introduction to spm batching guillaume flandin wellcome trust centre for neuroimaging university...

14
Introduction to SPM Batching Guillaume Flandin Wellcome Trust Centre for Neuroimaging University College London MATLAB for Cognitive Neuroscience ICN, May 2009 from acquisition to publication…

Upload: gavin-rich

Post on 24-Dec-2015

240 views

Category:

Documents


1 download

TRANSCRIPT

Introduction to SPM Batching

Guillaume Flandin

Wellcome Trust Centre for Neuroimaging

University College London

MATLAB for Cognitive Neuroscience

ICN, May 2009

from acquisition to publication…

NormalisationNormalisation

Statistical Parametric MapStatistical Parametric MapImage time-seriesImage time-series

Parameter estimatesParameter estimates

General Linear ModelGeneral Linear ModelRealignmentRealignment SmoothingSmoothing

Design matrix

AnatomicalAnatomicalreferencereference

Spatial filterSpatial filter

StatisticalStatisticalInferenceInference

RFTRFT

p <0.05p <0.05

Installing SPM using SVN

Install Subversion: http://subversion.tigris.org/ http://tortoisesvn.net/ on Windows

SPM repository

your SPM working copySPM

SPMSPMSPM

Repository URLs:SPM5: svn://bread.fil.ion.ucl.ac.uk/spm/branches/spm5SPM8: svn://bread.fil.ion.ucl.ac.uk/spm/trunkTBR: svn://bread.fil.ion.ucl.ac.uk/tools/TBR/trunkImport_Archive: svn://bread.fil.ion.ucl.ac.uk/tools/Import_Archive

Online instructions: http://www.fil.ion.ucl.ac.uk/spm/local/svn/ http://www.fil.ion.ucl.ac.uk/spm/local/tbr/

FIL & ICNonly

TortoiseSVN: Checkout

TortoiseSVN: Update

Case 1: your SPM files needed to be updated.

Case 2: your SPM files are up-to-date.

MATLAB pathAdd Folder (and not with Subfolders)

Remove older SPM versions from the path(or use spm_rmpath)

Batching SPM{2,5,8} SPM Extensions webpage:

http://www.fil.ion.ucl.ac.uk/spm/ext/#batch_utils

SPM99, SPM2

[1] http://en.wikibooks.org/wiki/SPM-Example_batch_script[2] http://imaging.mrc-cbu.cam.ac.uk/imaging/SpmBatch5

Call SPM functions directly [1,2]:

spm_realign spm_slice_timing spm_normalise spm_write_sn spm_smooth spm_fmri_spm_ui spm_spm spm_FcUtil spm_contrasts

Requires knowledge about input/output arguments of main SPM functions and about the SPM.mat structure.

SPM8

Batch Editor:

“matlabbatch” structure. Dependencies.

SPM5

Job Manager:

“jobs” structure. Virtual files.

SPM “jobs”

Goal: create a .mat file containing a Matlab structure ‘jobs’ similar to the one created using the GUI.

Tip: you only need to specify parameters that you would enter in the interface, the others will be automatically imported when executed. The jobs structure will mimic the interface.

Batch mode:

(“matlabbatch” for SPM8)

Useful SPM functions:

Select files: spm_select.m[files,dirs] = spm_select(‘FPList',dir,filt)ex.: f = spm_select(‘FPList',‘C:\data\exp’,‘^fM.*\.img$’);

Job manager: spm_jobman.mspm_jobman(‘initcfg’); % initialise SPM batch modespm_jobman(‘run’,jobs); % execute a jobspm_jobman(‘interactive’,jobs); % display a job in the GUI% jobs can be a Matlab variable or .mat/.m filename

Overall structure of a batch script:spm(‘defaults’,‘fmri’);spm_jobman(‘initcfg’); clear jobs

% fill in jobs structure

save(‘My_Batch.mat’,‘jobs’);spm_jobman(‘run’,jobs);

See also: fullfile cellstr editfilenames*

Data organisation

Should be as generic as possible to ease batch script writing.

Experiment

subject1

scripts

rfxmodel

subject2

structural

functional

session1

session2

jobs

stats

model1

model2

condition1

condition2

A potention pipeline for preprocessing with SPM:

Realign SegmentCoregister

Smooth

Normalize:Write

Raw

func

tiona

lim

ages

Update *.hdrmean.{img,hdr}

rp_*.txt

m*/c1*/c2*.{img,hdr}*_seg_sn.mat

*_seg_inv_sn.mat

Update *.hdr

wm*. {img,hdr}

sw*.{img,hdr}

Anatomicalimage

… Normalize:Write

w*.{img,hdr}

Group mean

Workflow for SPM8 Batch EditorSubject directory Functional data Structural data Experimental design

Coregistration

Normalisation Normalisation

Model Specification

Model Estimation

Segmentation

Smoothing

Make directory

Change directory

Realignment

1. Subject-independent data/analysis steps2. Data flow (dependencies)

3. Subject-specific data

Subject directory Functional data Structural data Experimental design

For more information…

SPM5/8 script examples:http://www.fil.ion.ucl.ac.uk/spm/data/

SPM8 manual chapter 34:http://www.fil.ion.ucl.ac.uk/spm/doc/spm8_manual.pdf

L. Kasper’s slides for SPM8:http://www.fil.ion.ucl.ac.uk/spm/course/slides09-zurich/