glm for fmri data analysis - dimitri van de...
TRANSCRIPT
Getting Started AUDIO 1st level The Batch Interface
GLM for fMRI data analysisLab Exercise 1
March 15, 2013
Medical Image Processing Lab
Medical Image Processing Lab GLM for fMRI data analysis
Getting Started AUDIO 1st level The Batch Interface
Outline
1 Getting Started
2 AUDIO 1st levelPreprocessingModel Specification, Review and EstimationInference and Results
3 The Batch Interface
2 / 26
Getting Started AUDIO 1st level The Batch Interface
Getting the Software and Data
● get the SPM software package and the two data sets fromhttp://miplab.epfl.ch/teaching/micro-513/download/ or from the the direct linksbelow
● SPM toolkit
● Dataset (single subject)
● For this practical, three files are required:spm8.zipglm data1.zip
3 / 26
Getting Started AUDIO 1st level The Batch Interface
fMRI Data Set
AUDIOsingle subject auditory data, 16 blocks, TR=7s, 1st level analysis, SPM8 manualChapter 28, available at http://www.fil.ion.ucl.ac.uk/spm/data/auditory/
4 / 26
Getting Started AUDIO 1st level The Batch Interface
Medical Imaging Datatypes
DICOM (Digital Imaging and Communications in Medicine)
● file name suffix .dcm
● one file per slice
● meta information stored in every file
● vendor-specific meta-information
● standard for archiving in hospital environment
● incompatible with SPM8
ANALYZE
● file name suffix header/matrix .hdr,.img
● header contains voxel-to-world mapping
● matrix contains the raw data matrix
● compatible with SPM8
NIfTI (Neuroimaging Informatics Technology Initiative)
● file name suffix .nii
● matrix and voxel-to-world mapping in one file
● standard format of SPM8
5 / 26
Getting Started AUDIO 1st level The Batch Interface
Start SPM8
● extract glm spm8.zip into /tmp
● verify that there is a folder /tmp/spm8
● add SPM8 to the Matlab path andstart it
% add SPM8 path to Matlab path v a r i a b l eaddpath ( genpath ( '/tmp/spm8 ' ) ) ;% s t a r t SPM8 g r a p h i c a l u s e r i n t e r f a c espm
● choose fMRI
Figure : SPM8 modality selection window.
● alternatively, start fMRI mode directlyafter adding path
% s t a r t d i r e c t l y i n fMRI modespm ( ' fMRI ' ) ;
6 / 26
Getting Started AUDIO 1st level The Batch Interface
SPM8 Interface
● access the most usedfunctions
● status messages, progressbar, selections, etc.
● view results, images, etc.
Figure : SPM8 “Menu” (top-left), “Interactive” (bottom-left) and“Graphics” (right) window.
7 / 26
Getting Started AUDIO 1st level The Batch Interface
File Selection Window
● one click to select/deselect files
● Ed button allows manual change or enteringof path
● Done button confirms selection
● keeps history of previously visited paths
● regexp-like filtering
● works also in scripts, e.g. files=spm select;
● current Matlab path is the default path
Figure : SPM select dialog.
8 / 26
Getting Started AUDIO 1st level The Batch Interface
Inspect the Data
AUDIOsee SPM8 manual, chapter 28, for detailed tutorialusing this data set
● Decompress glm data1.zip into /tmp.
● Verify that there is a folder/tmp/GLMLAB/AUDIO
● Browse the files, there is one folder containingthe structural image (i.e. sM00223) and onefolder for the functional volumes (i.e.fM00223).
● start the check registration tool fromcommand line
% check t h e image r e g i s t r a t i o n q u a l i t ys p m c h e c k r e g i s t r a t i o n
● or click Check Reg button
● choose one or more images, e.g. one functionaland the structural
Figure : Functional and structuralimages before co-registration.
9 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Headers, Pre-, and Suffixes
SPM functions modify the data in different ways
● change affine world-to-voxel mapping stored in header *.hdr
● write new file, often pre- or suffixed
Prefixes
r* re-sliced and usually also realignedmean* mean imagec1* gray matterc2* white matterc3* cerebro-spinal fluidm* bias-field corrected structural imagew* warped (non-linearly transformed) image, e.g. into MNIs* spatially smoothed image
Suffixes
* seg sn.mat non-linear forward transformation from subject to MNI space* seg inv sn.mat non-linear reverse transformation from MNI to subject space
10 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Preprocessing Overview
Preprocessing StepInputs Outputs
Realign (Estimate & Reslice)
Coregister (Estimate)
Segmentation
Normalise (Write)
Smooth
fM00223 *.{img,hdr}
meanfM00223 004.{img,hdr}sM00223.{img,hdr}
sM00223 004.{img,hdr}
sM00223 seg sn.mat
rfM00223 *.{img,hdr}
wrfM00223 *.{img,hdr}
rfM00223 *.{img,hdr}meanfM00223 004.{img,hdr}
sM00223 002.hdr
c{1,2,3}sM00223 002.{img,hdr}sM00223 002 seg sn.mat
sM00223 002 seg inv sn.mat
msM00223 002.{img,hdr}wmsM00223 002.{img,hdr}
wrfM00223 *.{img,hdr}
swrfM00223 *.{img,hdr}
11 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Spatial Normalization
Realignment
● rigid-body transform (translation and rotation)
● within modality
● within subject
Co-registration
● affine transform (translation, rotation and scaling)
● across different modalities
● within same or across subjects
Normalize
● non-linear invertible transformation
● usually to reference space, i.e. MNI
12 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
1st Level Analysis
Dataset AUDIO /tmp/GLMLAB/AUDIO/
13 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Realignment of functional volumes
Perform realignment of the volumes of the timeseries to the mean image.
● select Realign (Est & Res) from the
Realign pull-down menu
● highlight data, select New Session , then
highlight the newly created Session option.
● Select Specify Files and use the SPM file
selector to choose all of your functional imagesfM000*.img. There should be 96 files
● Save the job file as eg. ./jobs/realign.m.
● Press the ▶ button in the batch editor
● headers will be rewritten
● mean image meanfM00223 004.img will becreated
Figure : Rigid body realignmentparameters.
14 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Co-registration
Co-register the structural to the mean functionalimage.
● Select Coregister (Estimate) from the
Coregister pulldown menu.
● Highlight Reference Image and then select
the mean fMRI scan from realignmentmeanfM00223 004.img.
● Highlight Source Image and then select the
structural image sM00223 002.img.
● Press the Save button (floppy disk symbol)and save the job as coreg.m.
● Then press the ▶ button.
● Verify that alignment is correct.
Figure : Image coregistration result.
15 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Segmentation
Create tissue probability maps of gray matter(GM), white matter (WM) and cerebro-spinal fluid(CSF), and obtain normalization parameters towarp image into MNI space.
● Press the Segment button.
● Highlight the Data field and then select thesubjects registered anatomical imagesM00223 002.img.
● Highlight . Cerebro-Spinal Fluid and choose
Native Space .
● Save the job file as segment.m, and then press▶ button.
● Open the tissue probability mapsc1sM00223 002.img (GM),c2sM00223 002.img (WM),c3sM00223 002.img (CSF), andmsM00223 002.img (bias-field corrected T1).
Figure : Segmentation result.
16 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Normalized
Normalize volumes of time series into MNI spaceand re-slice to 3mm isotropic voxel size.
● Select Normalise (Write) from the
Normalise pull-down menu.
● Highlight Data , select New Subject .
● Highlight Parameter File and select thesM00223 0020 seg sn.mat.
● Highlight images to write and select all ofthe realigned functional images rfM000*.img
and the structural image sM00223 0020.nii.
● Open Writing Options , and change
Voxel sizes from [2 2 2] to [3 3 3].
● Save the job as normalise.m and then pressthe ▶ button.
Figure : wmsM00223 0020.img (top)and single subject T1 template/spm8/canonical/single subj T1.nii
17 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing
Smoothing
Apply spatial smoothing with isotropic Gaussianfilter with 6mm FWHM.
● Press Smooth button.
● Select Images to Smooth and then select the
spatially normalised files created in the lastsection i.e. ^wrf.*
● Highlight FWHM and change [8 8 8] to [6 66]. This will smooth the data by 6mm in eachdirection.
● Save the job as smooth.m and press the ▶button.
Figure : wrfM00223 004.img (top) andswrfM00223 004.img (bottom)
18 / 26
Getting Started AUDIO 1st level The Batch Interface
Model Specification, Review and Estimation
Model Specification
To avoid T1 effects in the initial scans of an fMRI time series we discarding the firstcycle (12 scans, 04-15), leaving 84 scans, image files 16-99.
● Press Specify 1st-level button.
● Open the Timing parameters option.
● Highlight Units for design and select Scans .
● Highlight Inter-scan interval and enter “7”.
● Highlight Data and Design and select New Subject/Session .
● Open the newly created Subject/Session option.
● Highlight Scans and use SPM’s file selector to choose the 84 smoothed,normalised func- tional images ie. swrfM00223 {016..099}.img. (use ^s.*).
● Highlight Conditions and select New condition .
● Open the newly created Condition option. Highlight Name and enter “active”.
High-light Onsets and enter “6:12:84”. Highlight Durations and enter “6”.
● Create a directory named results.
● Highlight Directory and select the results directory you just created.
● Save the job as specify.m and press the ▶ button.
19 / 26
Getting Started AUDIO 1st level The Batch Interface
Model Specification, Review and Estimation
Review
Y =Xβ + ε (1)
Y: observed signal, X: regressors, β: parameter estimates, ε: zero-mean Gaussiannoise
Figure : Design matrix. Figure : Orthogonality. Figure : Explore session 1.
20 / 26
Getting Started AUDIO 1st level The Batch Interface
Model Specification, Review and Estimation
Estimation
● Press the Estimate button.
● Highlight the Select SPM.mat option and then choose the SPM.mat file saved inthe classical subdirectory.
● Save the job as estimate.m and press the ▶ button.
● SPM will write a number of files into the selected directory including an SPM.mat
file.
21 / 26
Getting Started AUDIO 1st level The Batch Interface
Inference and Results
Contrast Prompt
● Press Results .
● Select the SPM.mat file created in the lastsection.
● This will invoke the contrast manager.
● Select Define new contrast . One sided maineffects for the active condition (i.e., aone-sided t-test) can be specified as “1”(active > rest) and “-1” (rest > active).
● Select the contrast name e.g., “active > rest”.
● Press Done .
Figure : Contrast prompt.
22 / 26
Getting Started AUDIO 1st level The Batch Interface
Inference and Results
Thresholded Statistical Parametric Map
● Select “sections” from the overlays pulldownmenu.
● Choose wmsM00223 002.img as background.
Figure : Statistical parametric map ofAUDIO single subject activation(p<0.05, FWE).
23 / 26
Getting Started AUDIO 1st level The Batch Interface
The Batch Interface
Batch interface allows to define processing pipelineslinked by dependencies.
● Press Batch .
● Choose menu “File” then “Open File ..”
● Select realign.m, coregister.m andsegment.m (in this order).
● Select the Coregister: Estimate module and
then Reference Image .
● Press Dependency , highlight
Realign: Estimate & Reslice: Mean Image ,
and then OK.
● Select the Segment module, highlight Data ,
press Dependency , highlight
Coregister: Estimate: Coregistered Images
and Press OK .
Figure : Batch editor including the firstthree steps of the preprocessingpipeline.
24 / 26
Getting Started AUDIO 1st level The Batch Interface
Preprocessing Overview
View of the various processing steps as a single box with only few in- and outputs.Preprocessing StepInputs Outputs
PreprocessingfM00223 *.{img,hdr}
sM00223 004.{img,hdr} swrfM00223 *.{img,hdr}
25 / 26
Getting Started AUDIO 1st level The Batch Interface
Resources
● SPM8 Documentation, http://www.fil.ion.ucl.ac.uk/spm/doc/
● Friston, K.J., 2007. Statistical parametric mapping, the analysis of functionalbrain images. Academic Press.
Acknowledgements Thanks to Ahmed Abdulkadir and Jonas Richiardi for helping inputting together this lab exercise.
26 / 26