SPM batching without scripting... Can it be done? Paul Groot, fMRI instuif ...
contain any matlab script, but contains a hierarchical collection ... SPM5 batch
script ...
SPM batching without scripting... Can it be done?
Paul Groot, fMRI instuif 2010-03-26
Today's programme • Matlab data types: matrices, cell arrays, ... • SPM 5: jobs structures • SPM 8: new batching system
Data types array [ ]
char
number
cell { }
int (8, 16, 32, 64) uint (8, 16, 32, 64) single, double
struct
class
...
...
matrices [ ] M = [ 2, 5, 7; 3, 6, 8]
2 5 7 M= 3 6 8
N = zeros(3,2)
0 0 N= 0 0 0 0
Q = eye(3)
Q=
Q(3,2) = 4
M' =
2 3 5 6 7 8
1 0 0 0 1 0 0 0 1
1 0 0 Q= 0 1 0 0 4 1
Q – 2*Q' =
-1 0 0 0 -1 -8 0 4 -1
text strings s1 = 'apple'
apple
s2 = 'banana'
banana
s3 = [ s1 s2 ]
applebanana
s3 = [ s1; s2 ]
dimensions not consistent
s3 = strvcat(s1 s2)
1x5
appl e banana
1x6
2x6
1 x 11
Cell arrays { } C = cell(2,3); C{1,1} = 'PI'; C{1,2} = 3.14; C{2,3} = [ 1, 2; 3, 4 ]; C=
a cell can contain any data type
' PI'
3.14
[]
[]
[] 1
2
3
4
Structure arrays P.name = 'John'; P.age = 21;
P=
name = 'John' age = 21
P(2,1).name = 'Jane'; P(2,1).age = 27; P(1,2).name = 'Piet'; P(1,2).age = 33;
a contains 'named' values
P=
name = 'John' age = 21
name = 'Piet' age = 33
name = 'Jane' age = 27
name = [ ] age = [ ]
Classes A class object is like a structure (i.e. can have 'named' values), but has functions attached that use or change the values of the class object: P.name = 'John'; P.age = 21; P.isAdult()
(true if P.age>=21)
SPM5 jobs
SPM5 jobs structures -jobs struct -spatial struct (Coreg) -coreg struct -estimate struct -ref -source -other -eoptions struct -cost_func -sep [1x2] -tol [1x12] -fwhm [1x2] -spatial struct (Segmentation) -preproc ...
jobfile (*.mat) does not contain any matlab script, but contains a hierarchical collection of parameters. At the top there is only a single node, called ‘jobs’. SPM heavily depends on the use of structures and cell arrays. Customized batching: change values in the tree structure.
SPM5 job batching Use an existing job and modify relevant parameters: % LOAD JOB load 'mybatch.mat'
% this will load the jobs structure from mat-file
% DEFINE FILES f{1} = 'C:\data\sub1\fM0001.img‘; ... % REALIGN jobs{1}.spatial{1}.realign{1}.estwrite.data{1} = cellstr(f); % COREGISTER jobs{1}.spatial{2}.coreg{1}.estimate.ref = editfilenames(f(1,:),'prefix','mean'); jobs{1}.spatial{2}.coreg{1}.estimate.source = cellstr(a); % SEGMENT jobs{1}.spatial{3}.preproc.data = cellstr(a); ... spm_jobman('run',job); % and run the job as usual
SPM5 batch script
SPM8... new batch system: http://sourceforge.net/projects/matlabbatch/
include all required 1 modules
specify session independent parameters
2
specify dependencies (output -> input)
3
After specifying session independent parameters and output->input dependencies, session specific parameters are still UNDEFINED (