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

9 function to write out preprocessed traces as bids #19

Open
wants to merge 105 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 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
97560a0
function place holder
likeajumprope Aug 9, 2022
aafc907
update
likeajumprope Aug 9, 2022
b26ea66
New pre-release v8.2.0-beta, fixing GitHub issue #204, see CHANGELOG.…
mrikasper Aug 10, 2022
ec7d171
add first function placements
likeajumprope Aug 11, 2022
449a2df
fucntion write2bids placeholder
likeajumprope Aug 11, 2022
c7d6152
add write bids switch to tapas_physio_new()
likeajumprope Aug 11, 2022
89cbc2a
add first json writer
likeajumprope Aug 17, 2022
098de0b
add documentation
likeajumprope Aug 17, 2022
30979b0
add trigger comverter
likeajumprope Aug 25, 2022
d770919
Merge pull request #14 from likeajumprope/physio
likeajumprope Aug 28, 2022
76e3a10
Merge pull request #16 from likeajumprope/development
likeajumprope Aug 28, 2022
1db3ccf
save dir and write
likeajumprope Aug 30, 2022
8e6bf46
Merge branch '9-function-to-write-out-preprocessed-traces-as-bids' of…
likeajumprope Aug 30, 2022
08705b0
add function
likeajumprope Sep 1, 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
777b69d
add places for functions
likeajumprope Sep 9, 2022
5d01dfe
add different wrting points
likeajumprope Sep 9, 2022
a59ff09
change write bids input
likeajumprope Sep 9, 2022
68e4654
add tags
likeajumprope Sep 9, 2022
6d11a2c
Check other possible SPM toolbox locations in spm (my) defaults for…
mrikasper Sep 9, 2022
7a8a4d2
add documentation, change location parameter
likeajumprope Sep 10, 2022
53679b5
Added Siemens_VB/RESP3T_Logversion_3 integration tests, updated wiki …
mrikasper Sep 12, 2022
0ef5c2e
split 2 and 3 writing case
likeajumprope Sep 12, 2022
ab574f1
add physio structure as input
likeajumprope Sep 12, 2022
669c657
add physio and location file
likeajumprope Sep 12, 2022
99934fa
add write_bids argument
likeajumprope Sep 12, 2022
77f8847
debigging
likeajumprope Sep 12, 2022
5aa1ad5
Bugfix Philips reader for 12-columnar physlog files, see GitHub Issu…
mrikasper Sep 14, 2022
4494184
make changes to input
likeajumprope Sep 18, 2022
74b80ee
add write2bids
likeajumprope Sep 18, 2022
51711e7
changes
likeajumprope Sep 18, 2022
fe7d8c9
change functions
likeajumprope Sep 18, 2022
2f51f5e
Merge pull request #17 from likeajumprope/physio
likeajumprope Sep 19, 2022
b7b3882
add if statement
likeajumprope Sep 19, 2022
59ca680
bug fixes
likeajumprope Sep 19, 2022
2cc3efd
add semicolons
likeajumprope Sep 26, 2022
fe078e9
add one matrix output
likeajumprope Sep 26, 2022
5c596c0
add semicolon
likeajumprope Sep 26, 2022
eda7dd8
adding ascii file output
likeajumprope Oct 15, 2022
a63f044
add write ascii location 2 and 3
likeajumprope Oct 15, 2022
cc1ca0d
switch bids and tag
likeajumprope Oct 15, 2022
5cfbe32
which_bids to bids_step
likeajumprope Oct 15, 2022
64f1586
add bids prefix
likeajumprope Oct 16, 2022
21bbcfe
change output fiel to bids standard tsv
likeajumprope Oct 16, 2022
6919bdc
change bids_step
likeajumprope Oct 16, 2022
6c6bf82
change json file format to bids standard
likeajumprope Oct 16, 2022
f79e500
Merge branch 'translationalneuromodeling:development' into development
likeajumprope Oct 17, 2022
55919ef
Added myself to CLA
likeajumprope Oct 17, 2022
b1d01fc
add if else statement wrt jsonencode
likeajumprope Oct 21, 2022
7438a29
add gzip
likeajumprope Oct 21, 2022
296fe70
add stdructure for consistency test
likeajumprope Oct 23, 2022
c5fd528
Merge branch 'translationalneuromodeling:development' into development
mrikasper Oct 28, 2022
59ffbfb
adapt gitignore
likeajumprope Oct 30, 2022
d126d8b
add reference bids files in the test folder
likeajumprope Oct 30, 2022
9553589
move test files to TestReferenceExample folder
likeajumprope Oct 30, 2022
4dbe1bc
add reference and example path for bids test
likeajumprope Oct 30, 2022
55391b5
add load physio.mat to be adapted
likeajumprope Oct 30, 2022
fa96efb
identity test
likeajumprope Nov 5, 2022
7cc966d
Merge branch '20-add-tests-for-bids-writer' into 9-function-to-write-…
likeajumprope Nov 6, 2022
4c5368f
Merge pull request #22 from likeajumprope/9-function-to-write-out-pre…
likeajumprope Nov 6, 2022
a579cef
add missing brackets after cd
likeajumprope Nov 6, 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
ab5c75a
Merge branch 'development' into 9-function-to-write-out-preprocessed-…
mrikasper Nov 14, 2022
dd25f6f
cosmetics CLA table
mrikasper Nov 14, 2022
754658c
clear branch
likeajumprope Nov 15, 2022
eba2746
files that were already there
likeajumprope Nov 15, 2022
0739a1b
bids writer test files
likeajumprope Nov 15, 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
e937a66
remove examples from gitignore
likeajumprope Nov 25, 2022
af6681b
add missing brackets in readin bids
likeajumprope Nov 25, 2022
e3d80a2
Merge pull request #23 from likeajumprope/test-files
likeajumprope Dec 3, 2022
0c28079
Have test run from ECT3T_folder
likeajumprope Dec 5, 2022
4f32bcf
de-bug test
likeajumprope Dec 7, 2022
7a9c781
uncomment remaining tests
likeajumprope Dec 7, 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
083eec6
Update Contributor-License-Agreement.md
likeajumprope Nov 3, 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
1fe076b
Merge branch 'physio' into 9-function-to-write-out-preprocessed-trace…
mrikasper Jan 11, 2024
743b2da
Removed erroneously added examples folder (large files)
mrikasper Jan 17, 2024
dbdfcd3
Merge branch 'translationalneuromodeling:master' into 9-function-to-w…
mrikasper Jan 22, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ lib
*.DS_Store
.idea
.idea/*
examples
physio_out
.gitignore

# 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
3 changes: 2 additions & 1 deletion Contributor-License-Agreement.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ and
each GitHub User listed in the following table:

Name | Company/Institution/Address | City | Country | E-Mail/GitHub Username | CLA version accepted
------------------------ | ---------------------------------- | --------- | ------- | ---------------------- | ------------------
------------------------ | ---------------------------------- | --------- | ------- | ---------------------- | --------------------
Lars Kasper | TNU, University of Zurich | Zurich | CH | mrikasper | 1.0
Eduardo Aponte | TNU, University of Zurich | Zurich | CH | tnutapas | 1.0
Daniel Hoffmann Ayala | Technical University | Munich | D | DanielHoffmannAyala | 1.0
Expand All @@ -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

Minor Release Notes (v8.2.0)
----------------------------

### 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
40 changes: 26 additions & 14 deletions PhysIO/code/model/tapas_physio_create_noise_rois_regressors.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,7 @@
[fpRoi,fnRoi] = fileparts(Vroi.fname);
Vroi.fname = fullfile(fpRoi, sprintf('noiseROI_%s.nii', fnRoi));
spm_write_vol(Vroi,roi);

% Overlay the final noise ROI (code from spm_orthviews:add_c_image)
if verbose.level >= 2
spm_orthviews('addcolouredimage',r,Vroi.fname ,[1 0 0]);
hlabel = sprintf('%s (%s)',Vroi.fname ,'Red');
c_handle = findobj(findobj(st.vols{r}.ax{1}.cm,'label','Overlay'),'Label','Remove coloured blobs');
ch_c_handle = get(c_handle,'Children');
set(c_handle,'Visible','on');
uimenu(ch_c_handle(2),'Label',hlabel,'ForegroundColor',[1 0 0],...
'Callback','c = get(gcbo,''UserData'');spm_orthviews(''context_menu'',''remove_c_blobs'',2,c);');
spm_orthviews('redraw')
end
final_roi_files{r} = Vroi.fname;

Yroi = Yimg(roi(:)==1, :); % Time series of the fMRI volume in the noise ROIs

Expand Down Expand Up @@ -274,7 +263,7 @@

% plot
if verbose.level >=2
stringFig = sprintf('Model: Noise\\_rois: Extracted principal components for ROI %d', r);
stringFig = sprintf('Model: Noise Rois: Extracted principal components for ROI %d', r);
verbose.fig_handles(end+1) = tapas_physio_get_default_fig_params();
set(gcf, 'Name', stringFig);
plot(R);
Expand All @@ -299,6 +288,29 @@
R_noise_rois = [R_noise_rois, R];


end % nROI
end % nROIs


%% Summary plot noise roise location
% Overlay intial and final noise ROI (code from spm_orthviews:add_c_image)
% (before/after reslice, threshold and erosion)
if verbose.level >= 2
spm_check_registration( roi_files{:} );
spm_orthviews('context_menu','interpolation',3); % disable interpolation // 3->NN , 2->Trilin , 1->Sinc
for r = 1:nRois
Vroi.fname = final_roi_files{r};
spm_orthviews('addcolouredimage',r,Vroi.fname ,[1 0 0]);
hlabel = sprintf('%s (%s)',Vroi.fname ,'Red');

if isprop(st.vols{r}.ax{1}, 'cm')
c_handle = findobj(findobj(st.vols{r}.ax{1}.cm,'label','Overlay'),'Label','Remove coloured blobs');
ch_c_handle = get(c_handle,'Children');
set(c_handle,'Visible','on');
uimenu(ch_c_handle(2),'Label',hlabel,'ForegroundColor',[1 0 0],...
'Callback','c = get(gcbo,''UserData'');spm_orthviews(''context_menu'',''remove_c_blobs'',2,c);');
end
end
spm_orthviews('redraw')
end

end % function
33 changes: 19 additions & 14 deletions PhysIO/code/plot/tapas_physio_plot_raw_physdata_siemens.m
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
function fh = tapas_physio_plot_raw_physdata_siemens(dataCardiac)
function fh = tapas_physio_plot_raw_physdata_siemens(dataPhysio)
% plots cardiac data as extracted from Siemens log file
%
% output = tapas_physio_plot_raw_physdata_siemens(input)
% fh = tapas_physio_plot_raw_physdata_siemens(dataCardiac)
%
% IN
%
% dataPhysio output struct from tapas_physio_siemens_table2cardiac
% OUT
%
% EXAMPLE
% tapas_physio_plot_raw_physdata_siemens
%
% See also tapas_physio_read_physlogfiles_siemens
% See also tapas_physio_siemens_table2cardiac
% See also tapas_physio_read_physlogfiles_siemens tapas_physio_siemens_table2cardiac

% Author: Lars Kasper
% Created: 2016-02-29
Expand All @@ -23,30 +22,36 @@
% (either version 3 or, at your option, any later version). For further details, see the file
% COPYING or <http://www.gnu.org/licenses/>.

tapas_physio_strip_fields(dataCardiac);
tapas_physio_strip_fields(dataPhysio);

stringTitle = 'Read-In: Raw Siemens physlog data';
fh = tapas_physio_get_default_fig_params();
set(gcf, 'Name', stringTitle);
stem(cpulse_on, ampl*ones(size(cpulse_on)), 'g'); hold all;
stem(cpulse_off, ampl*ones(size(cpulse_off)), 'r');
stem(t(stopSample), ampl , 'm');
plot(t, channel_1);
plot(t, channel_AVF);
plot(t, meanChannel);

stringLegend = { ...
'cpulse on', 'cpulse off', 'assumed last sample of last scan volume', ...
'channel_1', 'channel_{AVF}', 'mean of channels'};
stringLegend = {'physio trigger on', 'physio trigger off', ...
'assumed last sample of last scan volume'};

nChannels = size(recordingChannels, 2);

for iChannel = 1:nChannels
plot(t, recordingChannels(:,iChannel));
stringLegend{end+1} = sprintf('channel %d', iChannel);
end

plot(t, meanChannel);
stringLegend{end+1} = 'mean of channels';

if ~isempty(recording_on)
stem(recording_on, ampl*ones(size(recording_on)), 'k');
stringLegend{end+1} = 'phys recording on';
stringLegend{end+1} = 'physio recording on';
end

if ~isempty(recording_off)
stem(recording_off, ampl*ones(size(recording_off)), 'k');
stringLegend{end+1} = 'phys recording off';
stringLegend{end+1} = 'physio recording off';
end
legend(stringLegend);
title(stringTitle);
Expand Down
12 changes: 8 additions & 4 deletions PhysIO/code/preproc/tapas_physio_filter_respiratory.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@

%% Basic preproc and outlier removal

% If rpulset has nans, replace them with zeros
rpulsetOffset = nanmean(rpulset);
rpulset(isnan(rpulset)) = nanmean(rpulset);
% If rpulset has nans, replace them with mean of valid values
try
rpulsetOffset = mean(rpulset, 'omitnan');
catch % for backwards compatibility < Matlab 2016a
rpulsetOffset = nanmean(rpulset);
end
rpulset(isnan(rpulset)) = rpulsetOffset;

rpulset = detrend(rpulset, 3); % Demean / detrend to reduce edge effects

Expand Down Expand Up @@ -178,4 +182,4 @@
legend(handles, labels);
end

end
end
37 changes: 32 additions & 5 deletions PhysIO/code/readin/tapas_physio_read_columnar_textfiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
% Reads _PULS, _RESP, _ECG, _Info-files from Siemens tics format with
% multiple numbers of columns and different column headers
%
% output = tapas_physio_read_columnar_textfiles(input)
% [C, columnNames] = tapas_physio_read_columnar_textfiles(fileName, fileType)
%
% IN
% fileName *.log from Siemens VD/VE tics file format
% fileType 'ECG', 'PULS', 'RESP', 'Info', 'BIOPAC_TXT'
% fileType 'ECG', 'PULS', 'RESP', 'Info', 'BIOPAC_TXT', 'PHILIPS'
% If not specified, this is read from the last part of the
% filename after the last underscore, e.g.
% Physio_*_ECG.log -> log
Expand Down Expand Up @@ -56,6 +56,16 @@


switch upper(fileType)
case {'ADINSTRUMENTS_TXT', 'LABCHART_TXT'}
strColumnHeader = 'ChannelTitle=';

%sub-02 from CUBRIC
parsePatternPerNColumns{4} = '%f %f %f %f';
nEmptyLinesAfterHeader(4) = 1;

%sub-01 from CUBRIC
parsePatternPerNColumns{7} = '%f %f %f %f %f %f %f';
nEmptyLinesAfterHeader(7) = 4;
case 'BIDS'
strColumnHeader = '';
parsePatternPerNColumns{3} = '%f %f %f';
Expand All @@ -80,6 +90,14 @@
nEmptyLinesAfterHeader(3) = 0;
nEmptyLinesAfterHeader(4) = 1;
nEmptyLinesAfterHeader(5) = 1;
case 'PHILIPS'
strColumnHeader = 'v1raw'; % Philips header similar to: # v1raw v2raw v1 v2 ppu resp vsc gx gy gz mark mark2
parsePatternPerNColumns{10} = '%d %d %d %d %d %d %d %d %d %s';
parsePatternPerNColumns{11} = '%d %d %d %d %d %d %d %d %d %s %s'; % log file version 2 with two marker columns
parsePatternPerNColumns{12} = '%d %d %d %d %d %d %d %d %d %d %s %s'; % logfile version 3(?, from Nottingham) with 'vsc' column
nEmptyLinesAfterHeader(10) = 0;
nEmptyLinesAfterHeader(11) = 0;
nEmptyLinesAfterHeader(12) = 0;
case {'PULS', 'RESP', 'ECG'} % have similar format
% Cologne (RESP/PULS/ECG for 2nd column):
% Time_tics RESP Signal
Expand All @@ -104,20 +122,27 @@
while ~haveFoundColumnHeader
nHeaderLines = nHeaderLines + 1;
strLine = fgets(fid);
haveFoundColumnHeader = any(regexp(upper(strLine), strColumnHeader));
haveFoundColumnHeader = any(regexpi(strLine, strColumnHeader));
end

switch upper(fileType)
case {'ADINSTRUMENTS_TXT', 'LABCHART_TXT'}
columnNames = regexp(strLine, '([\t])', 'split');
nColumns = numel(columnNames);
case 'BIDS' % will be in separate json-file
columnNames = {};
nColumns = 3;
case 'BIOPAC_TXT' % bad column names with spaces...e.g. 'RESP - RSP100C'
columnNames = regexp(strLine, '([\t])', 'split');
nColumns = numel(columnNames);
case 'PHILIPS'
columnNames = regexp(strLine, '([\w]*)', 'tokens');
columnNames = [columnNames{:}]; % cell of cell into cell of strings
nColumns = numel(columnNames);
otherwise
columnNames = regexp(strLine, '([\w]*)', 'tokens');
columnNames = [columnNames{:}]; % cell of cell into cell of strings
nColumns = numel(regexp(strLine, ' *')) + 1; % columns are separated by arbitrary number of spaces
nColumns = numel(regexp(strLine, ' *')) + 1; % columns are separated by arbitrary number of spaces...TODO: Why + 1?
end
fclose(fid);

Expand All @@ -126,8 +151,10 @@
% now read the rest of the file
fid = fopen(fileName);
switch upper(fileType)
case {'BIDS', 'BIOPAC_TXT', 'INFO', 'PULS', 'RESP'}
case {'ADINSTRUMENTS_TXT', 'LABCHART_TXT', 'BIDS', 'BIOPAC_TXT', 'INFO', 'PULS', 'RESP'}
C = textscan(fid, parsePatternPerNColumns{nColumns}, 'HeaderLines', nHeaderLines);
case 'PHILIPS' % sometimes odd lines with single # occur within text file
C = textscan(fid, parsePatternPerNColumns{nColumns}, 'HeaderLines', nHeaderLines, 'CommentStyle', '#');
case {'ECG'}
C = textscan(fid, parsePatternPerNColumns{nColumns}, 'HeaderLines', nHeaderLines);
if nColumns == 4 % CMRR, different ECG channels possible!
Expand Down
3 changes: 3 additions & 0 deletions PhysIO/code/readin/tapas_physio_read_physlogfiles.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
end

switch lower(log_files.vendor)
case {'adinstruments_txt', 'labchart_txt'}
[c, r, t, cpulse, acq_codes] = ...
tapas_physio_read_physlogfiles_adinstruments_txt(log_files, cardiac_modality, verbose);
case 'bids'
[c, r, t, cpulse, acq_codes] = ...
tapas_physio_read_physlogfiles_bids(log_files, cardiac_modality, verbose);
Expand Down
Loading