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 OPTIMA_convert_LOG_BIDS(BIDS, biomax_table)
%
% copies the logfiles into BIDS format
%
% Required fields of convert_LOG_BIDS:
%
% file history:
% created M. Czisch & F. Binder 8.11.2017
% last M. Czisch 10.4.2018 multiple logfile issue
fprintf('converting LOG files\n');
% create correct file name
short_ID = data_set_short_ID(BIDS);
cmd_str = sprintf('date >> %s/func/logfile_%s_log_conversion.txt', BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
cd([BIDS.input.dir]);
cd('LOG');
filenames = dir([short_ID, '*.log']);
max = size(filenames,1);
% loop over all possible log files
logfile_name_general = ['*Hariri*.log'];
if size(dir(logfile_name_general),1) > 2; error('multiple log files found'); end
logfile_name_general = ['*TET*.log'];
if size(dir(logfile_name_general),1) > 2; error('multiple log files found'); end
logfile_name_general = ['*reward*.log'];
if size(dir(logfile_name_general),1) > 2; error('multiple log files found'); end
logfile_name_general = ['*Nback*.log'];
if size(dir(logfile_name_general),1) > 2; error('multiple log files found'); end
logfile_name_general = ['*IST*.log'];
if size(dir(logfile_name_general),1) > 2; error('multiple log files found'); end
for i=1:max
clear cmd_str;
log_str = [short_ID,'-Hariri.log'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'faces'},{'Log'}}
cmd_str = sprintf('cp %s %s/func/sub-%s_task-hariri_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
end
log_str = [short_ID,'-TET.log'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'TET'},{'Log'}}
cmd_str = sprintf('cp %s %s/func/sub-%s_task-tet_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
end
log_str = [short_ID,'-Nback.log'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'nback'},{'Log'}}
cmd_str = sprintf('cp %s %s/func/sub-%s_task-nback_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
end
log_str = [short_ID,'-reward.log'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'Reward'},{'Log'}}
cmd_str = sprintf('cp %s %s/func/sub-%s_task-reward_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
end
log_str = [short_ID,'-IST.log']; % these are the IST logfiles renamed in biomax consistency.m
if strfind(filenames(i).name,log_str) & biomax_table{{'IST'},{'Log'}}
cmd_str = sprintf('cp %s %s/func/sub-%s_task-ist_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
system(cmd_str);
end
% log_str = [short_ID,'-IST_final_122014.log']; %these are the IST which were run with the HDMI box
% if strfind(filenames(i).name,log_str) & biomax_table{{'IST'},{'Log'}}
% cmd_str = sprintf('cp %s %s/func/sub-%s_task-ist_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
% system(cmd_str);
% end
%
% log_str = [short_ID,'-IST_flipped2.log']; %these are the current IST
% if strcmp(filenames(i).name,log_str) & biomax_table{{'IST'},{'Log'}}
% cmd_str = sprintf('cp %s %s/func/sub-%s_task-ist_bold.log',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3});
% system(cmd_str);
% end
%
if exist('cmd_str')
logfilename = sprintf('%s/func/logfile_%s_log_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
cd([BIDS.input.dir]);