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_GE_BIDS_3.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
154 lines (139 sloc)
9.28 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_GE_BIDS_3(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 | |
% adapted to inclue SIT1 M. Czisch 17.7.2019 | |
% last edited M. Czisch 05.11.2019 | |
test_flag = 0; % if test then 1 | |
% flags are introduced to mark already processed files | |
flag_RSN2 = 0; | |
flag_RSN3 = 0; | |
fprintf('converting GE files\n'); | |
cmd_str = sprintf('date >> %s/func/logfile_%s_func_dcm2nii.txt',BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
if ~test_flag system(cmd_str); end | |
cmd_str = sprintf('date >> %s/anat/logfile_%s_anat_dcm2nii.txt',BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
if ~test_flag system(cmd_str); end | |
cmd_str = sprintf('date >> %s/dwi/logfile_%s_dwi_dcm2nii.txt',BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
if ~test_flag system(cmd_str); end | |
cmd_str = sprintf('mkdir %s/dicom',BIDS.output.dir); system(cmd_str); | |
number_of_days = size(BIDS.input.data_dir,2); | |
for i = 1:number_of_days % loop over days | |
max = size(BIDS.input.data_dir(i).subdir,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_%s_anat_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_T1w.dicom.1 >> %s/anat/logfile_%s_anat_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
end | |
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_%s_func_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
filename = sprintf('%s/func/sub-%s_task-rest_run-1_bold.json',BIDS.output.dir,BIDS.input.data_dir(i).PatientID{j}); | |
OPTIMA_dataset_func_description_BIDS_3(BIDS,filename, biomax_table{{'rest1'},:}); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_task-rest_run-1_bold.dicom.1 >> %s/func/logfile_%s_func_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
cmd_str = sprintf('touch %s/func/sub-%s_task-rest_run-1_bold_README.txt >> %s/func/logfile_%s_func_dcm2nii.txt',... | |
BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
system(cmd_str); | |
end; | |
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_%s_anat_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_inplaneT2star_run-1.dicom.1 >> %s/anat/logfile_%s_anat_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
end; | |
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_%s_anat_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_FLAIR.dicom.1 >> %s/anat/logfile_%s_anat_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
end; | |
end | |
end | |
if strcmp(BIDS.input.data_dir(i).SeriesDescription{j},'fMRI SIT1') | |
if biomax_table{{'SIT1'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_task-sit1_bold -z y -o %s/func %s >> %s/func/logfile_%s_func_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
filename = sprintf('%s/func/sub-%s_task-sit1_bold.json',BIDS.output.dir,BIDS.input.data_dir(i).PatientID{j}); | |
OPTIMA_dataset_func_description_BIDS_3(BIDS,filename, biomax_table{{'SIT1'},:}); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_task-sit1_bold.dicom.1 >> %s/func/logfile_%s_func_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
cmd_str = sprintf('touch %s/func/sub-%s_task-sit1_bold_README.txt >> %s/func/logfile_%s_func_dcm2nii.txt',... | |
BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
system(cmd_str); | |
end; | |
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_%s_dwi_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_run-1_dwi.dicom.1 >> %s/dwi/logfile_%s_dwi_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
end; | |
end | |
end | |
if logical(strfind(BIDS.input.data_dir(i).SeriesDescription{j},'polar')) | |
if biomax_table{{'Pepolar'},{'Ser'}} | |
cmd_str = sprintf('dcm2niix -f sub-%s_run-2_dwi -z y -o %s/dwi %s >> %s/dwi/logfile_%s_dwi_dcm2nii.txt',... | |
BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
fprintf('\n%s', cmd_str); | |
if ~test_flag | |
system(cmd_str); | |
cmd_str = sprintf('cp %s/*MRDC.1 %s/dicom/sub-%s_run-2_dwi.dicom.1 >> %s/dwi/logfile_%s_dwi_dcm2nii.txt', ... | |
BIDS.input.data_dir(i).subdir{j}, BIDS.output.dir, BIDS.input.data_dir(i).PatientID{j}, BIDS.output.dir, BIDS.input.data_dir(1).PatientID{3}); | |
system(cmd_str); | |
end; | |
end | |
end | |
end | |
end | |
end | |
cd([BIDS.input.dir]); |