I'm aware of the ambivalence of cogsci.stacexchange with regards to asking questions about code, but this question really is about SPM, specifically, so I think that the domain-specific nature of my inquiry makes it suitable for this forum. I do apologize if this is in poor form.
I'm trying to run a custom batch script on some fMRI data. The relevant code is presented below:
cfg = config(); % a struct that holds a few parameters, namely paths and regexps
for isub = 1:length(cfg.subdir)
subdir = cfg.subdir(isub);
rundirs = fullfile(subdir, regexpdir(subdir, cfg.regex.rundir));
matlabbatch{isub}.spm.spatial.realign.estwrite.data = regexpdir(fullfile(subdir), cfg.regex.funcscan);
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.quality = 1.0;
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.sep = 4;
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.fwhm = 5;
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.rtm = 2;
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.interp = 2;
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.wrap = [0 0 0];
matlabbatch{isub}.spm.spatial.realign.estwrite.eoptions.weight = '';
matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.which = [0 1]; % [0 1] = create mean images only; [1 1] crt all imgs + mean
matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.interp = 4; % 4th degree bspline interp
matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.wrap = [0 0 0];
matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.mask = 1;
matlabbatch{isub}.spm.spatial.realign.estwrite.roptions.prefix = 'r';
end
This loop, which performs slice realignment for all subjects, is called via spm_jobman('serial', 'myscript.m')
where myscript.m
is the script shown above.
regexpdir
is available on the matlab file exchange for those who wish to examine it, but it returns an Nx1 cell array of strings, which correspond to paths matched by the regex parameter.
Running this code doesn't seem to produce any errors, per se, but rather prints the following several thousand times:
Item 'Session', field 'val': Value must be either empty, a cellstr or a cfg_dep object.
The variable name cfg_dep
makes me think of SPM's "dependency" construct, often used in the visual batch tool. The code above is taken from said visual batch tool's code exportation feature, so it's possible that I'm referencing a dependency that somehow got omitted when I refactored the exported code... but damned if I can find where...
Any thoughts or advice would be greatly appreciated!