diff --git a/aa_engine/aas_processBIDS.m b/aa_engine/aas_processBIDS.m index ee47827fe..5ca979ee6 100644 --- a/aa_engine/aas_processBIDS.m +++ b/aa_engine/aas_processBIDS.m @@ -59,6 +59,7 @@ regcolumn = 'trial_type'; end + BIDSsettings.directories.structDIR = 'anat'; BIDSsettings.directories.functionalDIR = 'func'; BIDSsettings.directories.fieldmapDIR = 'fmap'; @@ -86,6 +87,8 @@ end end + + %% Process if BIDSsettings.combinemultiple aas_log(aap,false,'WARNING: You have selected combining multiple BIDS sessions!'); @@ -160,6 +163,39 @@ fieldmapDIR = BIDSsettings.directories.fieldmapDIR; diffusionDIR = BIDSsettings.directories.diffusionDIR; +% defaults for acq_details flags + +if (isfield(aap.acq_details,'omitBIDSmodeling') && aap.acq_details.omitBIDSmodeling == true) + omitBIDSmodeling = true; +else + omitBIDSmodeling = false; +end + +if (isfield(aap.acq_details,'stripBIDSEventNames') && aap.acq_details.stripBIDSEventNames == true) + stripBIDSEventNames = true; +else + stripBIDSEventNames = false; +end + +if (isfield(aap.acq_details,'omitNullBIDSEvents') && aap.acq_details.omitNullBIDSEvents == true) + omitNullBIDSEvents = true; +else + omitNullBIDSEvents = false; +end + +if (isfield(aap.acq_details,'convertBIDSEventsToUppercase') && aap.acq_details.convertBIDSEventsToUppercase == true) + convertBIDSEventsToUppercase = true; +else + convertBIDSEventsToUppercase = false; +end + +if (isfield(aap.acq_details,'maxBIDSEventNameLength') && aap.acq_details.maxBIDSEventNameLength > 0) + maxBIDSEventNameLength = aap.acq_details.maxBIDSEventNameLength; +else + maxBIDSEventNameLength = Inf; +end + + % locate first_level modules stagenumModel(1) = struct('name','aamod_firstlevel_model','ind',... find(strcmp({aap.tasklist.main.module.name},'aamod_firstlevel_model'))); @@ -314,10 +350,8 @@ % Model - if (isfield(aap.acq_details,'omitBIDSmodeling') && aap.acq_details.omitBIDSmodeling == true) - + if (omitBIDSmodeling) aas_log(aap,false,sprintf('INFO: Omitting addevent in aas_processBIDS (change in aap.acq_details.omitBIDSmodeling)')); - else for thisstage = stagenumModel @@ -342,7 +376,7 @@ iName = cell_index(EVENTS(1,:),regcolumn); iOns = cell_index(EVENTS(1,:),'onset'); iDur = cell_index(EVENTS(1,:),'duration'); - if (isfield(aap.acq_details,'stripBIDSEventNames') && aap.acq_details.stripBIDSEventNames == true) + if (stripBIDSEventNames) EVENTS(2:end,iName) = regexprep(EVENTS(2:end,iName),'[^a-zA-Z0-9]',''); end names = unique(EVENTS(2:end,iName)); @@ -353,21 +387,16 @@ onsets{iEV}(end+1) = str2double(EVENTS{t,iOns}); durations{iEV}(end+1) = str2double(EVENTS{t,iDur}); end - if (isfield(aap.acq_details,'omitNullBIDSEvents') && aap.acq_details.omitNullBIDSEvents == true) - omitNullEvents = true; - else - omitNullEvents = false; - end - if (isfield(aap.acq_details,'convertBIDSEventsToUppercase') && aap.acq_details.convertBIDSEventsToUppercase == true) + if (convertBIDSEventsToUppercase) names = upper(names); end - if (isfield(aap.acq_details,'maxBIDSEventNameLength') && aap.acq_details.maxBIDSEventNameLength > 0) - maxlen = aap.acq_details.maxBIDSEventNameLength; + if (maxBIDSEventNameLength < Inf) + maxlen = maxBIDSEventNameLength; names = cellfun(@(x) x(1:min(maxlen,length(x))), names,'UniformOutput',false); end for m = iModel for e = 1:numel(names) - if (strcmpi(names{e},'null') && omitNullEvents) + if (strcmpi(names{e},'null') && omitNullBIDSEvents) continue; end aap = aas_addevent(aap,sprintf('%s_%05d',thisstage.name,m),subjname,taskname,names{e},onsets{e}-numdummies*TR,durations{e});