sinpase fmri course dr cyril pernet, university of edinburgh dr gordon waiter, university of...
TRANSCRIPT
SINPASE fMRI SINPASE fMRI coursecourse
Dr Cyril Pernet, University of Dr Cyril Pernet, University of EdinburghEdinburgh
Dr Gordon Waiter, University of Dr Gordon Waiter, University of AberdeenAberdeen
OverviewOverview Matlab® environment: images are matricesMatlab® environment: images are matrices MRI and fMRI: image format and softwaresMRI and fMRI: image format and softwares Computational Neuro-anatomy: theoryComputational Neuro-anatomy: theory Computational Neuro-anatomy: praticeComputational Neuro-anatomy: pratice Statistics: theoryStatistics: theory fMRI Single level analysis in practicefMRI Single level analysis in practice fMRI Random effects analysisfMRI Random effects analysis Other software - visualizationOther software - visualization
Data provided by the FIL: Data provided by the FIL: http://www.fil.ion.ucl.ac.uk/spm/http://www.fil.ion.ucl.ac.uk/spm/
Matlab® Matlab® environment: environment:
images are images are matricesmatrices
Read data and do basic stuffsRead data and do basic stuffs
Matlab (1)Matlab (1) Command Command
window: window:
A = 3+5A = 3+5
Workspace: Workspace: whoswhos
HistoryHistory
BrowserBrowser
Matlab (2)Matlab (2) load MRI_3D load MRI_3D look in the workspace look in the workspace size(MRI_3D) size(MRI_3D) returns the dimensions (here nb returns the dimensions (here nb
of voxels)of voxels) imagesc(MRI_3D(:,:,54))imagesc(MRI_3D(:,:,54))
All rows All columns ‘column’ 54 on All rows All columns ‘column’ 54 on dim3dim3
imagesc(MRI_3D(:,:,54)')imagesc(MRI_3D(:,:,54)') imagesc(flipud(MRI_3D(:,:,54)'))imagesc(flipud(MRI_3D(:,:,54)')) colormap('gray')colormap('gray')
Matlab (3)Matlab (3) MRI images are matrices (tables) with 3 dimensions, MRI images are matrices (tables) with 3 dimensions,
but it can be 4 dimensions (fMRI) or more.but it can be 4 dimensions (fMRI) or more.
Operations on matricesOperations on matrices A = [1 2 3 4 5]; B = A' (transpose)A = [1 2 3 4 5]; B = A' (transpose) A*B A*B → matrix multiplication sum of row*columns→ matrix multiplication sum of row*columns C = [1 1 1 1 1];C = [1 1 1 1 1]; A+C → addition / subtraction work by cellA+C → addition / subtraction work by cell A.*C → multiplication by cell uses .* (and ./)A.*C → multiplication by cell uses .* (and ./)
ExerciseExercise: subtract slice 54 from slice 55 and image it: subtract slice 54 from slice 55 and image it
imagesc(flipud(MRI_3D(:,:,55)'-MRI_3D(:,:,54)'))imagesc(flipud(MRI_3D(:,:,55)'-MRI_3D(:,:,54)'))
Matlab (4)Matlab (4) ExerciseExercise: Make a script (Matlab Editor) to look : Make a script (Matlab Editor) to look
at the all volume using an at the all volume using an axialaxial viewview
Possible functions to use: Possible functions to use: for, imagesc, squeeze, for, imagesc, squeeze, pausepause … and the matlab help … and the matlab help
Loop For/EndLoop For/End
for z = 1:108for z = 1:108
do this and that for each zdo this and that for each z endend
Matlab (5)Matlab (5)
for z = 50:220for z = 50:220
imagesc(squeeze(MRI_3D(:,z,:)))imagesc(squeeze(MRI_3D(:,z,:)))
colormap('gray')colormap('gray')
title(['this is the slice ',num2str(z)])title(['this is the slice ',num2str(z)])
pause(0.1)pause(0.1)
endend
MRI and fMRI:MRI and fMRI:image format and image format and
softwaresoftware
Image formatImage format DICOM format (.dcm)DICOM format (.dcm)
‘‘Standard’ format coming from all scannersStandard’ format coming from all scanners Stands for Stands for DDigital igital IImaging and maging and CoCommunications in mmunications in
MMedicine edicine Part 10 of the DICOM standard describes a file Part 10 of the DICOM standard describes a file
format for the distribution of images format for the distribution of images A single DICOM file contains both a header (which A single DICOM file contains both a header (which
stores information about the patient's name, the stores information about the patient's name, the type of scan, image dimensions, etc), as well as all of type of scan, image dimensions, etc), as well as all of the image data (which can contain information in the image data (which can contain information in three dimensions). three dimensions).
Manufacturers tend to output in DICOM but also Manufacturers tend to output in DICOM but also put lots of useful information in the ‘private’ part of put lots of useful information in the ‘private’ part of the headerthe header
Image formatImage format Analyze format (.img .hdr)Analyze format (.img .hdr)
Analyze is an image processing program, written by The Analyze is an image processing program, written by The Biomedical Imaging Resource at the Mayo Foundation.Biomedical Imaging Resource at the Mayo Foundation.
There are two Analyze formats. One, by much the more There are two Analyze formats. One, by much the more common, is Analyze 7.5 (this is one format used by common, is Analyze 7.5 (this is one format used by SPM), the other is Analyze AVW, the format used in the SPM), the other is Analyze AVW, the format used in the latest version of the Analyze programlatest version of the Analyze program
An Analyze (7.5) format image consists of two files, and An Analyze (7.5) format image consists of two files, and image (.img) and a header file (.hdr). The .img file image (.img) and a header file (.hdr). The .img file contains the numbers that make up the information in contains the numbers that make up the information in the image. The .hdr file contains information about the the image. The .hdr file contains information about the img file, such as the volume represented by each img file, such as the volume represented by each number in the image (voxel size) and the number of number in the image (voxel size) and the number of pixels in the X, Y and Z directions. This header contains pixels in the X, Y and Z directions. This header contains fields of text, floating point, integer and other fields of text, floating point, integer and other information. information.
Image formatImage format NIfti format (.img .hdr or .nii)NIfti format (.img .hdr or .nii)
Stands for Stands for NNeuroimaging euroimaging IInnfformatics ormatics TTechnology echnology IInitiative (The National Institute of Mental Health nitiative (The National Institute of Mental Health and the National Institute of Neurological and the National Institute of Neurological Disorders and Stroke)Disorders and Stroke)
Facilitates inter-operation of functional MRI data Facilitates inter-operation of functional MRI data analysis software packages analysis software packages
Headers now include - affine coordinate Headers now include - affine coordinate definitions relating voxel index (definitions relating voxel index (i,j,ki,j,k) to spatial ) to spatial location (location (x,y,zx,y,z); codes to indicate spatio-temporal ); codes to indicate spatio-temporal slice ordering for FMRI; - "Complete" set of 8-128 slice ordering for FMRI; - "Complete" set of 8-128 bit data types; - Standardized way to store vector-bit data types; - Standardized way to store vector-valued datasets over 1-4 dimensional domains; - valued datasets over 1-4 dimensional domains; - etcetc
1. Importing Data1. Importing Data Matlab DICOM tools in the image processing toolbox, Matlab DICOM tools in the image processing toolbox,
but also plenty of free software including SPMbut also plenty of free software including SPM Type SPM Type SPM select fMRI select fMRI
Import from the directory3D_dicom
Save as one file
1. Importing Data1. Importing Data
1. Importing Data1. Importing Data Select the newly Select the newly
imported imageimported image Surf to the front, Surf to the front,
near the eyenear the eye
Check orientationCheck orientationCheck the voxel size!!Check the voxel size!!
edit spm_defaultsedit spm_defaults defaults.analyze.flip defaults.analyze.flip
= 1; % input = 1; % input data left = rightdata left = right
1. Importing Data1. Importing Data Now simply double click on the nii file – this should Now simply double click on the nii file – this should
bring MRICron bring MRICron Again surf to the front near the eyes Again surf to the front near the eyes the white the white
spot is at a different location ?? Check outside the spot is at a different location ?? Check outside the brain brain MRICron is telling you are on the right MRICron is telling you are on the right sideside
BE AWARE OF THE ORIENTATIONBE AWARE OF THE ORIENTATION
Computational Computational Neuro-anatomy: Neuro-anatomy:
theorytheory
Slice timing andRealignment
smoothing
normalisation
Statistics
AnatomicalAnatomicalreferencereference
kernelkernel
fMRI time-seriesfMRI time-series
Slice timing: Why?Slice timing: Why? During the scanning, slices of the brain are During the scanning, slices of the brain are
acquired every TR (x sec) and one wants to acquired every TR (x sec) and one wants to correct for this delay between slices.correct for this delay between slices.
Data can be acquired in ascending/descending Data can be acquired in ascending/descending order, in this case one realigns first, otherwise order, in this case one realigns first, otherwise one would apply the same time correction to one would apply the same time correction to voxels possibly coming from different slices, i.e. voxels possibly coming from different slices, i.e. acquired at different time.acquired at different time.
Often one acquires first slices 1, 3, 5, 7, 9 … then Often one acquires first slices 1, 3, 5, 7, 9 … then 2, 4,6, 8, … (interleaved mode), in this case slice 2, 4,6, 8, … (interleaved mode), in this case slice timing is done first otherwise the realignment timing is done first otherwise the realignment would move voxels possibly coming from would move voxels possibly coming from different slices, i.e. acquired at different time different slices, i.e. acquired at different time (max TR/2), onto the same plane and the slice (max TR/2), onto the same plane and the slice timing would then be wrong.timing would then be wrong.
Realignment: Why?Realignment: Why? Subjects will always move in the scanner.Subjects will always move in the scanner.
movement may be related to the tasks movement may be related to the tasks performed.performed.
When identifying areas in the brain that appear When identifying areas in the brain that appear activated due to the subject performing a task, it activated due to the subject performing a task, it may not be possible to discount artefacts that have may not be possible to discount artefacts that have arisen due to motion.arisen due to motion.
The sensitivity of the analysis is determined by the The sensitivity of the analysis is determined by the amount of residual noise in the image series, so amount of residual noise in the image series, so movement that is unrelated to the task will add to movement that is unrelated to the task will add to this noise and reduce the sensitivity.this noise and reduce the sensitivity.
Normalization: Why?Normalization: Why?
Inter-subject averagingInter-subject averaging extrapolate findings to the population as a extrapolate findings to the population as a
wholewhole increase activation signal above that obtained increase activation signal above that obtained
from single subjectfrom single subject increase number of possible degrees of increase number of possible degrees of
freedom allowed in statistical modelfreedom allowed in statistical model Enable reporting of activations as co-ordinates Enable reporting of activations as co-ordinates
within a known standard spacewithin a known standard space e.g. MNIe.g. MNI
Smoothing: Why?Smoothing: Why?Smoothing is used for 3 reasons:Smoothing is used for 3 reasons: Potentially increase signal to noise (Depends on Potentially increase signal to noise (Depends on
relative size of smoothing kernel and effects to relative size of smoothing kernel and effects to be detected - Matched filter theorem: smoothing be detected - Matched filter theorem: smoothing kernel = expected signal - Practically FWHM 3· kernel = expected signal - Practically FWHM 3· voxel size ; May consider varying kernel size if voxel size ; May consider varying kernel size if interested in different brain regions (e.g. interested in different brain regions (e.g. hippocampus -vs- parietal cortex))hippocampus -vs- parietal cortex))
Inter-subject averaging.Inter-subject averaging. Increase validity of SPM.Increase validity of SPM.
In SPM, smoothing is a convolution with a Gaussian kernel, and the Kernel is defined in terms of FWHM (full width at half maximum).
Computational Computational Neuro-anatomy: Neuro-anatomy:
practicepractice
Single subject processingSingle subject processingProtocol – Imaging parametersProtocol – Imaging parameters
spm_data_set\Auditory_data_block_designspm_data_set\Auditory_data_block_design
Each acquisition consisted of 64 contiguous slices (3mm3).
Acquisition took 6.05s, with the scan to scan repeat time (TR) set to 7s.
96 acquisitions were made (TR=7s) from a single subject, in blocks of 6, giving 16 42s blocks.
The condition for successive blocks alternated between rest and auditory stimulation, starting with rest. Auditory stimulation was bi-syllabic words presented binaurally at a rate of 60 per minute.
The functional data starts at acquisition 4, image fM00223_004.
2. Slice timing2. Slice timing
2. Slice timing2. Slice timing
Session – Specify files --> select all Session – Specify files --> select all functional images --> 96 filesfunctional images --> 96 files
Number of slices?Number of slices? TR?TR? TA?TA? Slice order? Slice order? Reference slice?Reference slice?
OUTPUT: ‘a’ images .. afM00XX.img / .hdrOUTPUT: ‘a’ images .. afM00XX.img / .hdr
64
7
6.05[64:-2:1, 64-1:-2:1][64:-2:1, 64-1:-2:1]
2
3. Realignment3. Realignment
New session Select the slice timed images afM00XX.imgFor each session during the scanning, create a session !!
Creates the mean of all realigned EPI images – you do not have to write the data, parameters (which comes from the ‘estimate’) are kept in the header
created in your directory- the mean image-a spm.ps - .txt file= translation and rotation parameters
4. Normalize4. Normalize
We could normalize on the EPI template but We could normalize on the EPI template but since we have the subjects’ anatomical scan, since we have the subjects’ anatomical scan, we can use it to normalize on the T1 template.we can use it to normalize on the T1 template.
T1
Mean image
T1 like EPI
MNI T1 template
compute
apply
EPIRealign and normalizeCoregistration
4a. Coregister4a. Coregister
4a. Coregister4a. Coregister Target image?Target image?
mean EPI – this doesn’t changemean EPI – this doesn’t change Source image?Source image?
High resolution T1 (nsM00223_002.img)High resolution T1 (nsM00223_002.img)
We want this to be like the EPIWe want this to be like the EPI Other images?Other images?
nothing here nothing here Reslice option Reslice option interpolation interpolation
trilinear is fine, could improve using b-splinetrilinear is fine, could improve using b-spline
(come back to this latter)(come back to this latter)
4a. Coregistrer4a. Coregistrer Output: Output:
rrnsM00223_002.imgnsM00223_002.img
4b. Normalization4b. Normalization
4b. Normalize4b. Normalize Data Data New Subject New Subject
Source Image Source Image rns...img (compute from the coregistered rns...img (compute from the coregistered T1) T1)
Images to write Images to write all the af…img (normalize all EPI images) all the af…img (normalize all EPI images)
we can add the mean.imgwe can add the mean.img
we can add the rns…img (normalize the we can add the rns…img (normalize the T1)T1)
Estimation options: Estimation options:
Template image Template image SPM5\Template\T1.nii SPM5\Template\T1.nii
Writing options: interpolationWriting options: interpolation
4b. Normlization4b. Normlization Output:Output:
wa…imgwa…img
4c. Check the data4c. Check the data Check RegCheck Reg
Several Several images at images at onceonce
4c. Check the data4c. Check the data
SelectSelect
wmean…imgwmean…img T1 templateT1 template
5. Smoothing5. Smoothing Select the normalized imagesSelect the normalized images Smooth atSmooth at 6 mm6 mm
Output: s…imgOutput: s…img
A word on A word on interpolationinterpolation
Writing down the imagesWriting down the images What is interpolation?What is interpolation? Interpolation is a process for estimating values Interpolation is a process for estimating values
that lie between known data pointsthat lie between known data points
exit spm and open/run the script called interp_ex.mexit spm and open/run the script called interp_ex.m
z is a 2D matrix and one interpolates between the z is a 2D matrix and one interpolates between the ‘points’ defined by z – there are many options, here ‘points’ defined by z – there are many options, here we use nearest neighbor, bilinear, and bicubic we use nearest neighbor, bilinear, and bicubic interpolation methods – observe the difference in interpolation methods – observe the difference in the resultsthe results
5. Writing down the 5. Writing down the imagesimages
Writing down the imagesWriting down the images Why is it better to compute (estimate) everything Why is it better to compute (estimate) everything
11stst and then apply? and then apply?
While one can compute and write the realigned While one can compute and write the realigned data and compute and write the normalized one, I data and compute and write the normalized one, I suggest here to estimate the realignment suggest here to estimate the realignment parameters and then normalize. The realignment parameters and then normalize. The realignment only uses affine transformation (translations and only uses affine transformation (translations and rotations in x, y ,z) and this info is stored in the rotations in x, y ,z) and this info is stored in the header. Then we compute how to normalize an header. Then we compute how to normalize an image (translation, rotation, zoom, shear and non-image (translation, rotation, zoom, shear and non-linear warping) and multiply the two linear warping) and multiply the two transformation matrix – as a result a voxel (and its’ transformation matrix – as a result a voxel (and its’ contend) is ‘cut’ only 1 time vs. twice.contend) is ‘cut’ only 1 time vs. twice.
Statistical Statistical modelling: theorymodelling: theory
Slice timing andRealignment
smoothing
normalisation
General Linear Model model fitting statistic image
corrected corrected pp-values-values
Design matrixDesign matrix
AnatomicalAnatomicalreferencereference
kernelkernel
StatisticalStatisticalParametric MapParametric Map
Multiple comparisons correction
fMRI time-seriesfMRI time-seriesParameter estimatesParameter estimates
General Linear ModelGeneral Linear Model Regression, t-tests, ANOVAs, AnCovas … are all instances of Regression, t-tests, ANOVAs, AnCovas … are all instances of
the same linear modelling.the same linear modelling.
Regression: - simple: sRegression: - simple: searching to explain the data (y) by a earching to explain the data (y) by a single predictor (x) such as single predictor (x) such as y = y = ββx + b x + b – – multiple: smultiple: searching to earching to explain the data (y) by several predictors (xexplain the data (y) by several predictors (x11, x, x22, …) such as , …) such as y y = = ββ11xx11 + + ββ22xx22 + b + b
Linear models can be solved by the least squares method, i.e. one looks for a coefficient (Beta) that minimizes the error, i.e. the difference between the model (βx+b) and the data (y)
General Linear ModelGeneral Linear Model
Dummy coding:Dummy coding:
Instead of a continuous variable, we have Instead of a continuous variable, we have categorical variablescategorical variables
for each data point (y) we have a 2 groups, i.e. 1 for each data point (y) we have a 2 groups, i.e. 1 predictor (x) regarding the group that we code like predictor (x) regarding the group that we code like 1111-1-1-1-1 and we still use the equation 1111-1-1-1-1 and we still use the equation y = y = ββx + x + b b ( = t-test) ( = t-test)
or we can haveor we can have several groups/conditions (x1 = several groups/conditions (x1 = 1111-1-1-1-1, x2 =11-1-111-1-1, x1x2=11-1-1-1-111) 1111-1-1-1-1, x2 =11-1-111-1-1, x1x2=11-1-1-1-111) such assuch as y = y = ββ11xx11 + + ββ22xx22 + + ββ1212xx11xx22 b (ANOVA) b (ANOVA)
General Linear ModelGeneral Linear Model Using a matrix notation we can write any models like Using a matrix notation we can write any models like
Y = Xβ + eY = Xβ + e
Y a vector for each data point, Y a vector for each data point,
X the design matrix where each column is a vector X the design matrix where each column is a vector representing groups/conditions/continuous predictor representing groups/conditions/continuous predictor
β a vector (length = nb of column of X) of the β a vector (length = nb of column of X) of the coefficients to apply on X in order the minimize e the coefficients to apply on X in order the minimize e the error (what is not modeled/explained)error (what is not modeled/explained)
Matrix algebra offers a unique solution for all models: Matrix algebra offers a unique solution for all models:
β = (Xβ = (XTTX)X)-1-1 X XTT Y Y
using pseudoinverse in matlab: betas = using pseudoinverse in matlab: betas = pinv(X’*X)*X’*Ypinv(X’*X)*X’*Y
General Linear ModelGeneral Linear Model Exercise 1: multiple regression with 4 covariatesExercise 1: multiple regression with 4 covariates
Load the data called reg_eg.mat: load ('reg_eg')Load the data called reg_eg.mat: load ('reg_eg') Y = reg_eg(:,1); X = reg_eg(:,2:6); imagesc(X); XY = reg_eg(:,1); X = reg_eg(:,2:6); imagesc(X); X Y=X*B+e Y=X*B+e B = pinv(X'*X)*X'*YB = pinv(X'*X)*X'*Y; ; Yhat = X*B; Yhat = X*B; plot(Y); hold on; plot(Yhat,'r')plot(Y); hold on; plot(Yhat,'r') ss_total = norm(Y - mean(Y)).^2; ss_effect = ss_total = norm(Y - mean(Y)).^2; ss_effect =
norm(Yhat - mean(Yhat)).^2; ss_error = ss_total – norm(Yhat - mean(Yhat)).^2; ss_error = ss_total – ss_effect;ss_effect;
Rsquare = ss_effect/ss_totalRsquare = ss_effect/ss_total f = (ss_effect/(rank(X)-1)) / (ss_error/(length(Y)-f = (ss_effect/(rank(X)-1)) / (ss_error/(length(Y)-
rank(X))) rank(X)))
General Linear ModelGeneral Linear Model Exercise 2: ANOVA with 4 groupsExercise 2: ANOVA with 4 groups
Clear all; close all; clc; load(‘anova_eg’);Clear all; close all; clc; load(‘anova_eg’); Y = anova_eg(:,1); X = anova_eg(:,2:6); imagesc(X); Y = anova_eg(:,1); X = anova_eg(:,2:6); imagesc(X); Y=X*B+e Y=X*B+e B = pinv(X'*X)*X'*YB = pinv(X'*X)*X'*Y; ; Yhat = X*B; Yhat = X*B; plot(Y); hold on; plot(Yhat,'r')plot(Y); hold on; plot(Yhat,'r') ss_total = norm(Y - mean(Y)).^2; ss_effect = norm(Yhat - ss_total = norm(Y - mean(Y)).^2; ss_effect = norm(Yhat -
mean(Yhat)).^2; ss_error = ss_total – ss_effect;mean(Yhat)).^2; ss_error = ss_total – ss_effect; Rsquare = ss_effect/ss_totalRsquare = ss_effect/ss_total f = (ss_effect/(rank(X)-1)) / (ss_error/(length(Y)-rank(X))) f = (ss_effect/(rank(X)-1)) / (ss_error/(length(Y)-rank(X)))
EVERY ANALYSIS DEPENDS ON X AND THE DOFEVERY ANALYSIS DEPENDS ON X AND THE DOF
General Linear ModelGeneral Linear Model
Application to fMRI: massive univariate Application to fMRI: massive univariate approachapproach
For each voxel of the brainFor each voxel of the brain we have a time series we have a time series (data points Y) and we know what happened during (data points Y) and we know what happened during this time period (experimental conditions X).this time period (experimental conditions X).
We also know that after a stimulus or a response, We also know that after a stimulus or a response, the blood flow increases peaking at 5sec then the blood flow increases peaking at 5sec then decreases (hemodynamic response)decreases (hemodynamic response)
We thus model the data such as We thus model the data such as Y(t) = [u(t) Y(t) = [u(t) h(h(ττ)] )] ββ + e(t) + e(t) where u represent the occurance of where u represent the occurance of a stimulus or a response and h(a stimulus or a response and h(ττ) the hemodynamic ) the hemodynamic response with response with ττ the peristimulus time the peristimulus time
General linear convolution General linear convolution modelmodel
X(y) = u(t) X(y) = u(t) h( h(ττ))
u = [0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 u = [0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ];0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 ];
h = spm_hrf(1)h = spm_hrf(1)X = conv(u,h);X = conv(u,h);
General linear convolution General linear convolution modelmodel
y(t) = X(t)y(t) = X(t)ββ + e(t) + e(t) X as now two conditions u1 and u2 …X as now two conditions u1 and u2 … And we search the beta parameters to fit YAnd we search the beta parameters to fit Y
YY XX
General linear convolution General linear convolution modelmodel
= = ββ1 +1 + ββ2 + u + e2 + u + e
General linear convolution General linear convolution modelmodel
= = ββ11 ββ2 2 + e+ eu u
Single subject Single subject stat modelling: stat modelling:
practicepractice
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats Directory Directory select a directory to store your data select a directory to store your data
Timing parametersTiming parameters Unit for the design: scanUnit for the design: scan Interscan interval: 7 (TR)Interscan interval: 7 (TR) Microtime onset: 3 Microtime onset: 3
(TA = 6.05 and we slice timed on the middle slice)(TA = 6.05 and we slice timed on the middle slice)
Data and Design Data and Design ‘New Subject/Session’ ‘New Subject/Session’ Scans: images swaf…4.img to waf…99.imgScans: images swaf…4.img to waf…99.img
5. Single subject stats5. Single subject stats Data and Design Data and Design ‘New Subject/Session’ ‘New Subject/Session’ Scans: start at 4 to avoid artefacts .. (you should Scans: start at 4 to avoid artefacts .. (you should
always discard initial scans) = 96 filesalways discard initial scans) = 96 files Conditions Conditions New condition New condition
Name: ‘activation’Name: ‘activation’Onsets: Onsets: 6:12:84 (= every 12 scans from 6 to
84) Durations: 6 Multiple regressors: select the realignment
parameters (.txt file)
The rest is implicitly modelled (goes into the mean)
5. Single subject stats5. Single subject stats
ActivationsActivations
MovementsMovements
MeanMean
Model summaryModel summary
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
5. Single subject stats5. Single subject stats
Contrast estimateContrast estimate
(effect size) (effect size)
Fitted responseFitted response
(model or Y-error)(model or Y-error)
5. Single subject stats5. Single subject stats SPM outputsSPM outputs
beta000X.img /hdr: betas values in each voxelbeta000X.img /hdr: betas values in each voxel con000X.img /hdr: contrast (combination of betas)con000X.img /hdr: contrast (combination of betas) spmT000X.ing /hdr: statistics imagespmT000X.ing /hdr: statistics image
AlsoAlso mask.img / hdr: area analyzed by SPM (binary mask.img / hdr: area analyzed by SPM (binary
image)image) RessMS: residual mean squareRessMS: residual mean square RPV: Resels-Per-Voxel image; image of roughnessRPV: Resels-Per-Voxel image; image of roughness
Multiple Multiple comparisons comparisons correction: correction:
theorytheory
What Problem?What Problem?
4-Dimensional Data4-Dimensional Data 1,000 multivariate observations,1,000 multivariate observations,
each with 100,000 elementseach with 100,000 elements 100,000 time series, each 100,000 time series, each
with 1,000 observationswith 1,000 observations Massively UnivariateMassively Univariate
ApproachApproach 100,000 hypothesis100,000 hypothesis
teststests Massive MCP!Massive MCP!
1,000
1
2
3
. . .
Solutions for MCPSolutions for MCP
Height ThresholdHeight Threshold Familywise Error Rate (FWER)Familywise Error Rate (FWER)
Chance of Chance of anyany false positives; Controlled by false positives; Controlled by Bonferroni & Random Field MethodsBonferroni & Random Field Methods
False Discovery Rate (FDR)False Discovery Rate (FDR) Proportion of false positives Proportion of false positives amongamong rejected rejected
teststests Set level statisticSet level statistic Bayes StatisticsBayes Statistics
From single univariate to From single univariate to massive univariatemassive univariate
Univariate statUnivariate stat Functional Functional neuroimagingneuroimaging
1 observed data1 observed data Many voxelsMany voxels
1 statistical value1 statistical value Family of statistical Family of statistical valuesvalues
Type 1 error rate Type 1 error rate (chance to be wrong (chance to be wrong rejecting H0)rejecting H0)
Family-wise error Family-wise error raterate
Null hypothesisNull hypothesis Family-wise null Family-wise null hypothesishypothesis
Height ThresholdHeight Threshold Choose locations where a test statistic Z (T, 2, ...) Choose locations where a test statistic Z (T, 2, ...)
is large to threshold the image of Z at a height zis large to threshold the image of Z at a height z The problem is how to choose this threshold z to The problem is how to choose this threshold z to
exclude false positives with a high probability exclude false positives with a high probability (e.g. 0.95)?(e.g. 0.95)?
To control for family wise error on must take into account the nb of tests
BonferroniBonferroni 10000 Z-scores ; alpha = 5%10000 Z-scores ; alpha = 5% alpha corrected = .000005 ; z-score = 4.42alpha corrected = .000005 ; z-score = 4.42
100 voxels
100 voxels
BonferroniBonferroni 10000 Z-scores ; alpha = 5%10000 Z-scores ; alpha = 5% 2D homogeneous smoothing – 100 independent 2D homogeneous smoothing – 100 independent
observationsobservations alpha corrected = .0005 ; z-score = 3.29alpha corrected = .0005 ; z-score = 3.29
100 voxels
100 voxels
Random Field TheoryRandom Field Theory 10000 Z-scores ; alpha = 5%10000 Z-scores ; alpha = 5% Gaussian kernel smoothing – Gaussian kernel smoothing – How many independent observations ?How many independent observations ?
100 voxels
100 voxels
Random Field TheoryRandom Field Theory RFT relies on theoretical results for smooth RFT relies on theoretical results for smooth
statistical maps (hence the need for smoothing), statistical maps (hence the need for smoothing), allowing to find a threshold in a set of data allowing to find a threshold in a set of data where it’s not easy to find the number of where it’s not easy to find the number of independent variables. Uses the expected Euler independent variables. Uses the expected Euler characteristic (EC density)characteristic (EC density)
1 Estimation of the smoothness = number of 1 Estimation of the smoothness = number of resel (resolution element) = f(nb voxels, FWHM) resel (resolution element) = f(nb voxels, FWHM)
2 ! expected Euler characteristic = number of 2 ! expected Euler characteristic = number of clusters above the threshold clusters above the threshold
3 Calculation of the threshold3 Calculation of the threshold
Random Field TheoryRandom Field Theory The Euler characterisitc can be seen as the The Euler characterisitc can be seen as the
number of blobs in an image after thresholdingnumber of blobs in an image after thresholding At high threshold, EC = 0 or 1 per resel: E[EC] At high threshold, EC = 0 or 1 per resel: E[EC]
ppFWEFWE
E[EC] = R · (4 loge 2) · (2)−2/3 · Zt · e−1/2 Z2t for a 2D image, more complicated in 3D
Random Field TheoryRandom Field Theory For 100 resels, the equation gives E[EC] = 0.049 for a For 100 resels, the equation gives E[EC] = 0.049 for a
threshold Z of 3.8, i.e. the probability of getting one or threshold Z of 3.8, i.e. the probability of getting one or more blobs where Z is greater than 3.8 is 0.049more blobs where Z is greater than 3.8 is 0.049
100 voxels
100 voxels
If the resel size is much larger than the voxel size then If the resel size is much larger than the voxel size then E[EC] only depends on the nb of resels othersize it also E[EC] only depends on the nb of resels othersize it also depends on the volume, surface and diameter of the search depends on the volume, surface and diameter of the search area (i.e. shape and volume matter)area (i.e. shape and volume matter)
False discovery RateFalse discovery Rate
Whereas family wise approach corrects for any false Whereas family wise approach corrects for any false positive, the FDR approach aim at correcting among positive, the FDR approach aim at correcting among positive results only.positive results only.
1. Run an analysis with alpha = x%1. Run an analysis with alpha = x%
2. Sort the resulting data2. Sort the resulting data
3. Threshold the resulting data to remove the false positives 3. Threshold the resulting data to remove the false positives
(theoretical problem: threshold any voxels whatever their (theoretical problem: threshold any voxels whatever their spatial positions) spatial positions)
False discovery RateFalse discovery Rate
Signal+Noise
FEW correction
FDR correction
Levels of Levels of inference:inference:
theorytheory
Levels of inferenceLevels of inference 3 levels of inference can be considered:3 levels of inference can be considered:- Voxel level (prob associated at each voxel)Voxel level (prob associated at each voxel)- Cluster level (prob associated to a set of voxels)Cluster level (prob associated to a set of voxels)- Set level (prob associated to a set of clusters)Set level (prob associated to a set of clusters)
The 3 levels are nested and based on a single The 3 levels are nested and based on a single probability of obtaining c or more clusters (set level) probability of obtaining c or more clusters (set level) with k or more voxels (cluster level) above a with k or more voxels (cluster level) above a threshold u (voxel level): Pthreshold u (voxel level): Pww(u,k,c)(u,k,c)
Both voxel and cluster levels need to address the Both voxel and cluster levels need to address the multiple comparison problem. If the activated region multiple comparison problem. If the activated region is predicted in advance, the use of corrected P is predicted in advance, the use of corrected P values is unnecessary and inappropriately values is unnecessary and inappropriately conservative – a correction for the number of conservative – a correction for the number of predicted regions (Bonferroni) is enough predicted regions (Bonferroni) is enough
Levels of inferenceLevels of inference Set levelSet level: we can reject H0 for an : we can reject H0 for an
omnibus test, i.e. there are some omnibus test, i.e. there are some significant clusters of activation in significant clusters of activation in the brain.the brain.
Cluster levelCluster level: we can reject H0 for an : we can reject H0 for an area of a size k, i.e. a cluster of area of a size k, i.e. a cluster of ‘activated’ voxels is likely to be true for ‘activated’ voxels is likely to be true for a given spatial extend.a given spatial extend.
Voxel levelVoxel level: we can reject H0 at : we can reject H0 at each voxel, i.e. a voxel is ‘activated’ each voxel, i.e. a voxel is ‘activated’ if exceeding a given thresholdif exceeding a given threshold
Inference in Inference in practicepractice
Levels of inference and Levels of inference and MCCMCC
From single From single subjects to subjects to
random effects: random effects: theorytheory
From single subjects to From single subjects to random effectsrandom effects
Why random effect (also called pseudo-mixed)?Why random effect (also called pseudo-mixed)?
Basic stats: compute the mean for each condition Basic stats: compute the mean for each condition for each subjects and do the stats on these for each subjects and do the stats on these means (inter-subject variance)means (inter-subject variance)
Random effect: compute the beta parameters for Random effect: compute the beta parameters for each condition (intra-subject variance) and do each condition (intra-subject variance) and do the stats on these beta parameter (inter-subject the stats on these beta parameter (inter-subject variance)variance)
From single From single subjects to random subjects to random
effects: practiceeffects: practice
Face data setFace data set Repetition priming experiment performed using
event-related fMRI 2x2 factorial study with factors `fame‘ and
`repetition' where famous and non-famous faces were presented twice against a checkerboard baseline
Four event-types of interest; first and second presentations of famous and non-famous faces, which are denoted N1, N2, F1 and F2
TR=2s TA = 1.92s 24 descending slices (64x64 3x3mm2) 3mm thick with a 1.5mm gap
Single subject modellingSingle subject modelling Here we consider a more sophisticated model in Here we consider a more sophisticated model in
which we use the hrf and its derivatives.which we use the hrf and its derivatives.
In the folder, spm_data_set\In the folder, spm_data_set\Face_data_event_related_design\ single_subject\Face_data_event_related_design\ single_subject\Preprocessed, you can find the smoothed, Preprocessed, you can find the smoothed, normalized, realigned, and slice timed imagesnormalized, realigned, and slice timed images
Try to model by yourself Try to model by yourself
Single subject modellingSingle subject modelling Stimulus Onsets
Times sots.mat Cond 1 to 4 are
F1, F2, N1, N2 with the respective onset time sot{1} sot{2} sor{3} and sot{4}
Single subject modellingSingle subject modelling DirectoryDirectory stats stats Timing parametersTiming parameters: : UnitsUnits (sec), (sec), Interscan intervalInterscan interval
(2), (2), Microtime resolutionMicrotime resolution (24), (24), Microtime onsetMicrotime onset (12)(12)
Data and designData and design ‘ ‘New Subject/SessionNew Subject/Session’: ’: ScanScan (all EPI swa…img), (all EPI swa…img), ConditionCondition create 4 conditions, create 4 conditions, each time enter name and sot (F1 sot{1} F2 sot {2} each time enter name and sot (F1 sot{1} F2 sot {2} N1 sot{3} N2 sot{4}), N1 sot{3} N2 sot{4}), Multiple regressorsMultiple regressors: enter : enter the .txt file from realignmentthe .txt file from realignment
Factorial DesignFactorial Design create 2 factors (famous, level create 2 factors (famous, level =2, and repetition, level =2)=2, and repetition, level =2)
Basis functionBasis function: Canonical HRF, model derivatives : Canonical HRF, model derivatives (time and dispersion)(time and dispersion)
Single subject modellingSingle subject modelling Result Result select the SPM.mat select the SPM.mat Because we specified the factorial design, the variance Because we specified the factorial design, the variance
has been partitioned in a specific way and contrasts are has been partitioned in a specific way and contrasts are already therealready there
Select contrast nb 5Select contrast nb 5
Single subject modellingSingle subject modelling
Single subject modellingSingle subject modelling
Single subject modellingSingle subject modelling Define a new F contrast called ‘effect of interest’Define a new F contrast called ‘effect of interest’
(any effect of any regressor and combinations) (any effect of any regressor and combinations) ok ok done done
Single subject modellingSingle subject modelling Plot Plot contrast estimates and 90% CI contrast estimates and 90% CI select select
effect of interesteffect of interest
F1 F2 N1 N2
Single subject modellingSingle subject modelling Plot event-related response / fitted responsePlot event-related response / fitted response
Single subject modellingSingle subject modelling In the matlab workspace In the matlab workspace Y = fitted response, y = adjusted responseY = fitted response, y = adjusted response ExerciseExercise: plot for 4 fitted responses on 1 figure: plot for 4 fitted responses on 1 figure Each time save using e.g. N1 = Y; then N2 = Y; .. then Each time save using e.g. N1 = Y; then N2 = Y; .. then
plot(N1); hold on; plot(N2,’--’) …plot(N1); hold on; plot(N2,’--’) …
Multi-subjectsMulti-subjects
All data were analyzed and are stored in the folder All data were analyzed and are stored in the folder Face_data_event_related_design\multisubjects\Face_data_event_related_design\multisubjects\cons_informedcons_informed
We have all the con images from 12 subjects, data We have all the con images from 12 subjects, data were modelled with Famous and Non famous faces were modelled with Famous and Non famous faces (2 conditions only) with the hrf and the two (2 conditions only) with the hrf and the two derivatives (12*6 files)derivatives (12*6 files)
Random effectsRandom effects
Random effectsRandom effects Analyze Faces vs baselineAnalyze Faces vs baseline For each subject we have the con images for the For each subject we have the con images for the
hrf, the 1hrf, the 1stst derivative and 2 derivative and 2ndnd derivative derivative
A full analysis will thus be a repeated measure A full analysis will thus be a repeated measure ANOVA (we have 3 measures per subject)ANOVA (we have 3 measures per subject)
SPM allows to correct for non-sphericity, i.e. it SPM allows to correct for non-sphericity, i.e. it will take into account the correlation between will take into account the correlation between regressors – here regressors are by inception regressors – here regressors are by inception correlatedcorrelated
Random effectsRandom effects Design Design Full factorial Full factorial
create a ‘new factor’ create a ‘new factor’ Name: Basis functionsName: Basis functions Levels:Levels: Independence: Independence: Specify cells Specify cells create 3 create 3
cells, 1 per level of the cells, 1 per level of the factor (cell 1 = con 3 to factor (cell 1 = con 3 to 14 / cell 2 = 15 to 26 / 14 / cell 2 = 15 to 26 / cell 3 = 27 to 38) cell 3 = 27 to 38)
RunRun EstimateEstimate
3No
Random effectsRandom effects In the contrast In the contrast
manager, manager, enter a new F enter a new F contrast: effect contrast: effect of interest of interest (eye(3))(eye(3))
Evaluate and Evaluate and look at the look at the result with a result with a correction correction FWE @ .05FWE @ .05
Random effectsRandom effects
Random effectsRandom effects In the In the
contrast contrast manager, manager, enter a new T enter a new T contrast for contrast for the hrf only: 1 the hrf only: 1 0 00 0
Evaluate and Evaluate and look at the look at the result with a result with a correction correction FEW @ .05FEW @ .05
Random effectsRandom effects
Select an image to display (e.g. SPM /canonical/T1)Add blobs select the SPM.mat and the 2 contrasts
Random effectsRandom effects The display is The display is
‘surfable’‘surfable’ MNI and voxel MNI and voxel
coordinates coordinates availableavailable
Voxel valueVoxel value
}
Random effectsRandom effects F Contrast [0 1 0]F Contrast [0 1 0] Time dispersion Time dispersion
(+/- 2 sec)(+/- 2 sec)
F Contrast [0 0 1 ]F Contrast [0 0 1 ]
Duration dispersionDuration dispersion
Earlier response(- = delayed)
Narrower response( - = wider)
Random effectRandom effect Paired t-testPaired t-test
12 pairs12 pairs 3 vs 393 vs 39 4 vs 404 vs 40 …… Independence: Independence:
NoNo Variance: equalVariance: equal
Visualizing the Visualizing the datadata
SPM and other softwareSPM and other software
Rendering with Rendering with SPMSPM
SegmentationSegmentation
SegmentationSegmentation Input Input coregistered coregistered
image in \image in \spm_data_set\ spm_data_set\ Face_data_event_relatFace_data_event_related_design\ed_design\single_subject\single_subject\Structural Structural rs …img rs …img
Output Output grey / white matter grey / white matter
tissuestissues bias corrected imagebias corrected image
affine normalization affine normalization parameters (and parameters (and inverse)inverse)
Rendering with SPMRendering with SPM
Select the grey and white matter (c1 and c2) images and save the rendering
Rendering with SPMRendering with SPM
Select the SPM.mat from the individual subject and then 2 sets / contrasts
Rendering in SPMRendering in SPM For random effects analysis you can use the For random effects analysis you can use the
render in SPM/render which is in the MNI spacerender in SPM/render which is in the MNI space
For individual subjects, best is to not normalize For individual subjects, best is to not normalize and make a render .. Results are better with and make a render .. Results are better with smaller voxel size (i.e. you could interpolate the smaller voxel size (i.e. you could interpolate the data @ 1mmdata @ 1mm33) )
Overall, better to use slices / section – poor Overall, better to use slices / section – poor rendering capabilities although new plug in are rendering capabilities although new plug in are appearing ..appearing ..
Surface Surface visualization with visualization with
CaretCaret
What does it do?What does it do? Surface visualizationSurface visualization Display experimental data (activation maps, connectivity Display experimental data (activation maps, connectivity
patterns, etc)patterns, etc) View data in flexible combinations (cortical surface, flat View data in flexible combinations (cortical surface, flat
maps, contours, outlines, etc)maps, contours, outlines, etc)
Surface manipulation and data analysisSurface manipulation and data analysis generate inflated maps, spherical maps, and flat mapsgenerate inflated maps, spherical maps, and flat maps probabilistic maps, surface based analysisprobabilistic maps, surface based analysis
On-line search for fMRI maps, On-line search for fMRI maps, comparisons, etc .. comparisons, etc ..
The SoftwareThe Software http://http://brainmap.wustl.edubrainmap.wustl.edu/caret/caret my experience is that it works better with linux / mac my experience is that it works better with linux / mac
but windows does the jobbut windows does the job
From David Van Essen lab – Washingtom University From David Van Essen lab – Washingtom University in St Louis – School of Medicine – Dpt of Anatomy & in St Louis – School of Medicine – Dpt of Anatomy & NeurobiologyNeurobiology
Most famous paper from this guy?Most famous paper from this guy? Felleman, D.J. and Van Essen, D.C. (1991) Distributed Felleman, D.J. and Van Essen, D.C. (1991) Distributed
hierarchical processing in primate visual cortex, hierarchical processing in primate visual cortex,
Cerebral Cortex, 1: 1-47.Cerebral Cortex, 1: 1-47.
CaretCaret File File Open Spec File Open Spec File
……
In Caret\ In Caret\ HUMAN.COLIN.ATLASHUMAN.COLIN.ATLAS\ LEFT_HEM\ …spec\ LEFT_HEM\ …spec
CaretCaret
CaretCaret
CaretCaret Attributes Attributes Map Map
Volume(s) to Volume(s) to Surface(s) … Surface(s) … leave the Metric leave the Metric option ticked and option ticked and press nextpress next
CaretCaret Add Volumes Add Volumes
From Disk From Disk select the select the spmT_0005.hdr spmT_0005.hdr file from the file from the single subject single subject analysis (Face analysis (Face data set)data set)
CaretCaret Map to CaretMap to Caret
CaretCaret Chose your Chose your
algorithm algorithm Average Voxel Average Voxel Neighbor Box Size Neighbor Box Size 1 1 Next .. Next ..
CaretCaret
CaretCaret
CaretCaret
Individual Individual visualization with visualization with
AnatomistAnatomist
Brain Visa / AnatomistBrain Visa / Anatomist Caret as well as BrainVisa / Anatomist works Caret as well as BrainVisa / Anatomist works
better with clean data … better with clean data … 1 st – data are usual better handled with 1 st – data are usual better handled with
isotropic voxels (same dimensions in x, y, z) isotropic voxels (same dimensions in x, y, z) better acquire isotropic voxels, at least for the T1better acquire isotropic voxels, at least for the T1
2 nd – there is usual a bias in one direction (often 2 nd – there is usual a bias in one direction (often Z), i.e. for a given concentration of tissue, the Z), i.e. for a given concentration of tissue, the gray scale is slightly differentgray scale is slightly different
Solution: correct and resampleSolution: correct and resample
My favourite tools for this: FSLMy favourite tools for this: FSL
Quick Tour into FSLQuick Tour into FSL Depending on what you want to doDepending on what you want to do ApplyXFM ApplyXFM reinterpolation using the identity matrix reinterpolation using the identity matrix FSL FSL brings the interface brings the interface BET / SUSAN / FSL View BET / SUSAN / FSL View
Back to BrainVisa / Back to BrainVisa / AnatomistAnatomist
Back to AnatomistBack to Anatomist
AnatomistAnatomist
ResourcesResources
IdoImaging: IdoImaging: http://idoimaging.com/index.shtmlhttp://idoimaging.com/index.shtml
SPM: SPM: http://www.fil.ion.ucl.ac.uk/spm/http://www.fil.ion.ucl.ac.uk/spm/ Caret: Caret:
http://brainvis.wustl.edu/wiki/index.php/Caret:Abhttp://brainvis.wustl.edu/wiki/index.php/Caret:Aboutout
FSL: FSL: http://www.fmrib.ox.ac.uk/fsl/http://www.fmrib.ox.ac.uk/fsl/ BrainVisa / Anatomist: BrainVisa / Anatomist: http://brainvisa.info/http://brainvisa.info/
Cambridge imaging wiki: Cambridge imaging wiki: http://imaging.mrc-cbu.cam.ac.uk/imaging/CbuIhttp://imaging.mrc-cbu.cam.ac.uk/imaging/CbuImagingmaging
Russ Poldracks’wiki on Matlab: Russ Poldracks’wiki on Matlab: http://www.poldracklab.org/teaching/psych254http://www.poldracklab.org/teaching/psych254
Digital signal processing in general: Digital signal processing in general: http://www.dspguide.com/pdfbook.htmhttp://www.dspguide.com/pdfbook.htm
Maths in general: Maths in general: http://mathworld.wolfram.com/http://mathworld.wolfram.com/