canlab / CanlabCore

Core tools required for running Canlab Matlab toolboxes. The heart of this toolbox is object-oriented tools that enable interactive analysis of neuroimaging data and simple scripts using high-level commands tailored to neuroimaging analysis.
https://canlab.github.io/CanlabCore/
Other
146 stars 80 forks source link

canlab_glm_subject_levels not assigning noise_regs to correct runs if runs are missing #39

Closed lukasvo76 closed 3 years ago

lukasvo76 commented 3 years ago

If DSGN.allowmissingfunc = true, and you have missing functional files for runs that are not the last runs of your subject, noise_regs.mat files (containing the spm-style R matrix) are not assigned to the correct runs. When a folder for a run is empty, this is handled correctly for onsets and durations files, but not for the noise_reg files. For the latter, the code looks for a noise_regs.mat file in the folder for the empty run, does not find one, causing the mutliple regressors field in the spm batch file to be empty, and then picking the wrong noise_regs.mat file for the following run (the file for run n-1 is assigned to run n). The problem seems to be located in canlab_glm_subject_levels_run1subject.m, which is a child process of canlab_glm_subject_levels.m - I may need some help to fix it but should definitely be feasible @bogpetre @torwager

lukasvo76 commented 3 years ago

Adding the following on line 394-7 of _canlab_glm_subject_levelsrun1subject.m solves the problem! I have tested this solution on my 60 subjects, and @bogpetre will do so on paingen, after which we will commit and push.

for m=1:size(multipleregressors,2)
    idx(m)=isempty(multipleregressors{m});
end
    multipleregressors(idx)=[];
lukasvo76 commented 3 years ago

I ended up fixing the issue differently, changes have been committed and pushed a few months ago!