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_EDF_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.
156 lines (134 sloc)
7.55 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_EDF_BIDS(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 28.3.2018 | |
if logical(sum(biomax_table{:,{'EDF'}})) | |
fprintf('converting EDF 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_edf_conversion.txt', BIDS.output.dir, BIDS.input.data_dir(1).PatientID{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; | |
log_str = ['har', short_ID,'.edf']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'faces'},{'EDF'}} | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-hariri_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['har', short_ID,'.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-hariri_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/har', short_ID,'.asc']) | |
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/har', short_ID,'.asc']; | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-hariri_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
else | |
cmd_str2 = sprintf('no asc file found'); | |
end | |
end | |
log_str = ['Te', short_ID,'.edf']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'TET'},{'EDF'}} | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-tet_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['Te', short_ID,'.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-tet_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/Te', short_ID,'.asc']) | |
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/Te', short_ID,'.asc']; | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-tet_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
else | |
cmd_str2 = sprintf('no asc file found'); | |
end | |
end | |
log_str = ['N', short_ID,'.edf']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'nback'},{'EDF'}} | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-nback_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['N', short_ID,'.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-nback_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/N', short_ID,'.asc']) | |
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/N', short_ID,'.asc']; | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-nback_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
else | |
cmd_str2 = sprintf('no asc file found'); | |
end | |
end | |
log_str = ['Re', short_ID,'.edf']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'Reward'},{'EDF'}} | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-reward_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['Re', short_ID,'.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-reward_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/Re', short_ID,'.asc']) | |
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/Re', short_ID,'.asc']; | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-reward_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{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_task-rest_run-1_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['RS', short_ID,'.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-rest_run-1_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{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_task-rest_run-1_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
else | |
cmd_str2 = sprintf('no asc file found'); | |
end | |
end | |
log_str = ['RS', short_ID,'b.edf']; | |
if strcmp(filenames(i).name,log_str) & biomax_table{{'rest2'},{'EDF'}} | |
cmd_str = sprintf('cp %s %s/physio/sub-%s_task-rest_run-2_bold.edf',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
log_str = ['RS', short_ID,'b.asc']; | |
if exist(log_str) | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-rest_run-2_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
elseif exist(['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/RS', short_ID,'b.asc']) | |
log_str = ['/run/media/spectro/DATAPART1/FORSCHUNGSAMBULANZ/ASC/RS', short_ID,'b.asc']; | |
cmd_str2 = sprintf('cp %s %s/physio/sub-%s_task-rest_run-2_bold.asc',log_str, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str2); | |
else | |
cmd_str2 = sprintf('no asc file found'); | |
end | |
end | |
if exist('cmd_str') | |
logfilename = sprintf('%s/physio/logfile_%s_edf_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 | |
if exist('cmd_str2') | |
logfilename = sprintf('%s/physio/logfile_%s_edf_conversion.txt', BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fid = fopen(logfilename,'a'); | |
fprintf(fid,'%s\n',cmd_str2); | |
fclose(fid); | |
end | |
end | |
end | |
cd([BIDS.input.dir]); |