Docstoc

Batching SPM

Document Sample
Batching SPM Powered By Docstoc
					Introduction to SPM Batching

      from acquisition to publication…


                 Guillaume Flandin
       Wellcome Trust Centre for Neuroimaging
             University College London


        MATLAB for Cognitive Neuroscience
                 ICN, May 2009
Image time-series
                    Spatial filter      Design matrix       Statistical Parametric Map




Realignment         Smoothing        General Linear Model


                                                            Statistical        RFT
        Normalisation                                       Inference




                        Anatomical                                         p <0.05
                        reference Parameter estimates
Installing SPM using SVN                                                 FIL & ICN
                                                                            only
        your SPM
 SPM   working copy
                          Install Subversion:
                               http://subversion.tigris.org/
                               http://tortoisesvn.net/ on Windows



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


                      Repository URLs:
         SPM          SPM5: svn://bread.fil.ion.ucl.ac.uk/spm/branches/spm5
  SPM
   SPM repository
    SPM               SPM8: svn://bread.fil.ion.ucl.ac.uk/spm/trunk
                      TBR: svn://bread.fil.ion.ucl.ac.uk/tools/TBR/trunk
                      Import_Archive: svn://bread.fil.ion.ucl.ac.uk/tools/Import_Archive
TortoiseSVN: Checkout
TortoiseSVN: Update




                      Case 1: your SPM files needed to be updated.




                      Case 2: your SPM files are up-to-date.
MATLAB path
                                 Add 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                              SPM5                   SPM8

     Call SPM functions                Job Manager:         Batch Editor:
    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             “jobs” structure.    “matlabbatch” structure.
    SPM.mat structure.                  Virtual files.       Dependencies.
[1] http://en.wikibooks.org/wiki/SPM-Example_batch_script
[2] http://imaging.mrc-cbu.cam.ac.uk/imaging/SpmBatch5
 SPM “jobs”
(“matlabbatch” for SPM8)


      Batch mode:


 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.
 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.m
  spm_jobman(‘initcfg’);           %     initialise SPM batch mode
  spm_jobman(‘run’,jobs);          %     execute a job
  spm_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                         See also:
                                                    fullfile
  save(‘My_Batch.mat’,‘jobs’);                      cellstr
  spm_jobman(‘run’,jobs);                           editfilenames*
Experiment
             subject1
                        structural
                        functional

                                     session1
                                     session2
                                       …
                                                Data organisation
                          jobs
                          stats                  Should be as generic as
                                     model1       possible to ease batch
                                     model2
                                                  script writing.
                                       …
             subject2
               …
             scripts
             rfxmodel
                        condition1
                        condition2
                           …
  A potention pipeline for preprocessing with SPM:
                                          Anatomical
                                            image
Raw functional
   images




                       Realign           Coregister           Segment

                      Update *.hdr       Update *.hdr     m*/c1*/c2*.{img,hdr}
                     mean.{img,hdr}                          *_seg_sn.mat
                        rp_*.txt                           *_seg_inv_sn.mat

                            Group mean    Normalize:
                                            Write

                                         wm*. {img,hdr}


                 …                        Normalize:
                         Smooth
                                            Write

                      sw*.{img,hdr}        w*.{img,hdr}
Workflow for SPM8 Batch Editor
 Subject directory     Functional data     Structural data     Experimental design

 Change directory

                        Realignment


                                           Coregistration


                                           Segmentation


                       Normalisation       Normalisation


                         Smoothing
  Make directory


                     Model Specification        1. Subject-independent data/analysis steps
                                                2. Data flow (dependencies)
                      Model Estimation          3. Subject-specific data
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/

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:96
posted:11/19/2011
language:English
pages:14