Skip to content

Commit

Permalink
add flag initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Jones committed Apr 29, 2020
1 parent f202cef commit a6c786c
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions aa_engine/aas_processBIDS.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
regcolumn = 'trial_type';
end


BIDSsettings.directories.structDIR = 'anat';
BIDSsettings.directories.functionalDIR = 'func';
BIDSsettings.directories.fieldmapDIR = 'fmap';
Expand Down Expand Up @@ -86,6 +87,8 @@
end
end



%% Process
if BIDSsettings.combinemultiple
aas_log(aap,false,'WARNING: You have selected combining multiple BIDS sessions!');
Expand Down Expand Up @@ -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')));
Expand Down Expand Up @@ -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
Expand All @@ -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));
Expand All @@ -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});
Expand Down

0 comments on commit a6c786c

Please sign in to comment.