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?
test/convert_GE_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.
138 lines (129 sloc)
7.61 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 convert_GE_BIDS(BIDS, biomax_table) | |
% | |
% performes dicom2niix and saves data in BIDS format | |
% | |
% Required fields of convert_GE_BIDS: | |
% | |
% BIDS - BIDS structure | |
% biomax_table - biomax_out information in table format | |
% | |
% | |
% file history: | |
% created M. Czisch & F. Binder 20.11.2017 | |
% last edited M. Czisch 31.1.2018 | |
% flags are introduced to mark already processed files | |
flag_RSN2 = 0; | |
flag_RSN3 = 0; | |
for i = 1:2 % loop over days | |
max = size(BIDS.input.data_dir(i).ProtocolName,2); | |
if i == 1 | |
cd([BIDS.input.dir,'/',BIDS.input.data_dir(1).name]); | |
for j = 3:max %ignore '.' and '..' | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'Sag FSPGR BRAVO 1x1x1mm') | |
if biomax_table{{'T1w'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_T1w -z y -o %s/anat %s >> %s/anat/logfile_anat_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI rest') | |
if biomax_table{{'rest1'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-rest_run-1_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'EPI segmentation T2w') | |
if biomax_table{{'EPI1'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_inplaneT2star_run-1 -z y -o %s/anat %s >> %s/anat/logfile_anat_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI TET') | |
if biomax_table{{'TET'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-tet_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'Ax T2 FLAIR') | |
if biomax_table{{'FLAIR'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_FLAIR -z y -o %s/anat %s >> %s/anat/logfile_anat_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI reward') | |
if biomax_table{{'Reward'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-reward_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'DTI 2.0 DSE 66 Dir Nex1') | |
if biomax_table{{'DTI'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_run-1_dwi -z y -o %s/dwi %s >> %s/dwi/logfile_dwi_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'DTI 2.0 DSE 66 Dir pepolar1') | |
if biomax_table{{'Pepolar'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_run-2_dwi -z y -o %s/dwi %s >> %s/dwi/logfile_dwi_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI n-back') | |
if biomax_table{{'nback'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-nback_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
end | |
elseif i==2 | |
cd([BIDS.input.dir,'/',BIDS.input.data_dir(2).name]); | |
for j = 3:max %ignore '.' and '..' | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI faces') | |
if biomax_table{{'faces'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-hariri_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'EPI segmentation T2w') | |
if biomax_table{{'EPI2'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_inplaneT2star_run-2 -z y -o %s/anat %s >> %s/anat/logfile_anat_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI rest') & ~flag_RSN2 | |
if biomax_table{{'rest2'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-rest_run-2_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
system(cmd_str); | |
flag_RSN2 = 1; | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI IST TR2000, 40SL') | |
if biomax_table{{'IST'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-ist_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
%system(cmd_str); | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI rest') & ~flag_RSN3 | |
if biomax_table{{'rest3'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-rest_run-3_bold -z y -o %s/func %s >> %s/func/logfile_func_dcm2nii.txt',BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir); | |
fprintf('\n%s', cmd_str); | |
system(cmd_str); | |
flag_RSN3 = 1; | |
end | |
end | |
end | |
end | |
end | |
cd([BIDS.input.dir]); |