Skip to content
Permalink
master
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
function BIDS = OPTIMA_make_BIDS_2(input_dir)
%
% Prepare datasets for BIDS format, version 2, created 1.7.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_2('/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 1.7.2019
% last modified 12.9.2019 M. Czisch to include SIT1
% 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(BIDS);
% check and prepare temporary BIDS directory structure
pathInfo = what(BIDS.input.dir);
current_dir = pathInfo.path;
BIDS.output.dir = [current_dir,'/BIDS/'];
OPTIMA_check_BIDS(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(BIDS);
% do the conversion to BIDS format
OPTIMA_convert_GE_BIDS_2(BIDS, biomax_table);
% make a json file with dataset description
OPTIMA_dataset_description_BIDS(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_2(BIDS,biomax_table);
% do the conversion of EDF files to BIDS naming format
OPTIMA_convert_EDF_BIDS_2(BIDS,biomax_table);
% do the conversion of PPG and RESP files to BIDS
OPTIMA_convert_PPG_BIDS_2(BIDS, biomax_table);
% do tsv conversion of logfiles
%Hariri_logfile_bids(BIDS,biomax_table);
%NBack_logfile_bids(BIDS,biomax_table);
%TET_logfile_bids(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).PatientID{3},'_BIDS'];
system(cmd_str);
cmd_str = ['mv ', BIDS.output.dir,' ', BIDS.output.dir,'../',BIDS.input.data_dir(1).PatientID{3},'_BIDS'];
system(cmd_str);
fprintf('\n\ndone %s\n', BIDS.input.data_dir(1).PatientID{3});
clear all