Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
function repair_PPG_BIDS(BIDS, biomax_table)
%
% copies the ppg files into BIDS format
% for datasets before 29.5.2018 (old Become Version 1.0.1)
%
% file history:
% created M. Czisch 29.5.2018
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);
%cmd_str = sprintf('mkdir %s/physio', BIDS.output.dir); system(cmd_str);
cmd_str = sprintf('date >> %s/physio/logfile_%s_ppg_resp_conversion.txt', BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
cd([BIDS.input.dir]);
cd('PPG_Tag1');
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_task-rest_run-1_ppg.txt',filenames_ppg(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-rest_run-1_resp.txt',filenames_resp(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
j = j+1;
end
if biomax_table{6,{'PPG'}} % TET
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-tet_ppg.txt',filenames_ppg(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-tet_resp.txt',filenames_resp(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
j = j+1;
end
if biomax_table{8,{'PPG'}} % Reward
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-reward_ppg.txt',filenames_ppg(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-reward_resp.txt',filenames_resp(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
j = j+1;
end
if biomax_table{11,{'PPG'}} % nack
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-nback_ppg.txt',filenames_ppg(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-nback_resp.txt',filenames_resp(j).name, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str); print2log(cmd_str);
end
end
cd([BIDS.input.dir]);
function print2log(cmd_str)
logfilename = sprintf('%s/physio/logfile_%s_ppg_resp_conversion.txt', BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
fid = fopen(logfilename,'a');
fprintf(fid,'%s\n',cmd_str);
fclose(fid);
end
end