zurich spm course 2011 batch programming of fmri data analysis

ZURICH SPM COURSE 2011
lars.kasper@econ.uzh.ch
kasper@biomed.ee.ethz.ch
Batch Programming of fMRI Data Analysis
Lars Kasper & Christoph Mathys
Institute for Biomedical Engineering (ETH Zurich)
& Computational Neuroeconomics Group (Univ. of Zurich)
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Overview
 Introduction & Example Dataset
 General fMRI Data Analysis Workflow with SPM




Quality Assessment of Raw Data
Spatial Preprocessing
Statistical Design: The General Linear Model
Results: Analyzing Contrast & Reporting
 Within-Subject Batching (Single Subject)



Subject-independent Analysis Steps
Subject-independent Data Flow (Dependencies)
Subject-related data
 Between-Subject-Batching (Multiple Subject)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
2
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Overview
 Introduction & Example Dataset
 General fMRI Data Analysis Workflow with SPM




Quality Assessment of Raw Data
Spatial Preprocessing
Statistical Design: The General Linear Model
Results: Analyzing Contrast & Reporting
 Within-Subject Batching (Single Subject)



Subject-independent Analysis Steps
Subject-independent Data Flow (Dependencies)
Subject-related data
 Between-Subject-Batching (Multiple Subject)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
3
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
Image time-series
Realignment
Kernel
Overview of SPM
Smoothing
Design matrix
ZURICH SPM COURSE 2011
Statistical parametric map
(SPM)
General linear model
Statistical
inference
Normalisation
Gaussian
field theory
p <0.05
Template
Parameter estimates
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
4
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
What is batch processing?
 Repeats same data analysis for many subjects (>=2)
 Not prone to human errors, reproducible what was done
 e. g. jobs mat-files
 Runs automatically, no supervision needed
 Researcher can concentrate on assessing the results
 CAVEAT: Tempting to forget about all analysis steps in
between which could lead to errors in your conclusions
 Therefore: Always make sure, that meaningful results were
created at each step
 Using Display/CheckReg to view raw data, preprocessed data
 Using spm_print to save reported supplementary data output
 If anything went wrong, use debugging
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
5
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
3 flavors of batching – Goals of this tutorial
After finishing this session, you will be able to
analyze fMRI datasets using
1. the Graphical User Interface (GUI) of SPM:
2. The Batch Editor of SPM
3. A template Matlab .m-script file to batch very flexibly
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
6
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Introducing the Dataset
 Rik Henson‘s famous vs non-famous faces dataset
http://www.fil.ion.ucl.ac.uk/spm/data/face_rep/face_rep_SPM5.html
 Includes a manual with step-by-step instruction for analysis
(homework ;-))
 Download from SPM homepage (available for SPM5, but works fine
with SPM8)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
7
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Introducing the Dataset
 Factorial 2 x 2 design to investigate repetition suppression
 Question: Influence of repeated stimulus presentation on brain
activity (accomodation of response)?
 Each stimulus (pictures of faces) presented twice during a session
 Condition Rep, Level: 1 or 2
 lag between presentations randomized
 26 Famous and 26 non-famous faces to differentiate between
familiarity (long-term memory) and repetition
 Condition Fam, Level F(amous) and N(onfamous)
 Task: Decision whether famous or nonfamous (button-press)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
8
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Introducing the Dataset: Published Results
a. Right Fusiform face area
 Repetition suppression for familiar/famous faces
b. Left Occipital face area (posterior, occip. extrastriate)
 Repetition suppression for familiar AND unfamiliar faces
c. Posterior cingulate and bilateral parietal cortex
 Repetition enhancement
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
9
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Overview
 Introduction & Example Dataset
 General fMRI Data Analysis Workflow with SPM




Quality Assessment of Raw Data
Spatial Preprocessing
Statistical Design: The General Linear Model
Results: Analyzing Contrast & Reporting
 Within-Subject Batching (Single Subject)



Subject-independent Analysis Steps
Subject-independent Data Flow (Dependencies)
Subject-related data
 Between-Subject-Batching (Multiple Subject)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
10
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Spatial Preprocessing – Realign
GUI
 sd
Kasper/Mathys (18-Feb-11)
Batch Editor
Batch File
FORMAT P =
spm_realign
(P,flags)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
11
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Spatial Preprocessing – Unwarp
GUI
Batch Editor
Batch File
uw_params=
spm_uw_estimate
(P,uw_est_flags);
spm_uw_apply
(uw_params,uw_write_
flags);
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
12
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Uh…this takes ages…
 Now you can probably value the benefits of batch
processing. If you are still keen on doing all that by hand
(good exercise!), refer to the following
 The SPM manual
 Most current version in your spm8-folder, sub-folder man/manual.pdf
 Rik Henson‘s famous vs non-famous faces dataset
http://www.fil.ion.ucl.ac.uk/spm/data/face_rep/face_rep_SPM5.html
 Included in SPM manual, chapter 29, with step-by-step instruction for
analysis
 Available for SPM5, but works fine with SPM8
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
13
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Overview
 Introduction & Example Dataset
 General fMRI Data Analysis Workflow with SPM




Quality Assessment of Raw Data
Spatial Preprocessing
Statistical Design: The General Linear Model
Results: Analyzing Contrast & Reporting
 Within-Subject Batching (Single Subject)



Subject-independent Analysis Steps
Subject-independent Data Flow (Dependencies)
Subject-related data
 Between-Subject-Batching (Multiple Subject)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
14
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
General Workflow for the batch interface
Top-down approach
Specify subject-independent
data/analysis steps
Specify subject-independent
file-dependencies (data flow)
Specify subject-related data
(e.g. event-timing)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
15
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
1. The subject-independent analysis parts
 Load all modules first
(in right order!)
 Then specify details
(where Xs are found)
which are subject
independent




Kasper/Mathys (18-Feb-11)
TR
Nslices
model factors
contrasts of interest
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
16
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
2. Data-flow specification (subject-independent
dependencies)
 Specify, which results of which steps are input
to another step (DEP-sign)
 e.g. smoothed images needed for model spec
 Afterwards save this job as template .mat file
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
17
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
3. Add subject-dependent data/information
 Essentially go to all X‘s and fill in appropriate
values
 e.g. the .mat-file of the conditions onsets/durations
 Save this job as subject-batch file & Run
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
18
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Overview
 Introduction & Example Dataset
 General fMRI Data Analysis Workflow with SPM




Quality Assessment of Raw Data
Spatial Preprocessing
Statistical Design: The General Linear Model
Results: Analyzing Contrast & Reporting
 Within-Subject Batching (Single Subject)



Subject-independent Analysis Steps
Subject-independent Data Flow (Dependencies)
Subject-related data
 Between-Subject-Batching (Multiple Subject)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
19
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Between-Subject-Batching (Multiple Subject)
Make sure, parameters to be adjusted have an X
(clear value) for the single subject template
Specify a meta-job with Run batch
Create one run for every subject and add missing
parameter values (in right order)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
20
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Resources and Useful Literature
 All step-by-step instructions can be found in the SPM
manual, chapter 40
 Also multiple-session and multiple subjects processing included
 The SPM helpline/mailing list
 E.g. bug precluding the batch-file selector form working was fixed
here, but not in the updates yet https://www.jiscmail.ac.uk/cgibin/webadmin?A2=ind1001&L=SPM&P=R39357
 Batch templates are in your spm path:
 Configured subject-independent analysis steps
<spm8>/man/batch/face_single_subject_template_nodeps.m
 With dependencies included
<spm8>/man/batch/face_single_subject_template.m
 With multiple subjects
<spm8>/man/batch/face_multi_subject_template.m
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
21
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Many, many thanks to
 Klaas Enno Stephan
 The SPM developers (FIL methods group)
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
22
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Extending the batchfile with SPM GUI functions





Debugging
Generally a good idea to find out how things work in SPM
Crucial for batch-programming using a .m-file
Here: debug spm.m by setting a breakpoint
If called function found, use edit <functionname>.m
to look at the %comments in the file
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
23
BATCH PROGRAMMING OF
FMRI DATA ANALYSIS
ZURICH SPM COURSE 2011
Tuning the engine – Matlab workspace variables
 e.g. to manipulate SPM.mat or jobs by hand
 also important during debugging, how variables are defined
and changed
Kasper/Mathys (18-Feb-11)
Computational Neuroeconomics (Prof. Stephan, USZ) / MR-Technology (Prof. Prüssmann, IBT)
24