Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #24 from likeajumprope/development #26

Open
wants to merge 114 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
604c568
Development (#190)
mms-neuro May 17, 2022
400f458
add try catch for nanmean
likeajumprope Jul 30, 2022
aae150c
Merge branch 'master' into physio
mrikasper Aug 6, 2022
b26ea66
New pre-release v8.2.0-beta, fixing GitHub issue #204, see CHANGELOG.…
mrikasper Aug 10, 2022
d770919
Merge pull request #14 from likeajumprope/physio
likeajumprope Aug 28, 2022
dbe0448
Merge branch 'translationalneuromodeling:development' into development
mrikasper Sep 1, 2022
7809679
Merge branch 'development' into physio
mrikasper Sep 2, 2022
e248d9d
Updated to PhysIO R2022b-v8.2.0 with new interface to tapas_test and …
mrikasper Sep 5, 2022
997992a
Updated tapas toolbox infos for PhysIO
mrikasper Sep 5, 2022
c29743e
Updated PhysIO init to include tests folders for test functions
mrikasper Sep 5, 2022
f7b09a1
First attempt on generic examples path
mrikasper Sep 5, 2022
32c49ea
updated tapas_physio_version to R2022b-v8.2.0
mrikasper Sep 6, 2022
bb0596e
Added tapas_download_example_data suggestion if missing for test
mrikasper Sep 7, 2022
6d11a2c
Check other possible SPM toolbox locations in spm (my) defaults for…
mrikasper Sep 9, 2022
53679b5
Added Siemens_VB/RESP3T_Logversion_3 integration tests, updated wiki …
mrikasper Sep 12, 2022
5aa1ad5
Bugfix Philips reader for 12-columnar physlog files, see GitHub Issu…
mrikasper Sep 14, 2022
f79e500
Merge branch 'translationalneuromodeling:development' into development
likeajumprope Oct 17, 2022
55919ef
Added myself to CLA
likeajumprope Oct 17, 2022
c5fd528
Merge branch 'translationalneuromodeling:development' into development
mrikasper Oct 28, 2022
67a467d
Merge branch 'development' into small_bugs
mrikasper Nov 14, 2022
2708d11
Merge pull request #12 from likeajumprope/small_bugs
mrikasper Nov 14, 2022
edc5ead
New pre-release v8.2.0-beta, fixing GitHub issue #204, see CHANGELOG.…
mrikasper Aug 10, 2022
1f8fb64
Updated to PhysIO R2022b-v8.2.0 with new interface to tapas_test and …
mrikasper Sep 5, 2022
05d380b
Updated tapas toolbox infos for PhysIO
mrikasper Sep 5, 2022
7c03e30
Updated PhysIO init to include tests folders for test functions
mrikasper Sep 5, 2022
08d3d58
First attempt on generic examples path
mrikasper Sep 5, 2022
4c41db1
updated tapas_physio_version to R2022b-v8.2.0
mrikasper Sep 6, 2022
2733c6b
Added tapas_download_example_data suggestion if missing for test
mrikasper Sep 7, 2022
a708ccc
Check other possible SPM toolbox locations in spm (my) defaults for…
mrikasper Sep 9, 2022
6406bbe
Added Siemens_VB/RESP3T_Logversion_3 integration tests, updated wiki …
mrikasper Sep 12, 2022
06e5843
Bugfix Philips reader for 12-columnar physlog files, see GitHub Issu…
mrikasper Sep 14, 2022
186556b
Preparing release 6.1.0
mms-neuro Nov 18, 2022
fdc07c7
Preparing release v6.1.0
mms-neuro Nov 18, 2022
97eb19b
Merge branch 'tapas-v-6-1-0' into physio
mrikasper Dec 13, 2022
e3359f5
Updated tests for filtered traces to allow AbsTol (to avoid errors cl…
mrikasper Dec 13, 2022
c08ee7f
add matlab drive tag to gitignore
likeajumprope Mar 26, 2023
93e32f8
First suggestion for figure 2 Peak detection
likeajumprope Mar 30, 2023
59691c1
add headline and restructure Fig 2
likeajumprope Mar 30, 2023
ca3f3a2
add code
likeajumprope Mar 31, 2023
2f57b63
peak detection individual function
likeajumprope Mar 31, 2023
dea58c9
replace plotting with function
likeajumprope Mar 31, 2023
d6fec32
add saving in verbose
likeajumprope Mar 31, 2023
a4ef5d0
add saving in verbose
likeajumprope Mar 31, 2023
5c3826a
add peak function in physio_review
likeajumprope Apr 2, 2023
1241c63
add docs and author in peak detection plot function
likeajumprope Apr 2, 2023
fb6e680
add space in saving
likeajumprope Apr 2, 2023
6910149
igure: Perproc Coutcout actual scans
likeajumprope Apr 2, 2023
7c58cd2
Figure: Perproc Diagnostics for raw physiological time series
likeajumprope Apr 2, 2023
e706ac2
create new function plot traces
likeajumprope Apr 12, 2023
d3df68a
add verbose output
likeajumprope Apr 12, 2023
cc1c2e7
add verbose output
likeajumprope Apr 12, 2023
8b92a71
add new function call
likeajumprope Apr 12, 2023
ba8d9f7
remove typo
likeajumprope Apr 21, 2023
a8ee3c6
add polt traces to physio_review
likeajumprope Apr 21, 2023
7fd6287
remove old function
likeajumprope Apr 21, 2023
9eaffc3
add template for new sync plot function
likeajumprope Apr 21, 2023
f0c3d09
save relevant parameters
likeajumprope Apr 22, 2023
21ed152
add function
likeajumprope Apr 22, 2023
6fa96b9
add fucntion
likeajumprope Apr 22, 2023
bf49df5
add if statement and fix typos
likeajumprope Apr 24, 2023
2454714
fix typo
likeajumprope Apr 24, 2023
43b5e3f
remove review initialize
likeajumprope Apr 25, 2023
64aa619
add get cardiac
likeajumprope Apr 25, 2023
a17d529
add function plot get cardiac
likeajumprope Apr 25, 2023
abc062b
remove fucntion and add collector
likeajumprope Apr 25, 2023
882b976
add iterative template placeholder to review
likeajumprope Apr 25, 2023
1acf78e
isolate respiratory filter function
likeajumprope Apr 25, 2023
07e8121
add isolated function in filter respiratory
likeajumprope Apr 25, 2023
6105857
add filter physio review
likeajumprope Apr 26, 2023
50b2a8a
isolate plotting function
likeajumprope Apr 26, 2023
0523107
add rvt_hilbert_function
likeajumprope Apr 26, 2023
bb93d0f
add rvt hilbert plotting fucntion
likeajumprope Apr 26, 2023
bd92d59
rename detrended convHRV
likeajumprope Apr 27, 2023
566227a
organize functions and plots
likeajumprope Apr 27, 2023
1849f46
restructure and remove functions
likeajumprope Apr 27, 2023
b7f8160
add new function
likeajumprope Apr 27, 2023
fe9f08e
add create_hrv_regressors to review
likeajumprope Apr 27, 2023
36d55c2
rename rpulset
likeajumprope Apr 29, 2023
c240b6e
relabel rpulset
likeajumprope Apr 29, 2023
1632fb4
rename
likeajumprope Apr 29, 2023
648a8a1
rename rpulset after detrending
likeajumprope Apr 29, 2023
3cd5986
manipulate rpulset_out_trend
likeajumprope Apr 29, 2023
6716429
rename normalize
likeajumprope Apr 29, 2023
40a6f9b
remove functions and add summary plot func
likeajumprope Apr 29, 2023
2a09179
add functions to plotting func
likeajumprope Apr 29, 2023
042a0be
delete functions in file
likeajumprope Apr 29, 2023
ba833cb
save relevant structures
likeajumprope Apr 29, 2023
ea3b181
add resp filter to review
likeajumprope Apr 29, 2023
31f90e3
isolate plot function
likeajumprope Apr 29, 2023
2e6c4bb
new script for iiterate template
likeajumprope Apr 29, 2023
40b781c
save relevant structures
likeajumprope Apr 29, 2023
6ad1d66
add verbose to return verbose
likeajumprope Apr 30, 2023
40cfb53
add authorship
likeajumprope Apr 30, 2023
d1d284f
add verbose to return verbose
likeajumprope Apr 30, 2023
4ddbf28
isolate function and create new
likeajumprope Apr 30, 2023
eff9f76
remove plot function
likeajumprope Apr 30, 2023
5990bf7
save relevant structures for plotting
likeajumprope Apr 30, 2023
1a82d8f
add iterative template function review
likeajumprope May 5, 2023
601ea4c
return verbose
likeajumprope May 5, 2023
820ca25
create scan timing phillips
likeajumprope May 5, 2023
1e80a0e
add verbose
likeajumprope May 5, 2023
9492796
update checking for fields tapas_physio_review
likeajumprope May 5, 2023
936b179
Merge branch '4-retrospective-visualization-of-all-plots-for-debuggin…
likeajumprope May 5, 2023
b76cb18
Merge pull request #24 from likeajumprope/development
likeajumprope May 5, 2023
ca2edbc
remove comment
likeajumprope May 14, 2023
aa49507
take review out of if statement
likeajumprope May 14, 2023
2c4f18f
take save in review out of if statement
likeajumprope May 14, 2023
e1f3b43
take review out of if statement
likeajumprope May 14, 2023
3a99120
take review out of if statement
likeajumprope May 14, 2023
e9c9423
Merge branch 'development'
ImreKertesz Nov 15, 2023
926ddbe
Merge branch 'development'
ImreKertesz Nov 15, 2023
4386d70
Merge branch 'development'
ImreKertesz Nov 27, 2023
95b4459
Merge pull request #257 from translationalneuromodeling/master
mrikasper Feb 1, 2024
03b6cf3
Merge branch 'physio' into 4-retrospective-visualization-of-all-plots…
mrikasper Feb 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ lib
.idea
.idea/*
examples
.MATLABDriveTag

# Python
# See e.g. https://github.com/github/gitignore/blob/master/Python.gitignore
Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog
TAPAS toolbox
## [6.1.0] 2022-11-18
### Added
- Added `tapas_test` testing function. Started progressive introduction of testing framework.
- PhysIO [Version 8.2.0](PhysIO/CHANGELOG.md)
- Interface `tapas_physio_test` to TAPAS-generic `tapas_test` function
- Added suport for logfile version 3 of Siemens physio recordings
- multi ECG/Resp channels and interleaved status messages
- new integration test for Siemens VB Logversion 3
### Fixed
- PhysIO [Version 8.2.0](PhysIO/CHANGELOG.md)
- Removed dependence on `nanmean` (Statistics Toolbox)
- See [GitHub issue #205](https://github.com/translationalneuromodeling/tapas/issues/205)
- Compatibility with multiple SPM toolbox locations for `lmod` ([GitHub issue #211](https://github.com/translationalneuromodeling/tapas/issues/211))
- as listed in `spm_get_defaults('tbx')`
- Refactoring of Philips read-in to support novel 12-column logfile version, see [GitHub issue #207](https://github.com/translationalneuromodeling/tapas/issues/207#issuecomment-1246078600)

## [6.0.1] 2022-05-17

Expand All @@ -11,7 +26,7 @@ For this major release of TAPAS, we have decided to move currently unmaintained
to a dedicated [TAPAS Legacy repository](https://github.com/translationalneuromodeling/tapas_legacy).

### Added
- PhysIO [Version 8.1.0](Physio/CHANGELOG.md): BIDS Read-in for separate cardiac/respiratory trace files (e.g., due to different sampling frequencies)
- PhysIO [Version 8.1.0](PhysIO/CHANGELOG.md): BIDS Read-in for separate cardiac/respiratory trace files (e.g., due to different sampling frequencies)
- Compatibility of whole code base with Matlab compiler in order to run `spm_make_standalone`.
### Changed
- Moved `MICP`,`VBLM`,`h2gf` and `mpdcm` toolboxes to TAPAS Legacy repository.
Expand Down
1 change: 1 addition & 0 deletions Contributor-License-Agreement.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Stephan Heunis | Eindhoven University of Technology | Eindhoven | NL
Niklas Bürgi | SNS, University of Zurich | Zurich | CH | nbuergi | 1.0
Alexandre Sayal | CIBIT, University of Coimbra | Coimbra | PT | alexsayal | 1.0
Matthias Müller-Schrader | TNU, University of Zurich | Zurich | CH | mms-neuro | 1.1
Johanna M. M. Bayer | The University of Melbourne | Melbourne | AU | likeajumprope | 1.1
Saskia Bollmann | The University of Queensland | Brisbane | AUS | SaskiaBollmann | 1.1
**- Add Entry here -** | **- Add Entry here -** | **Add** | **Add** | **Add** | 1.1

Expand Down
23 changes: 21 additions & 2 deletions PhysIO/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,29 @@ RELEASE INFORMATION
Current Release
---------------

*Current version: PhysIO Toolbox Release R2022a, v8.1.0*
*Current version: PhysIO Toolbox Release R2022b, v8.2.0*

April 5th, 2022
November 22nd, 2022

Upcoming Release Notes (v8.2.0-beta)
------------------------------------

### Added
- Interface `tapas_physio_test` to TAPAS-generic `tapas_test` function
- Added suport for logfile version 3 of Siemens physio recordings
- multi ECG/Resp channels and interleaved status messages
- new integration test for Siemens VB Logversion 3
- Added support for ADInstruments/LabChart Txt-export format (see
[CUBRIC Seminar Example](https://github.com/BRAIN-TO/cubric-physio) and
gitlab branch #107)

### Fixed
- Removed dependence on `nanmean` (Statistics Toolbox)
- See [GitHub issue #205](https://github.com/translationalneuromodeling/tapas/issues/205)
- Compatibility with multiple SPM toolbox locations for `lmod` ([GitHub issue #211](https://github.com/translationalneuromodeling/tapas/issues/211))
- as listed in `spm_get_defaults('tbx')`
- Refactoring of Philips read-in to support novel 12-column logfile version, see [GitHub issue #207](https://github.com/translationalneuromodeling/tapas/issues/207#issuecomment-1246078600)
- Unit/Integration tests for filtered traces (cardiac and respiratory) switched to absolute tolerances (relative problematic for traces close to zero)

Minor Release Notes (v8.1.0)
----------------------------
Expand Down
4 changes: 2 additions & 2 deletions PhysIO/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TAPAS PhysIO Toolbox
====================

*Current version: Release 2022a, v8.1.0*
*Current version: Release 2022b, v8.2.0*

> Copyright (C) 2012-2022
> Lars Kasper
Expand Down Expand Up @@ -246,7 +246,7 @@ Contributors
------------

- Lead Programmer:
- [Lars Kasper](https://www.tnu.ethz.ch/en/team/faculty-and-scientific-staff/kasper.html),
- [Lars Kasper](https://brain-to.ca/content/lars-kasper),
TNU & MR-Technology Group, IBT, University of Zurich & ETH Zurich
- Project Team:
- Steffen Bollmann, Centre for Advanced Imaging, University of Queensland, Australia
Expand Down
141 changes: 128 additions & 13 deletions PhysIO/code/assess/tapas_physio_review.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
%
% See also

% Author: Lars Kasper
% Created: 2016-10-27
% Author: Johanna Bayer, Lars Kasper
% Created: 2016-10-27, completed 2023
% Copyright (C) 2016 TNU, Institute for Biomedical Engineering,
% University of Zurich and ETH Zurich.
%
Expand Down Expand Up @@ -72,6 +72,7 @@
sync = scan_timing.sync;
model = physio.model;
verbose = physio.verbose;
review = physio.verbose.review;

% Compatibility with old versions
if ~isfield(model, 'R_column_names')
Expand Down Expand Up @@ -118,28 +119,126 @@
verbose.close_figs = false;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Raw data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

verbose = tapas_physio_plot_raw_physdata(ons_secs.raw, verbose);

% tapas_physio_get_onsets_from_locs -> create plot function out of
% sub-function
% tapas_physio_get_cardiac_pulses_auto_matched -> subfunction for plot, only called
% if in this sub-branch

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Peak detection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if ismember(preproc.cardiac.initial_cpulse_select.method, {'auto','auto_template', 'auto_matched'})

if verbose.level >=2
if isfield(review, 'peak')

[verbose] = tapas_physio_plot_peak_detection_from_automatically_generated(review.peak.t, review.peak.c, ...
review.peak.cpulse, verbose);
end
end
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Iterative template
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% First and second figure

if verbose.level >= 3

if isfield(review, 'iter_temp')
[verbose] = tapas_physio_plot_iterative_template_creation(review.iter_temp.hasFirstGuessPeaks,...
review.iter_temp.t, review.iter_temp.c, review.iter_temp.cpulse1stGuess, review.iter_temp.nPulses1, ...
review.iter_temp.nPulses2, review.iter_temp.cpulse2ndGuess, review.iter_temp.meanLag1, ...
review.iter_temp.meanLag2, verbose);
end

% thrid figure
if isfield(review, 'temp_cyc')
[verbose] = tapas_physio_plot_templates_of_cycle_time(review.temp_cyc.tTemplate, ...
review.temp_cyc.template, review.temp_cyc.pulseTemplate, ...
review.temp_cyc.pulseCleanedTemplate, verbose)
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Sync Bundles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if verbose.level >= 3
if isfield(review, 'sync_bundles')

[verbose] = tapas_physio_plot_sync_bundles(review.sync_bundles.Nallvols, review.sync_bundles.t, ...
review.sync_bundles.SLICELOCS, verbose);
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Get cardiac
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if verbose.level >= 3

if isfield(review, 'get_cardiac')

[verbose] = tapas_physio_plot_get_cardiac_phase(review.get_cardiac.scannert, ...
review.get_cardiac.cardiac_phase, review.get_cardiac.pulset, ...
review.get_cardiac.svolpulse, verbose);
end

end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Preproc Coutcout actual scans - all events and gradients
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if verbose.level >= 2
verbose.fig_handles(end+1) = ...
tapas_physio_plot_cropped_phys_to_acqwindow(ons_secs, sqpar, verbose);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Preproc Respiratory filtering
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


if verbose.level>=3

if isfield(review, 'resp_filter')

[verbose] = tapas_physio_plot_filter_respiratory(review.resp_filter.rpulset, ...
review.resp_filter.m, review.resp_filter.s, review.resp_filter.t, ...
review.resp_filter.rpulset_out, review.resp_filter.rpulset_out_trend,...
review.resp_filter.trend,review.resp_filter.rpulset_out_trend_filt, verbose);

end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure: Preproc Diagnostics for raw physiological time series
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[verbose, ons_secs.c_outliers_low, ons_secs.c_outliers_high, ...
ons_secs.r_hist] = ...
tapas_physio_plot_raw_physdata_diagnostics(ons_secs.cpulse, ...
ons_secs.r, preproc.cardiac.posthoc_cpulse_select, verbose, ...
ons_secs.t, ons_secs.c);

% in tapas_physio_create_retroicor_regressors:
% tapas_physio_get_respiratory_phase
% function fh = plot_traces(pulset, rsampint, rout, resp_max, ...
% cumsumh, sumh, h, npulse, dpulse, rphase)

if verbose.level >=3

if isfield(review, 'traces')
fh = tapas_physio_plot_traces(review.traces.pulset, review.traces.rsampint, ...
review.traces.rout, review.traces.resp_max, review.traces.cumsumh,...
review.traces.sumh, review.traces.h, review.traces.npulse, review.traces.dpulse, ...
review.traces.r_phase);
end

end


%% RETROICOR
Expand Down Expand Up @@ -177,9 +276,25 @@
verbose.fig_handles(end+1) = tapas_physio_plot_rvt(ons_secs, sqpar);
end

%% tapas_physio_create_hrv_regressors, tapas_physio_create_rvt_regressors
% tapas_physio_create_noise_rois_regressors
% => create functions out of inline-plotting
if verbose.level >= 2
if model.rvt.include
[verbose] = tapas_physio_plot_rvt_hilbert(review.rvt_hilbert.t,review.rvt_hilbert.fr, ...
review.rvt_hilbert.fr_lp, review.rvt_hilbert.fr_mag, review.rvt_hilbert.fr_rv, ...
review.rvt_hilbert.fr_phase, review.rvt_hilbert.fr_if, verbose);
end
end

%% tapas_physio_create_hrv_regressors,
if verbose.level>=2
if model.rvt.include
[verbose] = tapas_physio_plot_create_hrv_regressors(review.create_hrv_regressors.sample_points, ...
review.create_hrv_regressors.hrOut, review.create_hrv_regressors.hr, review.create_hrv_regressors.t, ...
review.create_hrv_regressors.crf, review.create_hrv_regressors.convHRV, ...
review.create_hrv_regressors.delays,review.create_hrv_regressors.samplePointsOut,...
review.create_hrv_regressors.convHRVOut, verbose);
end
end


%% Overall regressors

Expand Down
Binary file added PhysIO/code/code
Binary file not shown.
49 changes: 16 additions & 33 deletions PhysIO/code/model/tapas_physio_create_hrv_regressors.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,16 @@
sample_points = tapas_physio_get_sample_points(ons_secs, sqpar, slicenum);
hr = tapas_physio_hr(ons_secs.cpulse, sample_points);

if verbose.level>=2
verbose.fig_handles(end+1) = tapas_physio_get_default_fig_params();
set(gcf, 'Name', 'Model: Regressors Heart Rate: HRV X CRF');
subplot(2,2,1)
plot(sample_points,hr,'r');xlabel('time (seconds)');
title('Heart Rate');
ylabel('beats per min (bpm)');
end


% Generate CRF
dt = sqpar.TR/sqpar.Nslices;
t = 0:dt:30; % seconds
crf = tapas_physio_crf(t);
crf = crf / max(abs(crf));

if verbose.level>=2
subplot(2,2,2)
plot(t, crf,'r');xlabel('time (seconds)');
title('Cardiac response function');
end


% Convolve and rescale for display purposes
convHRV = tapas_physio_conv(hr, crf, 'causal');
convHRV = convHRV / max(abs(convHRV));

if verbose.level>=2
subplot(2,2,3)
plot(sample_points, convHRV,'r');xlabel('time (seconds)');
title('Heart rate X cardiac response function');
end


% Create shifted regressors convolved time series, which is equivalent to
% delayed response functions according to Wikipedia (convolution)
%
Expand All @@ -101,7 +77,7 @@

% remove mean and linear trend to fulfill periodicity condition for
% shifting
convHRV = detrend(convHRV);
convHRV_detrend = detrend(convHRV);

% TODO: what happens at the end/beginning of shifted convolutions?
nDelays = numel(delays);
Expand All @@ -116,7 +92,7 @@
samplePointsOut = zeros(nScans,nSampleSlices);

for iDelay = 1:nDelays
convHRVShifted = circshift(convHRV, nShiftSamples(iDelay));
convHRVShifted = circshift(convHRV_detrend, nShiftSamples(iDelay));
for iSlice = 1:nSampleSlices
onset_slice = sqpar.onset_slice(iSlice);
hrOut(:,iSlice) = hr(onset_slice:sqpar.Nslices:end)';
Expand All @@ -125,14 +101,21 @@
end
end

% save relevant structures
verbose.review.create_hrv_regressors.sample_points = sample_points;
verbose.review.create_hrv_regressors.hrOut = hrOut;
verbose.review.create_hrv_regressors.hr = hr;
verbose.review.create_hrv_regressors.t = t;
verbose.review.create_hrv_regressors.crf = crf;
verbose.review.create_hrv_regressors.convHRV = convHRV;
verbose.review.create_hrv_regressors.delays = delays;
verbose.review.create_hrv_regressors.samplePointsOut = samplePointsOut;
verbose.review.create_hrv_regressors.convHRVOut = convHRVOut;

if verbose.level>=2
subplot(2,2,4)
[tmp, iShiftMin] = min(abs(delays));

hp{1} = plot(samplePointsOut, hrOut,'k--'); hold all;
hp{2} = plot(samplePointsOut, squeeze(convHRVOut(:,iShiftMin,:)),'r');
xlabel('time (seconds)');ylabel('regessor');
legend([hp{1}(1), hp{2}(1)], 'heart rate (bpm)', 'cardiac response regressor');
[verbose] = tapas_physio_plot_create_hrv_regressors(sample_points, hrOut, ...
hr, t, crf, convHRV, delays,samplePointsOut, convHRVOut, verbose)

end

end
Loading