Hi there:
Advance apologies for the multiple questions/long post - am wrestling with newly using matllabbatch on SPM12.
I'm trying to use the templating available on the batch to set up scripts for pre-processing. As an example, below I show just the slice-timing module. Key feature is that I am trying to iterate over many subjects (in resting state data) not iterate over multiple sessions for one subject. I am performing a module in one subject and then trying to set up a script for many subjects.
I note the batch editor outputs the following .m files as templates for just the slice timing step
The template file:
nrun = 1; % enter the number of runs here
jobfile = {'/Users/localuser/study_directory/subject_directory/blah/myfile_job.m'};
jobs = repmat(jobfile, 1, nrun);
inputs = cell(0, nrun);
for crun = 1:nrun
end
spm('defaults', 'FMRI');
spm_jobman('run', jobs, inputs{:});
The job file:
matlabbatch{1}.spm.temporal.st.scans = {
{
'/Users/localuser/study_directory/subject_directory/blah/rest_1/trest.nii,1'
....[**100+ timepoints in here with similar syntax**]
}
}';
%%
matlabbatch{1}.spm.temporal.st.nslices = XX;
matlabbatch{1}.spm.temporal.st.tr = X;
matlabbatch{1}.spm.temporal.st.ta = X.X;
matlabbatch{1}.spm.temporal.st.so = [1 2 ...X];
matlabbatch{1}.spm.temporal.st.refslice = XX;
matlabbatch{1}.spm.temporal.st.prefix = 'a';
---------------------
I would like to set up a script that looks perhaps something like this:
spm('defaults', 'FMRI');
spm_jobman('initcfg')
SUBJECTS = {'/000001/session_1/rest_1/trest.nii';
'000002/session_1/rest_1/trest.nii'};
for j = 1:length(SUBJECTS)
% something in here to expand to all the timepoints? like spm_select does
spm_select('expand',fullfile('trest.nii'))
% or use the batch?
matlabbatch{1}.cfg_basicio.file_dir.file_ops.file_fplist.dir = '<UNDEFINED>';
matlabbatch{1}.cfg_basicio.file_dir.file_ops.file_fplist.filter = '<UNDEFINED>';
matlabbatch{1}.cfg_basicio.file_dir.file_ops.file_fplist.rec = '<UNDEFINED>';
matlabbatch{2}.spm.util.exp_frames.files = '<UNDEFINED>';
matlabbatch{2}.spm.util.exp_frames.frames = '<UNDEFINED>';
%the job:
matlabbatch{1}.spm.temporal.st.nslices = XX;
matlabbatch{1}.spm.temporal.st.tr = X;
matlabbatch{1}.spm.temporal.st.ta = X.X;
matlabbatch{1}.spm.temporal.st.so = [1 2 ...X];
matlabbatch{1}.spm.temporal.st.refslice = XX;
matlabbatch{1}.spm.temporal.st.prefix = 'a';
end
spm_jobman('run', matlabbatch);
Here are my questions:
1. How do I best replace the array containing all the timepoints of the resting state in the individual subject file with a function call? Should I use spm_select or the batch modules for "file selector' and 'expand frames' utility? (or one of those?) I don't quite understand which spm functions underlie the batch basic IO and frame expansion utility and am not sure what is doing what and which ones I actually need here.
2. I assume the template that the batch outputs for iterating over many sessions isn't very useful here but is this incorrect?
3. Is the call spm_jobman('initcfg') necessary at the beginning of the script? I've seen this advised
4. Will the call spm_jobman('run', matlabbatch) suffice to iterate through all the modules like matlabbatch{1}.spm.temporal.st.nslices = 47; and so on, automagically?
5. What does inputs = cell(0, nrun); do? It appears to set up an empty cell array
I hope this is vaguely clear. Happy also to look at example scripts of similar use cases - I've tried googling but haven't been successful elsewhere or in the SPM archive.
Thanks *very* much
Nina
This message and any attached files might contain confidential information protected by federal and state law. The information is intended only for the use of the individual(s) or entities originally named as addressees. The improper disclosure of such information may be subject to civil or criminal penalties. If this message reached you in error, please contact the sender and destroy this message. Disclosing, copying, forwarding, or distributing the information by unauthorized individuals or entities is strictly prohibited by law.
|