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
140 lines (87 sloc) 3.6 KB
function BIDS = OPTIMA_make_BIDS_4(input_dir)
%
% Prepare datasets for BIDS format, version 4, created 12.11.2019
%
% Required fields of make_BIDS:
%
% input_dir - location of the GE data, use absolute path
%
% data must have passed consistency checks using
% OPTIMA_consistency.m in /run/media/spectro/DATAPART1/OPTIMA/autoscripts_BIOMAX
% the script is expecting a file named
% "biomax_out_*_VERIFIED*.txt" or
% "biomax_out_*_MODIFIED*.txt"
% to be present in the subjects main directory
%
% directories must be known:
% addpath '/run/media/spectro/DATAPART1/OPTIMA/autoscripts_BIDS'
%
% function call, e.g.: OPTIMA_make_BIDS_4('/run/media/spectro/DATAPART1/OPTIMA/PTP0270_T0')
%
% structure BIDS
% input.dir - directory with verified data
% e.g. BIDS.input.dir = '/run/media/spectro/DATAPART1/OPTIMA/PTP0270_T0'
% input.biomax - biomax_out filename
%
% file history:
% created M. Czisch 12.11.2019
% last modified 12.11.2019 M. Czisch to consider T0 and T7, BIDS directory
% naming adjusted, nii filenames corrected
% BecomeVersion 1.0.2
fprintf('\n\nStart BIDS conversion\n');
clear BIDS
BIDS.input.dir = input_dir;
BIDS.output.dir = '';
BIDS.autoscripts.dir = '/run/media/spectro/DATAPART1/OPTIMA/autoscripts_BIDS';
% have the data being for consistency checked already?
% does biomax_out exist?
BIDS = OPTIMA_check_BIOMAX_4(BIDS);
% check and prepare temporary BIDS directory structure
pathInfo = what(BIDS.input.dir);
current_dir = pathInfo.path
tmp = strsplit(current_dir,'_');
if size(tmp,2) ~= 2
fprintf('\n error file name\n');
return;
end
day_ID = tmp{2};
BIDS.output.dir = [current_dir,'/BIDS/'];
OPTIMA_check_BIDS_4(BIDS.input.dir); %OK
mkdir_BIDS(BIDS.output.dir); %OK
% load and format biomax_out info
biomax = load(BIDS.input.biomax);
biomax_table = array2table(biomax,...
'VariableNames',{'Ser','Log','EDF','PPG'},...
'RowNames',{'Loc';'T1w';'Cal';'rest1';...
'EPI1';'FLAIR';'SIT1';...
'DTI';'Pepolar'});
% copy biomax_out file to BIDS directory
cmd_str = sprintf('cp %s %s/%s', BIDS.input.biomax, BIDS.output.dir, BIDS.input.biomax); system(cmd_str);
% read content of GE EXAM and SERIES files
BIDS = OPTIMA_read_GE_BIDS_4(BIDS);
% do the conversion to BIDS format
% %MC
% for j=3:size(BIDS.input(1).data_dir.subdir,2)
% BIDS.input(1).data_dir.PatientID{j}='PTP1808_T0';
% end
% %
OPTIMA_convert_GE_BIDS_4(BIDS, biomax_table);
% make a json file with dataset description
OPTIMA_dataset_description_BIDS_4(BIDS,biomax_table);
% copy the ANALYZER files to BIDS naming format
% does not apply for OPTIMA, this is from BeCOME
% OPTIMA_convert_ANALYZER_BIDS_2(BIDS,biomax_table);
% do the conversion of logfiles to BIDS naming format
OPTIMA_convert_LOG_BIDS_4(BIDS,biomax_table);
% do the conversion of EDF files to BIDS naming format
OPTIMA_convert_EDF_BIDS_4(BIDS,biomax_table);
% do the conversion of PPG and RESP files to BIDS
OPTIMA_convert_PPG_BIDS_4(BIDS, biomax_table);
cd([BIDS.input.dir]);
% finally, rename the BIDS directory to a proper name
cmd_str = ['rm -r ', BIDS.output.dir,'../',BIDS.input.data_dir(1).FamilyName{3}, '_', BIDS.input.data_dir(1).GivenName{3},'_BIDS'];
system(cmd_str);
cmd_str = ['mv ', BIDS.output.dir,' ', BIDS.output.dir,'../',BIDS.input.data_dir(1).FamilyName{3}, '_', BIDS.input.data_dir(1).GivenName{3},'_BIDS'];
system(cmd_str);
fprintf('\n\ndone %s_%s\n', BIDS.input.data_dir(1).FamilyName{3}, BIDS.input.data_dir(1).GivenName{3});
clear all