SPM SPM short short course – course – Oct. Oct. 20020099Linear ModelsLinear Models and and ContrastsContrasts
Jean-Baptiste Poline
Neurospin, I2BM, CEASaclay, France
realignment &coregistration smoothing
normalisation
Corrected p-values
images Adjusted dataDesignmatrix
Anatomical Reference
Spatial filter
Random Field Theory
Your question:a contrast
Statistical MapUncorrected p-values
General Linear Model Linear fit
statistical image
Make sure we understand the testing procedures : tMake sure we understand the testing procedures : t-- and F and F--teststests
PlanPlan
Examples – almost realExamples – almost real
REPEAT: model and fitting the data with a Linear ModelREPEAT: model and fitting the data with a Linear Model
But what do we test exactly ?But what do we test exactly ?
Temporal series fMRI
Statistical image(SPM)
voxel time course
One voxel = One test (t, F, ...)One voxel = One test (t, F, ...)amplitude
time
General Linear Modelfittingstatistical image
Regression example…Regression example…
= + +
voxel time series
90 100 110
box-car reference function
-10 0 10
90 100 110
Mean value
Fit the GLM
-2 0 2
Regression example…Regression example…
= + +
voxel time series
90 100 110
box-car reference function
-2 0 2
0 1 2
Mean value
Fit the GLM
-2 0 2
……revisited : matrix formrevisited : matrix form
= + +
= + +Y
1 2 f(t)
Box car regression: design matrix…Box car regression: design matrix…
= +
= +Y X
data v
ecto
r
(v
oxel
time s
eries
)
design
mat
rix
param
eters
erro
r vec
tor
Q: When do I care ?Q: When do I care ?
A: ONLY when comparing manually A: ONLY when comparing manually entered regressors (say you would like to entered regressors (say you would like to
compare two scores)compare two scores)
What if two conditions A and B are not of What if two conditions A and B are not of the same duration before convolution HRF?the same duration before convolution HRF?
Fact: model parameters depend on Fact: model parameters depend on regressors scalingregressors scaling
What if we believe that there are drifts?What if we believe that there are drifts?
Add more reference functions / covariates ...Add more reference functions / covariates ...
Discrete cosine transform basis functionsDiscrete cosine transform basis functions
……design matrixdesign matrix
=
= +Y X
erro
r vec
tor
…
+
data v
ecto
r
……design matrixdesign matrix
=
+
= +Y X
data v
ecto
r
design
mat
rix
param
eters
erro
r vec
tor
= the b
etas (
here :
1 to
9)
Fitting the model = finding some Fitting the model = finding some estimateestimate of the of the betasbetas
raw fMRI time series adjusted for low Hz effects
residuals
fitted low frequencies
fitted signal
fitted drift
Raw data
How do we find the betas estimates? By How do we find the betas estimates? By minimizing the residual varianceminimizing the residual variance
Fitting the model = finding some Fitting the model = finding some estimateestimate of the betas of the betas
=
+ Y = X
∥Y−X ∥2 = Σi [yi−X i ]2
finding the betas = finding the betas = minimising the sum of square of the minimising the sum of square of the residualsresiduals
when when are estimated: let’s call them b are estimated: let’s call them b
when when is estimated : let’s call it e is estimated : let’s call it e
estimated SD of estimated SD of : let’s call it s : let’s call it s
We put in our model regressors (or covariates) that represent We put in our model regressors (or covariates) that represent how we think the signal is varying (of interest and of no interest how we think the signal is varying (of interest and of no interest alike) alike)
WHICH ONE TO INCLUDE ? WHICH ONE TO INCLUDE ? What if we have too many?What if we have too many?
Take home ...Take home ...
Coefficients (=Coefficients (= parameters) are parameters) are estimated by minimizing the estimated by minimizing the fluctuations, - variability – variance – of estimated noise – the fluctuations, - variability – variance – of estimated noise – the residuals. residuals.
Because the parameters depend on the scaling of the regressors Because the parameters depend on the scaling of the regressors included in the model, one should be careful in comparing included in the model, one should be careful in comparing manually entered regressors, or conditions of different durationsmanually entered regressors, or conditions of different durations
Make sure we understand t and F testsMake sure we understand t and F tests
PlanPlan
Make sure we all know about the estimation (fitting) part ...Make sure we all know about the estimation (fitting) part .... .
But what do we test exactly ?But what do we test exactly ?
An example – almost realAn example – almost real
A contrast = a weighted sum of parameters: c´ bc’ = 1 0 0 0 0 0 0 0
divide by estimated standard deviation of b
T test - one dimensional contrasts - SPM{T test - one dimensional contrasts - SPM{tt}}
SPM{t}T =
contrast ofestimated
parameters
varianceestimate
T =
ss22c’(X’X)c’(X’X)--cc
c’bc’b
b > 0 ?
Compute 1xb + 0xb + 0xb + 0xb + 0xb + . . . b b b b b ....
From one time series to an imageFrom one time series to an image
Y: data +=voxels
scans
EBX *
c’ =
1 0
0 0
0 0
0 0
Var(E) = s2
T =
ss22c’(X’X)c’(X’X)--cc
c’bc’b =
spm_con??? imagesspm_con??? images
beta??? imagesbeta??? images
spm_t??? imagesspm_t??? images
spm_ResMSspm_ResMS
FF--test : a reduced modeltest : a reduced model
H0: 1 = 0
X1 X0
H0: True model is X0
X0 c’ = 1 0 0 0 0 0 0 0
T values become F values. F = T2
Both “activation” and “deactivations” are tested. Voxel wise p-values are halved.This (full) model ? Or this one?
S2 S02
F ~ ( S02 - S2 ) / S2
Tests multiple linear hypotheses : Does X1 model anything ?
FF--test : a reduced model or ...test : a reduced model or ...
This (full) model ?
H0: True (reduced) model is X0
X1 X0
S2
Or this one?
X0
S02 F =
errorvarianceestimate
additionalvariance
accounted forby tested
effects
F ~ ( S02 - S2 ) / S2
0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 00 0 0 0 1 0 0 00 0 0 0 0 1 0 00 0 0 0 0 0 1 00 0 0 0 0 0 0 1
c’ =
tests multiple linear hypotheses. Ex : does drift functions model anything?
FF--test : a reduced model or ... multi-dimensional test : a reduced model or ... multi-dimensional contrasts ? contrasts ?
H0: 3-9 = (0 0 0 0 ...)
X1 X0
H0: True model is X0
X0
Or this one? This (full) model ?
Convolution model
Design andcontrast
SPM(t) orSPM(F)
Fitted andadjusted data
T tests are simple combinations of the betas; they are either T tests are simple combinations of the betas; they are either positive or negative (b1 – b2 is different from b2 – b1)positive or negative (b1 – b2 is different from b2 – b1)
T and F test: take home ...T and F test: take home ...
F tests can be viewed as testing for the additional variance F tests can be viewed as testing for the additional variance explained by a larger model wrt a simpler model, orexplained by a larger model wrt a simpler model, or
F tests the sum of the squares of one or several combinations of F tests the sum of the squares of one or several combinations of the betasthe betas
in testing “single contrast” with an F test, for ex. b1 – b2, the in testing “single contrast” with an F test, for ex. b1 – b2, the result will be the same as testing b2 – b1. It will be exactly the result will be the same as testing b2 – b1. It will be exactly the square of the t-test, testing for both positive and negative effects.square of the t-test, testing for both positive and negative effects.
Make sure we understand t and F testsMake sure we understand t and F tests
PlanPlan
Make sure we all know about the estimation (fitting) part ...Make sure we all know about the estimation (fitting) part .... .
But what do we test exactly ? Correlation between regressorsBut what do we test exactly ? Correlation between regressors
An example – almost realAn example – almost real
« Additional variance » : Again« Additional variance » : Again
No correlation between green red and yellow
correlated regressors, for examplegreen: subject ageyellow: subject score
Testing for the green
correlated contrasts
Testing for the red
Very correlated regressors ?
Dangerous !
Testing for the green
If significant ? Could be G or Y !
Testing for the green and yellow
Completely correlated regressors ?
Impossible to test ! (not estimable)
Testing for the green
An example: realAn example: real
Testing for first regressor: T max = 9.8
Including the movement parameters in the Including the movement parameters in the modelmodel
Testing for first regressor: activation is gone !
Implicit or explicit Implicit or explicit ((decorrelation (or decorrelation (or orthogonalisation)orthogonalisation)
Implicit or explicit Implicit or explicit ((decorrelation (or decorrelation (or orthogonalisation)orthogonalisation)
YY
XbXb
ee
Space of XSpace of X
C1C1
C2C2
LC2 :
LC1:
test of C2 in the implicit model
test of C1 in the explicit model
C1C1C2C2
XbXb
LC1
LC2
C2C2
cf Andrade et al., NeuroImage, 1999
This generalises when testing several regressors (F tests)
Correlation between regressors: take Correlation between regressors: take home ...home ...
Do we care about correlation in the design ? Do we care about correlation in the design ? Yes, alwaysYes, always
Start with the experimental design : conditions Start with the experimental design : conditions should be as uncorrelated as possibleshould be as uncorrelated as possible
use F tests to test for the overall variance use F tests to test for the overall variance explained by several (correlated) regressors explained by several (correlated) regressors
Make sure we understand t and F testsMake sure we understand t and F tests
PlanPlan
Make sure we all know about the estimation (fitting) part ...Make sure we all know about the estimation (fitting) part .... .
But what do we test exactly ? Correlation between regressorsBut what do we test exactly ? Correlation between regressors
An example – almost realAn example – almost real
A real example A real example (almost !)(almost !)
Factorial design with 2 factors : modality and category 2 levels for modality (eg Visual/Auditory)3 levels for category (eg 3 categories of words)
Experimental Design Design Matrix
V
A
C1
C2
C3C1
C2
C3
V A C1 C2 C3
Asking ouAsking ourrselves some questions ...selves some questions ...V A C1 C2 C3
• Design Matrix not orthogonal • Many contrasts are non estimable• Interactions MxC are not modelled
Test C1 > C2 : c = [ 0 0 1 -1 0 0 ]Test V > A : c = [ 1 -1 0 0 0 0 ]
[ 0 0 1 0 0 0 ]Test C1,C2,C3 ? (F) c = [ 0 0 0 1 0 0 ] [ 0 0 0 0 1 0 ]
Test the interaction MxC ?
Modelling the interactionsModelling the interactions
V A V A V A
Test C1 > C2 : c = [ 1 1 -1 -1 0 0 0]
Test the interaction MxC :[ 1 -1 -1 1 0 0 0]
c = [ 0 0 1 -1 -1 1 0][ 1 -1 0 0 -1 1 0]
• Design Matrix orthogonal• All contrasts are estimable• Interactions MxC modelled• If no interaction ... ? Model is too “big” !
C1 C1 C2 C2 C3 C3
Test V > A : c = [ 1 -1 1 -1 1 -1 0]
Test the category effect :[ 1 1 -1 -1 0 0 0]
c = [ 0 0 1 1 -1 -1 0][ 1 1 0 0 -1 -1 0]
With a more flexible modelWith a more flexible model
V A V A V ATest C1 > C2 ?Test C1 different from C2 ?from c = [ 1 1 -1 -1 0 0 0]to c = [ 1 0 1 0 -1 0 -1 0 0 0 0 0 0]
[ 0 1 0 1 0 -1 0 -1 0 0 0 0 0]becomes an F test!
C1 C1 C2 C2 C3 C3
What if we use only:
c = [ 1 0 1 0 -1 0 -1 0 0 0 0 0 0]
OK only if the regressors coding for the delay are all equal
use F tests whenuse F tests when- Test for >0 and <0 effectsTest for >0 and <0 effects- Test for more than 2 levels in factorial Test for more than 2 levels in factorial designsdesigns- Conditions are modelled with more than one Conditions are modelled with more than one regressorregressor
Toy example: take home ...Toy example: take home ...
Check post hocCheck post hoc
Thank you for your attention!Thank you for your attention!
[email protected]@cea.fr
How is this computed ? (t-test)How is this computed ? (t-test)
YY = = X X + + ~ ~ N(0,I) N(0,I) (Y : at one position)(Y : at one position)
b = (X’X)b = (X’X)+ + X’Y X’Y (b(b: : estimatestimatee of of ) -> ) -> beta??? images beta??? images
e = Y - Xbe = Y - Xb (e(e:: estimat estimatee of of ))
ss22 = (e’e/(n - p)) = (e’e/(n - p)) (s(s:: estimat estimate of e of n: n: time pointstime points, p: param, p: parameterseters)) -> -> 1 image ResMS1 image ResMS
Estimation [Y, X] [b, s]
Test [b, s2, c] [c’b, t]
Var(c’b) Var(c’b) = s= s22c’(X’X)c’(X’X)++c c (compute for each contrast c, proportional to (compute for each contrast c, proportional to ss22))
t = c’b / sqrt(st = c’b / sqrt(s22c’(X’X)c’(X’X)++c) c) c’b -> c’b -> images spm_con???images spm_con???
compute the t images -> compute the t images -> images spm_t??? images spm_t???
under the null hypothesis Hunder the null hypothesis H00 : t ~ Student : t ~ Student-t-t( df ) df = n-p( df ) df = n-p
How is this computed ? (F-test)How is this computed ? (F-test)Error
varianceestimate
additionalvariance accounted for
by tested effects
Test [b, s, c] [ess, F]
F ~ (sF ~ (s0 0 - s) / s- s) / s2 2 -> image -> image spm_ess???spm_ess???
-> image of F : -> image of F : spm_F???spm_F???
under the null hypothesis : F ~ F(under the null hypothesis : F ~ F(p - p0p - p0, n-p), n-p)
Estimation [Y, X] [b, s]
YY == X X + + ~ N(0, ~ N(0, I) I)
YY == XX + + ~ N(0, ~ N(0, I) I) XX : X Reduced : X Reduced