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.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
78 lines (61 sloc)
2.99 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(BIDS, biomax_table) | |
% | |
% copies the ppg files into BIDS format | |
% | |
% | |
% file history: | |
% created M. Czisch 25.4.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); | |
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'); | |
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 |