> Dear all,
> where do I find the spm_batch.m file as described on the web page?
> thanks
> Boris
Dear Kathryn and Boris,
spm_batch.m is a analysis-specific script that calls SPM2b routines
to implement an analysis of fMRI data. At the moment it deals with
analyses following spatial preprocessing. For each analysis you
would create a spm_batch.m (usually stored in the results directory)
and run it by typing
>> spm_batch.m
in that directory. The SPM2b routines are called successively and 'fill
in' various subfields of an SPM structure until the analysis is complete.
The example below analyses a single-session block-design experiment with
3 effects ('visual', ,motion, and 'set'). This deisgn is specified so that
these causes of evoked responses coincide for some trials. The 'set' response
is augmented with a time-dependent component, modelled with a second order
polynomial expansion.
I hope this helps - Karl
% Template batch script for SPM2
%
% The revisions for SPM2 ensure that modularity has been preserved while
% trying to make the code as simple and readable as possible. A key
% change, in terms of the architecture, is the consolidation of the .mat
% files that contain the analysis variables and parameters. These files
% have been consolidated in such a way that to use SPM in batch mode
% should be much easier. We have done this as a prelude to planned work
% using mark-up languages (XML) to facilitate the review, specification
% and implementation of SPM procedures.
% In brief, SPM2 sets up a single structure (SPM) at the beginning of
% each analysis and, as the analysis proceeds, fills in sub-fields in a
% hierarchical fashion. This enables one to fill in early fields
% automatically and bypass the user interface prompting. After the
% design specification fields have been filled in the design matrix is
% computed and placed in a design matrix structure. This, along with a
% data structure and non-sphericity structure is used by SPM to compute
% the parameters and hyperparameters. These are saved (as handles to the
% parameter and hyperparameter images) as sub-fields of SPM.
% A contrast sub-structure is generated automatically and can be
% augmented at any stage. This structure array can be filled in
% automatically after estimation using spm_contrasts.m. The hierarchical
% organisation of the sub-function calls and the SPM structure means
% that, after a few specification fields are set in the SPM structure, an
% entire analysis, complete with contrasts can be implemented
% automatically. An example of a text file that fills in the initial
% fields of SPM and then calls the required functions can be found below
%
%___________________________________________________________________________
% %W% Karl Friston %E%
% Specify design
%===========================================================================
% number of scans and session, e.g. [128 128 128] for 3 sessions
%---------------------------------------------------------------------------
SPM.nscan = 360;
% basis functions and timing parameters
%---------------------------------------------------------------------------
% OPTIONS:'hrf'
% 'hrf (with time derivative)'
% 'hrf (with time and dispersion derivatives)'
% 'Fourier set'
% 'Fourier set (Hanning)'
% 'Gamma functions'
% 'Finite Impulse Response'
%---------------------------------------------------------------------------
SPM.xBF.name = 'hrf (with time derivative)';
SPM.xBF.length = 32.2; % length in seconds
SPM.xBF.order = 2; % order of basis set
SPM.xBF.T = 16; % number of time bins per scan
SPM.xBF.T0 = 1; % first time bin (see slice timing)
SPM.xBF.UNITS = 'scans'; % OPTIONS: 'scans'|'secs' for onsets
SPM.xBF.Volterra = 1; % OPTIONS: 1|2 = order of convolution
% Trial specification: Onsets, duration (UNITS) and parameters for modulation
%---------------------------------------------------------------------------
SPM.Sess(1).U(1).name = {'visual'};
SPM.Sess(1).U(1).ons = [10 30 50 70 80 100 120 140 160 170 190 210,...
230 250 260 280 300 320 340 350]';
SPM.Sess(1).U(1).dur = 10;
SPM.Sess(1).U(1).P(1).name = 'none';
SPM.Sess(1).U(2).name = {'motion'};
SPM.Sess(1).U(2).ons = [10 30 50 70 100 120 140 160 190 210 230 250,...
280 300 320 340]';
SPM.Sess(1).U(2).dur = 10;
SPM.Sess(1).U(2).P(1).name = 'none';
SPM.Sess(1).U(3).name = {'set'};
SPM.Sess(1).U(3).ons = [10 50 100 140 210 250 300 340]';
SPM.Sess(1).U(3).dur = 10;
SPM.Sess(1).U(3).P(1).name = 'time';
SPM.Sess(1).U(3).P(1).P = SPM.Sess(1).U(3).ons;
SPM.Sess(1).U(3).P(1).h = 2; % order of polynomial expansion
% design (user specified covariates)
%---------------------------------------------------------------------------
SPM.Sess(1).C.C = [1:360]'; % [n x c double] covariates
SPM.Sess(1).C.name = {'Regressor 1'}; % [1 x c cell] names
% global normalization: OPTINS:'Scaling'|'None'
%---------------------------------------------------------------------------
SPM.xGX.iGXcalc = 'Scaling';
% low frequency confound: high-pass cutoff (secs) [Inf = no filtering]
%---------------------------------------------------------------------------
SPM.xX.K.HParam = 128;
% intrinsic autocorrelations: OPTIONS: 'none'|'AR(1) + w'
%-----------------------------------------------------------------------
SPM.xVi.form = 'AR(1) + w';
% specify data: matrix of filenames and TR
%===========================================================================
Directory = '/home/karl/SPM/attention/Karen';
Filter = 'sn*.img';
SPM.xY.P = spm_get('files',Directory,Filter);
SPM.xY.RT = 3.22; % seconds
% Configure design matrix
%===========================================================================
SPM = spm_fmri_spm_ui(SPM);
% Estimate parameters
%===========================================================================
SPM = spm_spm(SPM);
% Add extra contrasts
%===========================================================================
% F-contrasts
%---------------------------------------------------------------------------
iX0 = [3:12];
cname = 'Visual';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'F','iX0',iX0,SPM.xX.xKXs);
% T-contrasts
%---------------------------------------------------------------------------
c = [1 0 0 0 0 0 0 0 0 0 0 0];
cname = 'Visual';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
c = [0 0 1 0 0 0 0 0 0 0 0 0];
cname = 'Motion';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
c = [0 0 0 0 1 0 0 0 0 0 0 0];
cname = 'Set';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
% and evaluate
%---------------------------------------------------------------------------
spm_contrasts(SPM);
|