Skip to content

Commit

Permalink
Merge pull request automaticanalysis#400 from jones-michael-s/fall_20…
Browse files Browse the repository at this point in the history
…24_bugfixes

Fall 2024 bugfixes
  • Loading branch information
jones-michael-s authored Nov 8, 2024
2 parents 882d9ac + fb5ac43 commit 0c902d9
Show file tree
Hide file tree
Showing 8 changed files with 363 additions and 21 deletions.
7 changes: 7 additions & 0 deletions aa_engine/aas_processBIDS.m
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,21 @@

function LIST = tsvread(fname)
filestr = fileread(fname);
% this is counting lines based on the number of newlines (char(10))
% this is error-prone because some files may have a terminal newline
% and some may not. We can improve this by stripping any trailing
% whitespace then adding one...
nLines = sum(double(filestr)==10);
filestr = strtrim(filestr);
nLines = sum(double(filestr)==10)+1;
LIST = textscan(filestr,'%s','Delimiter','\t');
LIST = LIST{1};
% protect against extraneous whitespace in the tsv:
LIST = LIST(~cellfun(@isempty,LIST));
LIST = reshape(LIST,[],nLines)';
end


function str = strrep_multi(str, old, new)
for i = 1:numel(old)
str = strrep(str, old{i}, new{i});
Expand Down
16 changes: 13 additions & 3 deletions aa_modules/aamod_firstlevel_model.m
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
SPMdes.xX.W = sparse(eye(size(SPMdes.xY.P,1)));
SPMdes.xVi.V = sparse(eye(size(SPMdes.xY.P,1)));
end

%%%%%%%%%%%%%%%%%%%
%% ESTIMATE MODEL%%
%%%%%%%%%%%%%%%%%%%
Expand All @@ -190,7 +190,17 @@
spm_unlink(fullfile(SPMdes.swd, prevmask(ind,:)));
end
end


% add explicit mask if one is specified
% (SPM will intersect this with any implicit masking...)

if aas_stream_has_contents(aap, subj,'explicitmask')
% this will look for mask at subject level, then
% try study level is a subject level mask not found
explicitmaskfname = aas_getfiles_bystream_multilevel(aap, 'subject', subj, 'explicitmask');
SPMdes.xM.VM = spm_vol(explicitmaskfname);
end

if (strcmp(aap.tasklist.currenttask.settings.autocorrelation,'wls'))
SPMest = spm_rwls_spm(SPMdes);
else
Expand Down Expand Up @@ -398,4 +408,4 @@
otherwise
aas_log(aap,1,sprintf('Unknown task %s',task));

end
end
17 changes: 13 additions & 4 deletions aa_modules/aamod_firstlevel_model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@
1 - implicit
otherwise (0-1) - fraction threshold
-->

<firstlevelmasking>1</firstlevelmasking>


<!-- note you can also provide an explicit mask using the explicitmask -->
<!-- input stream (SPM will take the intersection w/ firstlevelmasking) -->
<!-- the explicit mask can be subject-level (one for each subject) -->
<!-- or study level (one mask applied to all subjects); specify -->
<!-- the explicit mask using aas_addinitialstream -->

<!-- 'None' or 'AR(1)' or 'wls' (must have rWLS toolbox installed) -->
<autocorrelation>AR(1)</autocorrelation>

Expand Down Expand Up @@ -91,13 +98,15 @@

<inputstreams>
<stream isrenameable='1' ismodified='0'>epi</stream>
<stream isessential='0'>ppi</stream>
<stream isessential='0'>ppi</stream>
<stream isessential='0'>listspikes</stream>
<stream isessential='0'>epi_dicom_header</stream>
<stream isessential='0'>sliceorder</stream>
<stream isessential='0'>realignment_parameter</stream>
<stream isessential='0'>compSignal</stream>
<stream isessential='0'>gd_results</stream>
<stream isessential='0'>compSignal</stream>
<stream isessential='0'>gd_results</stream>
<stream isessential='0'>physreg</stream>
<stream isessential='0'>explicitmask</stream>
</inputstreams>

<outputstreams>
Expand Down
8 changes: 5 additions & 3 deletions aa_modules/aamod_firstlevel_model_dot.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
otherwise (0-1) - fraction threshold
-->
<firstlevelmasking>1</firstlevelmasking>

<!-- 'None' or 'AR(1)' or 'wls' (must have rWLS toolbox installed) -->
<autocorrelation>AR(1)</autocorrelation>

Expand All @@ -54,7 +54,7 @@
-->
<writeresiduals></writeresiduals>

<allowemptymodel>0</allowemptymodel>
<allowemptymodel>0</allowemptymodel>

<!-- TR, if we wish to define it within the first level model
If empty, we try to find from DICOM headers... -->
Expand Down Expand Up @@ -97,12 +97,14 @@

<inputstreams>
<stream >dot</stream>
<stream isessential='0'>ppi</stream>
<stream isessential='0'>ppi</stream>
<stream isessential='0'>listspikes</stream>
<stream isessential='0'>dot_header</stream>
<stream isessential='0'>realignment_parameter</stream>
<stream isessential='0'>compSignal</stream>
<stream isessential='0'>gd_results</stream>
<stream isessential='0'>physreg</stream>
<stream isessential='0'>explicitmask</stream>
</inputstreams>

<!-- dot outstream used for residuals and will be removed -->
Expand Down
Loading

0 comments on commit 0c902d9

Please sign in to comment.