Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
NMR_OPTIMA_BIDS/OPTIMA_convert_PPG_BIDS_4.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
77 lines (58 sloc)
2.57 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OPTIMA_convert_PPG_BIDS_4(BIDS, biomax_table) | |
% | |
% copies the ppg files into BIDS format | |
% | |
% | |
% file history: | |
% created M. Czisch 12.9.2019 | |
% last edited 13.11.2019 | |
sum_table = sum(biomax_table{:,{'PPG'}}); | |
if sum_table > 0 | |
fprintf('converting PPG and RESP files\n'); | |
% create correct file name | |
%short_ID = data_set_short_ID(BIDS); | |
tmp_str = strsplit(BIDS.input.data_dir(1).PatientID{3},'PTP'); | |
short_ID = ['P',tmp_str{2}]; | |
%short_ID = ['P1808']; | |
cmd_str = sprintf('mkdir %s/physio', BIDS.output.dir); system(cmd_str); | |
cmd_str = sprintf('date >> %s/physio/logfile_%s_%s_ppg_resp_conversion.txt', ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); | |
cd([BIDS.input.dir]); | |
cd('PPG'); | |
filenames_ppg = dir(['PPGData_epiRT_*']); | |
max = size(filenames_ppg,1); | |
filenames_resp = dir(['RESPData_epiRT_*']); | |
% if max ~= sum_table | |
% error('Error. \nnumber of ppg files does not match biomax_out\n'); | |
% end | |
j = 1; | |
clear cmd_str; | |
if biomax_table{4,{'PPG'}} % rest1 | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-rest_run-1_ppg.txt',filenames_ppg(j).name, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); print2log(cmd_str); | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-rest_run-1_resp.txt',filenames_resp(j).name, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); print2log(cmd_str); | |
j = j+1; | |
end | |
if biomax_table{7,{'PPG'}} % SIT1 | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-sit1_ppg.txt',filenames_ppg(j).name, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); print2log(cmd_str); | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-sit1_resp.txt',filenames_resp(j).name, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); print2log(cmd_str); | |
j = j+1; | |
end | |
end | |
cd([BIDS.input.dir]); | |
function print2log(cmd_str) | |
logfilename = sprintf('%s/physio/logfile_%s_%s_ppg_resp_conversion.txt', ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
fid = fopen(logfilename,'a'); | |
fprintf(fid,'%s\n',cmd_str); | |
fclose(fid); | |
end | |
end |