The system divides up into a parameter setup file
and metabatch
scripts.
All the parameters in your analysis are specified in the parameter setup file. There is an example in the archive, called choice_top_groove.m
.
The file takes an optional subject specifier, which can be a string
giving the subject subdirectory, or a subject number, or a cell array
of subject subdirectories, or a vector of subject numbers. It then
creates and returns two matlab structures, a global parameter structure
and a subject parameter structure
, like this:
[global_params subject_params] = my_param_setup('subject_1_subdir');
The global parameters are parameters which are the same for every subject - such as the root directory for all the subjects' data files, settings for realignment, statistics etc.
The global parameter text file shows the fields and contents of the global parameter structure after running the example parameter setup file on the machine it was written on.
See the comments in the example file for the meaning of each field.
The subject parameter structure is an array of subject structures, with one element per subject. These contain information that may be specific for a specific subject, such as the subject data subdirectory, onsets for conditions in the statistical model, etc.
The subject parameter text file shows the fields and contents for the subject parameter structure, from the example script, for one subject.
Again, see the example file for comments describing what each field means.
These are files that will probably not change very much from one
analysis to the next - at least that is the intention. The files take
the global and subject parameter structures as input, and run a stage
of batch processing using those inputs. For example, here is the groovy_smooth.m
metabatch file:
function groovy_smooth(glob_ps, sub_ps) % spm2 smooth script imgs = ''; for sb = 1:length(sub_ps) my_sub = sub_ps(sb); subjroot = fullfile(glob_ps.fdata_root, my_sub.dir); sm_filter = [glob_ps.smooth_prefix my_sub.raw_filter]; for ss = 1:length(my_sub.sesses) dirn = fullfile(subjroot,my_sub.sesses(ss).dir); % get files in this directory imgs = strvcat(imgs, spm_get('files', dirn, sm_filter)); end end % and this is just spm_smooth_ui pasted/edited s = glob_ps.FWHM; P = imgs; n = size(P,1); % implement the convolution %--------------------------------------------------------------------------- for i = 1:n Q = deblank(P(i,:)); [pth,nm,xt,vr] = fileparts(deblank(Q)); U = fullfile(pth,['s' nm xt vr]); spm_smooth(Q,U,s); end
should then be relatively simple. You make your own parameter setup file specifying all the parameters of the analysis. Then you can run an analysis for a particular subject with:
my_subject_dir = 'subject_1'; [global_parameters subject_parameters] = my_param_setup(my_subject_dir); groovy_reorient(global_parameters, subject_parameters); groovy_realign(global_parameters, subject_parameters); groovy_coreg(global_parameters, subject_parameters); groovy_norm_calc(global_parameters, subject_parameters); groovy_norm_write(global_parameters, subject_parameters); groovy_smooth(global_parameters, subject_parameters); groovy_subject_model(global_parameters, subject_parameters); groovy_contrasts(global_parameters, subject_parameters);
Are, at least (please add when you find more):
are very many, as the point of the batch system is to be able to run an analysis without specifying absolutely everything - on the basis you will not want to use some of the many options that SPM allows. If any of the metabatch scripts don't allow the option you want, you could either:
The first is preferable, because then you can more easily share it with the rest of us!
This batch system is designed to make it easy to split up your jobs by subject. This makes it easy to get going with the batching described on the HowtoParallel page. For example, here is a single subject test script (as described in HowtoParallel):
% Test batch file for later transfer to the Beno parameter_root = '/import/hoover/imagers/choice'; fdata_root = '/home/imagers/choice'; subject_sdir = '05AM'; batch_sdir = 'groove_1'; ana_sdir = 'spm2_groove1'; addpath(fullfile(parameter_root, batch_sdir)); choice_one_subject;
where choice_one_subject
looks like this:
%% Single subject batch script % % Assumes the following parameters (here with example contents) % parameter_root = '/some/directory/on/my/machine'; % node_root = '/another/directory/on/my/machine'; % subject_sdir = 'subject_1'; % batch_sdir = 'my_batch_dir'; % ana_sdir = 'my_ana_sdir'; addpath /usr/local/spm/groovy_batch % Get the global and subject parameters glob_ps.parameter_root = parameter_root; glob_ps.fdata_root = fdata_root; [glob_ps sub_ps] = choice_top_groove(subject_sdir, glob_ps); glob_ps.ana_sdir = ana_sdir; groovy_reorient(glob_ps, sub_ps); groovy_realign(glob_ps, sub_ps); groovy_coreg(glob_ps, sub_ps); groovy_norm_calc(glob_ps, sub_ps); groovy_norm_write(glob_ps, sub_ps); groovy_smooth(glob_ps, sub_ps); groovy_subject_model(glob_ps, sub_ps); groovy_contrasts(glob_ps, sub_ps);
The groovy_batch files should be in /usr/local/spm/too_groovy
.
The groovy_subject_model metabatch file relies on a function called movement_regressors.m, which should also be on your matlab path, at /usr/local/spm/common
.
Last Refreshed: Fri Dec 30 13:10:29 CET 2005