31
2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Embed Size (px)

Citation preview

Page 1: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

2nd level analysis – design matrix, contrasts and inference

Irma KurniawanMFD Jan 2009

Page 2: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Today’s menu

• Fixed, random, mixed effects• First to second level analysis• Behind button-clicking: Images produced and calculated• The buttons and what follows..• Contrast vectors, Levels of inference, Global effects, Small

Volume Correction • Summary

Page 3: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Fixed vs. Random EffectsFixed vs. Random Effects

Subject 1

• Subjects can be Fixed or Random variables

• If subjects are a Fixed variable in a single design matrix (SPM “sessions”), the error term conflates within- and between-subject variance

– But in fMRI (unlike PET) the between-scan variance is normally much smaller than the between-subject variance

• Subjects can be Fixed or Random variables

• If subjects are a Fixed variable in a single design matrix (SPM “sessions”), the error term conflates within- and between-subject variance

– But in fMRI (unlike PET) the between-scan variance is normally much smaller than the between-subject variance

Subject 2

Subject 3

Subject 4

Subject 6

Multi-subject Fixed Effect model

error df ~ 300

Subject 5

• If one wishes to make an inference from a subject sample to the population, one needs to treat subjects as a Random variable, and needs a proper mixture of within- and between-subject variance

• Mixed models: the experimental factors are fixed but the ‘subject’ factor is random.

• In SPM, this is achieved by a two-stage procedure:1) (Contrasts of) parameters are estimated from

a (Fixed Effect) model for each subject2) Images of these contrasts become the data

for a second design matrix (usually simple t-test or ANOVA)

• If one wishes to make an inference from a subject sample to the population, one needs to treat subjects as a Random variable, and needs a proper mixture of within- and between-subject variance

• Mixed models: the experimental factors are fixed but the ‘subject’ factor is random.

• In SPM, this is achieved by a two-stage procedure:1) (Contrasts of) parameters are estimated from

a (Fixed Effect) model for each subject2) Images of these contrasts become the data

for a second design matrix (usually simple t-test or ANOVA)

Page 4: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

WHEN special case of n independent observations per

subject:

var(pop) = 2b + 2

w / Nn

Two-stage “Summary Statistic” approachTwo-stage “Summary Statistic” approach

p < 0.001 (uncorrected)

SPM{t}

1st-level (within-subject) 2nd-level (between-subject)

cont

rast

imag

es o

f c

i

1^

2^

3^

4^

5^

6^

N=6 subjects(error df =5)

One-sample t-test

po

p

^

^

1)^

wwithin-subject error^

2)

3)^

4)^

5)^

6)

Page 5: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Relationship between 1st & 2nd levels

• 1st-level analysis: Fit the model for each subject.Typically, one design matrix per subject

• Define the effect of interest for each subject with a contrast vector.

• The contrast vector produces a contrast image containing the contrast of the parameter estimates at each voxel.

• 2nd-level analysis: Feed the contrast images into a GLM that implements a statistical test.

Con image for contrast 1 for subject 1

Con image for contrast 2 for subject 2

Con image for contrast 1 for subject 2

Con image for contrast 2 for subject 1

Contrast 1 Contrast 2

Subject 2

Subject 1

You can use checkreg button to display con images of different subjects for 1 contrast and eye-ball if they show similar activations

Page 6: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

• Both use the GLM model/tests and a similar SPM machinery

• Both produce design matrices.• The rows in the design matrices represent observations:

– 1st level: Time (condition onsets); within-subject variability– 2nd level: subjects; between-subject variability

• The columns represent explanatory variables (EV): – 1st level: All conditions within the experimental design– 2nd level: The specific effects of interest

Similarities between 1st & 2nd levels

Page 7: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Similarities between 1st & 2nd levels

• The same tests can be used in both levels (but the questions are different)

• .Con images: output at 1st level, both input and output at 2nd level• 1st level: variance is within subject, 2nd level: variance is between

subject.• There is typically only one 1st-level design matrix per subject, but

multiple 2nd level design matrices for the group – one for each statistical test.

For example: 2 X 3 design between variable A and B. We’d have three design matrices (entering 3 different

sets of con images from 1st level analyses) for 1) main effect of A2) main effect of B3) interaction AxB.

A1

A2

1 2

4 5

3

6

B2 B3B1

Page 8: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Difference from behavioral analysis

• The ‘1st level analysis’ typical to behavioural data is relatively simple: – A single number: categorical or frequency – A summary statistic, resulting from a simple model of the data,

typically the mean.

• SPM 1st level is an extra step in the analysis, which models the response of one subject. The statistic generated (β) then taken forward to the GLM.– This is possible because βs are normally distributed.

• A series of 3-D matrices (β values, error terms)

Page 9: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Behind button-clicking…

• Which images are produced and calculated when I press ‘run’?

Page 10: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

1st level design matrix:6 sessions per subject

Page 11: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

The following images are created each time an analysis is performed (1st or 2nd level)

• beta images (with associated header), images of estimated regression coefficients (parameter estimate). Combined to produce con. images.• mask.img This defines the search space for the statistical analysis.• ResMS.img An image of the variance of the error (NB: this image is used to produce spmT images).• RPV.img The estimated resels per voxel (not currently used).

•All images can be displayed using check-reg button

Page 12: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

1st-level (within-subject)

1

2

3

4

5

6

1

^

^

^

^

^

^

wwithin-subject error^

Beta images contain values related to size of effect. A given voxel in each beta image will have a value related to the size of effect for that explanatory variable.

The ‘goodness of fit’ or error term is contained in the ResMS file and is the same for a given voxel within the design matrix regardless of which beta(s) is/are being used to create a con.img.

Page 13: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Explicit masks

Group maskSingle subject mask

Segmentation of structural images

Mask.img

Calculated using the intersection of 3 masks:

1) Implicit (if a zero in any image then masked for all images) default = yes

2) Thresholding which can be i) none, ii) absolute, iii) relative to global (80%).

3) Explicit mask (user specified)

Note:You can include explicit mask at

1st- or 2nd-level.If include at 1st-level, the

resulting group mask at 2nd-level is the overlapping regions of masks at 1st-levelso, will probably much smaller than single subject masks.

Page 14: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Beta value = % change above global mean.In this design matrix there are 6 repetitions of the condition so these need to be summed.

Con. value = summation of all relevant betas.

Page 15: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

ResMS.img =residual sum of squares or variance image and is a measure of within-subject error at the 1st level or between-subject error at the 2nd.

Con. value is combined with ResMS value at that voxel to produce a T statistic or spm.T.img.

2ˆi

Page 16: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

spmT.imgThresholded using theresults button.

Eg random noiseEg random noise

Gaussian10mm FWHM(2mm pixels)

pu = 0.05

Gaussian10mm FWHM(2mm pixels)

pu = 0.05pu = 0.05

Page 17: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

spmT.img and corresponding spmF.img

Page 18: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

So, which images?

• beta images contain information about the size of the effect

of interest.

• Information about the error variance is held in the

ResMS.img.

• beta images are linearly combined to produce relevant con.

images.

• The design matrix, contrast, constant and ResMS.img are

subjected to matrix multiplication to produce an estimate of the

st.dev. associated with each voxel in the con.img.

• The spmT.img are derived from this and are thresholded in

the results step.

Page 19: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

The buttons and what follows..

• Specify 2nd-level• Enter the output dir• Enter con images from

each subject as ‘scans’• PS: Using matlabbatch, you

can run several design matrices for different contrasts all at once

• Hit ‘run’• Click ‘estimate’ (may take a

little while)• Click ‘results’ (can ‘review’

first before this)

Page 20: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009
Page 21: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

A few additional notes…

Page 22: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

How to enter contrasts…Effort

Reward

E2E1

R2

R1

R1 R2

E1 E2 E1 E2

Main effect of Reward

1 1 -1 -1

Main effect of Effort

1 -1 1 -1

Effort x Reward

1 -1 -1 1

Interaction: RE1 x RE2 = (R1E1 – R1E2) – (R2E1– R2E2)= R1E1 – R1E2 – R2E1 + R2E2 = 1 - 1 - 1 + 1= [ 1 -1 -1 1]

Page 23: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Levels of InferenceLevels of Inference

• Three levels of inference:– extreme voxel values

voxel-level (height) inference

– big suprathreshold clusters cluster-level (extent) inference

– many suprathreshold clusters

set-level inference

• Three levels of inference:– extreme voxel values

voxel-level (height) inference

– big suprathreshold clusters cluster-level (extent) inference

– many suprathreshold clusters

set-level inference

n=82n=82

n=32n=32

n=1n=122

Set level: At least 3 clusters above thresholdSet level: At least 3 clusters above thresholdCluster level: At least 2 cluster with at least 82 Cluster level: At least 2 cluster with at least 82 voxels above thresholdvoxels above thresholdVoxel level: at least cluster with unspecified Voxel level: at least cluster with unspecified number of voxels above thresholdnumber of voxels above threshold

Which is more powerful?Which is more powerful?Set > cluster > voxel levelSet > cluster > voxel levelCan use voxel level threshold for a priori Can use voxel level threshold for a priori hypotheses about specific voxels.hypotheses about specific voxels.

voxel-level: voxel-level: P(t P(t 4.37) = .048 4.37) = .048

set-level:set-level: P(c P(c 3, n 3, n k, t k, t u) = 0.019 u) = 0.019

cluster-level:cluster-level: P(n P(n 82, t 82, t u) = 0.029 u) = 0.029

Page 24: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Example SPM window

Page 25: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Global EffectsGlobal Effects

• May be global variation from scan to scan

• Such “global” changes in image intensity confound local / regional changes of experiment

• Adjust for global effects (for fMRI) by:

Proportional Scaling

• Can improve statistics when orthogonal to effects of interest (as here)…

• …but can also worsen when effects of interest correlated with global (as next)

• May be global variation from scan to scan

• Such “global” changes in image intensity confound local / regional changes of experiment

• Adjust for global effects (for fMRI) by:

Proportional Scaling

• Can improve statistics when orthogonal to effects of interest (as here)…

• …but can also worsen when effects of interest correlated with global (as next)

rCB

F

x

o

o

o

o

o

o

x

x

x

x

x

gCBF

rCB

F

x

o

o

o

o

o

o

x

x

x

x

x

global

globalgCBF

rCB

F

x

oo

o

oo

o

xx

xx

x

0 50

rCB

F (adj)

o

0

xxxx

xx

ooooo

Scaling

Page 26: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Global EffectsGlobal Effects

• Two types of scaling: Grand Mean scaling and Global scaling

• Grand Mean scaling is automatic, global scaling is optional

• Grand Mean scales by 100/mean over all voxels and ALL scans (i.e, single number per session)

• Global scaling scales by 100/mean over all voxels for EACH scan (i.e, a different scaling factor every scan)

• Problem with global scaling is that TRUE global is not (normally) known…

• …we only estimate it by the mean over voxels

• So if there is a large signal change over many voxels, the global estimate will be confounded by local changes

• This can produce artifactual deactivations in other regions after global scaling

• Since most sources of global variability in fMRI are low frequency (drift), high-pass filtering may be sufficient, and many people to not use global scaling

• Two types of scaling: Grand Mean scaling and Global scaling

• Grand Mean scaling is automatic, global scaling is optional

• Grand Mean scales by 100/mean over all voxels and ALL scans (i.e, single number per session)

• Global scaling scales by 100/mean over all voxels for EACH scan (i.e, a different scaling factor every scan)

• Problem with global scaling is that TRUE global is not (normally) known…

• …we only estimate it by the mean over voxels

• So if there is a large signal change over many voxels, the global estimate will be confounded by local changes

• This can produce artifactual deactivations in other regions after global scaling

• Since most sources of global variability in fMRI are low frequency (drift), high-pass filtering may be sufficient, and many people to not use global scaling

Page 27: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Small-volume correctionSmall-volume correction

• If have an a priori region of interest, no need to correct for whole-brain!

• But can correct for a Small Volume (SVC)

• Volume can be based on:

– An anatomically-defined region

– A geometric approximation to the above (eg rhomboid/sphere)

– A functionally-defined mask (based on an ORTHOGONAL contrast!)

• Extent of correction can be APPROXIMATED by a Bonferonni correction for the number of resels…(cf. Random Field Theory slides)

• ..but correction also depends on shape (surface area) as well as size (volume) of region (may want to smooth volume if rough)

• If have an a priori region of interest, no need to correct for whole-brain!

• But can correct for a Small Volume (SVC)

• Volume can be based on:

– An anatomically-defined region

– A geometric approximation to the above (eg rhomboid/sphere)

– A functionally-defined mask (based on an ORTHOGONAL contrast!)

• Extent of correction can be APPROXIMATED by a Bonferonni correction for the number of resels…(cf. Random Field Theory slides)

• ..but correction also depends on shape (surface area) as well as size (volume) of region (may want to smooth volume if rough)

Page 28: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Example SPM window

Page 29: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

SVC summary

• p value associated with t and Z scores is dependent on

2 parameters:

1. Degrees of freedom.

2. How you choose to correct for multiple

comparisons.

Page 30: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

Statistical inference: imaging vs. behavioural data

• Inference of imaging data uses some of the same statistical tests as used for analysis of behavioral data:– t-tests, – ANOVA– The effect of covariates for the study of individual-differences

• Some tests are more typical in imaging:– Conjunction analysis

• Multiple comparisons poses a greater problem in imaging (RFT; small volume correction)

Page 31: 2nd level analysis – design matrix, contrasts and inference Irma Kurniawan MFD Jan 2009

With help from …

• Rik Henson’s slides.

• Debbie Talmi & Sarah White’s slides

• Alex Leff’s slides

• SPM manual (D:\spm5\man).

• Human Brain Function book

• Guillaume Flandin & Geoffrey Tan