Skip to content
Permalink
02f25a58e6
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
101 lines (82 sloc) 4.16 KB
function OPTIMA_convert_EDF_BIDS_4(BIDS, biomax_table)
%
% copies the edf files into BIDS format
%
% Required fields of convert_EDF_BIDS:
%
% file history:
% created M. Czisch 31.1.2018
% last M. Czisch 13.11.2019
if logical(sum(biomax_table{:,{'EDF'}}))
fprintf('converting EDF 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_edf_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('EDF');
filenames = dir(['*', short_ID, '*.edf']);
max = size(filenames,1);
% loop over all possible log files
for i=1:max
clear cmd_str cmd_str2;
log_str = [short_ID,'S1.edf'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'SIT1'},{'EDF'}}
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-sit1_bold.edf',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str);
log_str = [short_ID,'S1.asc'];
if exist(log_str)
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_%s_task-sit1_bold.asc',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str2);
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/', short_ID,'S1.asc'])
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/', short_ID,'S1.asc'];
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_%s_task-sit1_bold.asc',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str2);
else
cmd_str2 = sprintf('no asc file found');
end
end
log_str = ['RS', short_ID,'.edf'];
if strcmp(filenames(i).name,log_str) & biomax_table{{'rest1'},{'EDF'}}
cmd_str = sprintf('cp %s %s/physio/sub-%s_%s_task-rest_run-1_bold.edf',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str);
log_str = ['RS', short_ID,'.asc'];
if exist(log_str)
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_%s_task-rest_run-1_bold.asc',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str2);
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/RS', short_ID,'.asc'])
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/RS', short_ID,'.asc'];
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_%s_task-rest_run-1_bold.asc',log_str, ...
BIDS.output.dir, BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
system(cmd_str2);
else
cmd_str2 = sprintf('no asc file found');
end
end
if exist('cmd_str')
logfilename = sprintf('%s/physio/logfile_%s_%s_edf_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
if exist('cmd_str2')
logfilename = sprintf('%s/physio/logfile_%s_%s_edf_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_str2);
fclose(fid);
end
end
end
cd([BIDS.input.dir]);