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_LOG_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.
68 lines (52 sloc)
2.03 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_LOG_BIDS_4(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 13.11.2019 | |
fprintf('converting LOG 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('date >> %s/func/logfile_%s_%s_log_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('LOG'); | |
filenames = dir([short_ID, '*.log']); | |
max = size(filenames,1); | |
% loop over all possible log files | |
logfile_name_general = ['*SIT1*.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,'-SIT1.log']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'SIT1'},{'Log'}} | |
cmd_str = sprintf('cp %s %s/func/sub-%s_%s_task-sit1_bold.log',log_str, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); | |
end | |
if exist('cmd_str') | |
logfilename = sprintf('%s/func/logfile_%s_%s_log_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 | |
filenames = dir([short_ID, '_S1.txt']); | |
if size(filenames,1) > 2; error('multiple log txt files found'); end | |
log_str = [short_ID,'_S1.txt']; | |
if size(filenames,1) | |
if strcmp(filenames(1).name,log_str) & biomax_table{{'SIT1'},{'Log'}} | |
cmd_str = sprintf('cp %s %s/func/sub-%s_%s_task-sit1_bold_extracted.txt',log_str, ... | |
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3}); | |
system(cmd_str); | |
end | |
end | |
cd([BIDS.input.dir]); |