DCM for fMRI - 1st level (Attention)¶
Dynamic Causal Modelling (DCM) involves specifying a model for each participant (first-level analysis) and then specifying a model of between-subjects effects (second-level analysis). This tutorial works through first level analysis using data from the classic study of Buchel et al. (1998) using the Graphical User Interface (GUI).
We will first review the experimental design and hypotheses, and then work through the following steps:
- Download the data
- Specify the GLM
- Add contrasts
- Extract time series
- Specify models
- Estimate models
- Compare models (Bayesian model comparison)
- Review estimated parameters
Experimental design¶
This fMRI study investigated why paying attention to visual motion alters brain activity throughout the visual system.
During the experiment, participants saw pictures of dots on a computer screen in the scanner. Depending on the trial, the dots either moved radially outwards from the middle of the screen or remained stationary. There were four experimental conditions. which we will refer to as A,N,S and F:
- Attention. Participants were cued to silently detect changes in the speed of the moving dots.
- No attention. The dots were moving and the participants were instructed to “just look”.
- Stationary. The dots did not move and the participants were instructed to “just look”.
- Fixation. Only the central fixation point was visible.
Hypotheses¶
We will focus on three brain regions: early visual cortex (V1) and higher regions known to be sensitive to visual motion (V5) and attention (Superior Parietal Cortex, SPC). We will use DCM to arbitrate between two hypotheses:
- H1. Attention modulates forward (i.e., bottom-up) connectivity from V1 to V5.
- H2. Attention modulates backward (i.e., top-down) connectivity from SPC to V5.
Analysis¶
Download the data¶
First, get a a zip file containing the dataset from the SPM website. Unzip the files to a safe location on your computer and navigate to that directory using MATLAB. (The same link provides analysis scripts that reproduce the steps we are about to follow using the GUI.)
The directory you have downloaded should include:
- A directory named
functional
, which includes the preprocessed fMRI volumes. The TR is 3.22 seconds and there are 360 scans. - A directory named
structural
, which includes a normalised T1 structural volume. - File
factors.mat
, which contains the onsets for the conditions. They are namedstat
(stationary),natt
(no attention) andatt
(attention) and are defined in scans (not seconds). They are blocks of 10 TRs each.
Specify the GLM¶
Before performing a DCM for fMRI analysis, one must first perform a General Linear Model (GLM) analysis to identify where in the brain experimental effects occurred. For convenience, we will re-arrange the four conditions in the experiment into the following three conditions:
- Photic. Comprises all trials with dot stimuli (A,N,S).
- Motion. Subset of trials in which the dot stimuli were in motion (A,N).
- Attention. Subset of trials in which the participants were cued to pay attention (A).
These will form the three regressors in our GLM. Specify the GLM as follows:
-
Make a new directory called
GLM
that will contain the analysis (alongside the existing functional and structural directories). -
In MATLAB type
>> cd GLM >> spm fmri
-
From the main SPM window, click on the Batch button.
-
From the SPM menu at the top of the Batch Editor, select “Stats > fMRI model specification”.
-
Click Directory and choose the
GLM
directory that you made above. -
Units for design: scans
-
Interscan interval: 3.22
-
Click Data & Design, choose New Subject/Session.
-
Click Scans and choose all the functional scans
snffM00587_00xx.img
. There should be 360*.img
files. -
Go back to the main MATLAB workspace and load the MAT-file containing the experimental conditions:
>> load ../factors.mat
You can look at the loaded variables by typing the variable names (
stat
= stationary,natt
= no attention,att
= attention)>> stat >> natt >> att
-
Return to the batch editor. Click Conditions then double click New: Condition three times. Enter the following details for each:
- Condition 1: Name =
Photic
, Onsets =[att natt stat]
and Durations =10
. - Condition 2: Name =
Motion
, Onsets =[att natt]
and Durations =10
. - Condition 3: Name =
Attention
, Onsets =att
and Durations =10
.
- Condition 1: Name =
-
From the SPM menu at the top of the Batch Editor, select Stats > model estimation.
-
For “Select SPM.mat”, click on the Dependency button and choose the proposed item (the output from the previous module).
-
You should now be able to press the Run green arrow at the top of the Batch Editor window. This will specify and estimate the GLM.
The design matrix that has been created (and saved in the file SPM.mat
) is shown below.
Add contrasts¶
We need contrasts to identify where in the brain experimental effects occurred. We will define t-contrasts that test for photic, motion, and attention, respectively. We will also need to add an “effects of interest” F-contrast, which is required for mean-correcting the extracted time series. Any experimental effects not covered by this contrast will be regressed out of the signal.
-
From the main SPM window, click on the Batch button.
-
From the menu at the top, click “SPM > Stats > Contrast manager”.
-
For Select SPM.mat, select the one that has been created in the previous step.
-
Under Contrast Sessions, choose one New: F-contrast and three New: T-contrast. For each one, enter:
- F-contrast: Name =
Effects of interest
, F contrast vector =eye(3)
. - T-contrast: Name =
Photic
, T contrast vector =[1 0 0]
. - T-contrast: Name =
Motion
, T contrast vector =[0 1 0]
. - T-contrast: Name =
Attention
, T contrast vector =[0 0 1]
.
- F-contrast: Name =
-
Press the green arrow at the top of the Batch Editor window. This will specify and estimate these contrasts.
Extract time series¶
The next step is to extract one representative fMRI time series from each brain region of interest: V5, V1 and SPC.
Extract time series from V5¶
To locate visual area V5, we will identify voxels that respond to both visual motion AND attention to motion. This is referred to as “masking” one contrast by another. We will then extract time series from voxels identified by this contrast, restricted to a sphere positioned in the V5 region:
-
Press Results.
-
Select the
SPM.mat
file. -
Choose the t-contrast for the
Motion
condition. -
Apply masking: contrast
-
Choose the t-contrast for the
Attention
condition. -
Uncorrected mask p-value p < 0.05 and nature of mask: inclusive.
-
p value adjustment to control: none with a threshold of 0.001 and extent 0.
-
To overlay these results on a structural scan, click overlays... in the SPM Results window, then click sections. Navigate to the structural folder and select the file named “nsM00587_0002.img”.
-
At the bottom of the results window, enter the following coordinates, which are V5-ish:
[-36 -87 -3]
. -
Press the eigenvariate button.
-
Name of region:
V5
-
Adjust data for:
Effects of interest
(this effectively mean-corrects the time series) -
VOI definition:
sphere
-
VOI radius(mm): e.g.
8
mm
SPM now computes the first principal component of the time series from all super-threshold voxels included in the sphere. The result is stored together with the original time series) in a file named VOI_V5_1.mat
in the working directory (the “1” refers to session 1).
Extract time series from V1¶
We will next identify visual area V1 (primary visual cortex) using the Photic contrast. This is the same procedure as for V5 above, except we will only be using one contrast (not masking one contrast by another):
-
Press Results.
-
Select the
SPM.mat
file. -
Choose the t-contrast for the
Photic
condition. -
Apply masking: none
-
p value adjustment to control: none with a threshold of 0.001 and extent 0
-
To overlay these results on a structural scan, click “overlays...” in the SPM Results window, then click previous sections.
-
Set the coordinates at the bottom of the Results window to
[0 -93 18]
. -
Press the eigenvariate button.
-
Name of region:
V1
-
Adjust data for:
Effects of interest
(this effectively mean-corrects the time series) -
VOI definition:
sphere
-
VOI radius(mm): e.g.
8
mm
This will create the file VOI_V1_1.mat
.
Extract time series from SPC¶
Finally, we will extract time series from superior parietal cortex (SPC). We will identify voxels in this region using the Attention contrast:
-
Press Results.
-
Select the
SPM.mat
file. -
Choose the t-contrast for the
Attention
condition. -
Apply masking: none.
-
p value adjustment to control: none with a threshold of 0.001 and extent 0.
-
To overlay these results on a structural scan, click “overlays...” in the SPM Results window, then click previous sections.
-
Set the coordinates at the bottom of the Results window to
[-27 -84 36]
. -
Press the eigenvariate button.
-
Name of region:
SPC
-
Adjust data for:
Effects of interest
(this effectively mean-corrects the time series) -
VOI definition:
sphere
-
VOI radius(mm): e.g.
8
mm
Specify the DCMs¶
Backward (top-down) model¶
The first of two models we’ll specify is the backward model, in which attention modulates the connection from SPC to V5:
Specify this model by following these steps:
-
Press the large
Dynamic Causal Modelling
button. -
Choose specify.
-
Select the
SPM.mat
file you just created when specifying the GLM. -
Name for
DCM_???.mat
: e.g.mod_bwd
(for “attentional modulation of backward connection”). -
Select all VOIs in order
VOI_V1_1
,VOI_V5_1
,VOI_SPC_1
. -
Include
Photic
: Yes -
Include
Motion
: Yes -
Include
Attention
: Yes -
Specify slice timings for each area. The default values are set to the last slice of the data, which was the default in the original DCM version. For sequential (as opposed to interleaved) data, this modelling option allows to use DCM in combination with any TR (slice timing differences) (Kiebel et al. 2007). Here, we proceed with the default values.
-
Enter
0.04
for “Echo Time, TE”. -
Modulatory effects:
bilinear
-
States per region:
one
-
Stochastic effects:
no
-
Centre input:
no
-
Fit timeseries or CSD:
timeseries
-
Define the following extrinsic connections: V1 to V5, V5 to V1, V5 to SPC, SPC to V5, i.e. a hierarchy with reciprocal connections between neighbouring areas. Note that the columns specify the source of the connection and the rows specify its target. This should match the figure below (first panel).
-
Specify Photic as a driving input into V1. This should match the second panel, below.
-
Specify Motion to modulate the connection from V1 to V5. This should match the third panel, below.
-
Specify Attention to modulate the connection from SPC to V5. This should match the fourth panel, below.
A polite “Thank you” completes the model specification process. A file called DCM_mod_bwd.mat
will have been generated.
Forward (bottom-up) model¶
We will now specify the second DCM model, in which attention modulates the forward connection from V1 to V5:
To specify this model we will follow exactly the same procedure as above, but this time in step 4 we will name the model mod_fwd
, and in step 19, we will have Attention modulate the connection from V1 to V5:
-
Press the large
Dynamic Causal Modelling
button. -
Choose specify.
-
Select the
SPM.mat
file you just created when specifying the GLM. -
Name for
DCM_???.mat
: e.g.mod_fwd
(for “attentional modulation of forward connection”). -
Select all VOIs in order
VOI_V1_1
,VOI_V5_1
,VOI_SPC_1
. -
Include
Photic
: Yes -
Include
Motion
: Yes -
Include
Attention
: Yes -
Specify slice timings for each area. The default values are set to the last slice of the data, which was the default in the original DCM version. For sequential (as opposed to interleaved) data, this modelling option allows to use DCM in combination with any TR (slice timing differences) (Kiebel et al. 2007). Here, we proceed with the default values.
-
Enter
0.04
for “Echo Time, TE”. -
Modulatory effects:
bilinear
-
States per region:
one
-
Stochastic effects:
no
-
Centre input:
no
-
Fit timeseries or CSD:
timeseries
-
Define the following extrinsic connections: V1 to V5, V5 to V1, V5 to SPC, SPC to V5, i.e. a hierarchy with reciprocal connections between neighbouring areas. Note that the columns specify the source of the connection and the rows specify its target.
-
Specify Photic as a driving input into V1.
-
Specify Motion to modulate the connection from V1 to V5.
-
Specify Attention to modulate the connection from V1 to V5. Note that this differs from the connection selected in the previous model.
A polite “Thank you” completes the model specification process. A file called DCM_mod_fwd.mat
will be generated.
Estimate the DCMs¶
Estimating (or inverting) a DCM provides two outputs: the log-evidence for the model (approximated by a quantity called the free energy) and estimated model parameters (e.g., connection strengths).
Press the large DCM button, select both the models created above (DCM_mod_bwd.mat
and DCM_mod_fwd.mat
), then press Done. The screen shown below will be updated as the algorithm searches for a setting of the parameters that maximizes the quality of the model (as scored by the free energy).
Compare models¶
We will now perform Bayesian model comparison to assess which of the two models was the best.
-
Press the DCM button.
-
Choose Compare.
-
In the Batch Editor window that opened, fill in the boxes as follows:
-
Directory
- choose current directory by clicking the small dot on the right hand side of the file selector then click Done. -
Data
- add a New Subject with a New Session and select the two models, e.g. in the orderDCM_mod_bwd.mat
andDCM_mod_fwd.mat
. -
Inference method
- choose “Fixed effects (FFX)”.
-
-
Press Run (the green triangle in the Batch Editor).
The Graphics window now shows a bar plot of the model evidence. You can see that our second model is better than the first one.
Review the parameters of the winning model¶
Once this is completed, you can review the results as follows:
-
Press the DCM button.
-
Choose review.
-
Select
DCM_mod_bwd.mat
By clicking “review…” you can now select from multiple options, e.g. you can revisit the fit of the model (“Outputs”) or look at the parameter estimates for the endogenous coupling (“Intrinsic connections”) or for the parameters associated with the driving or modulatory inputs (“Effects of Photic”, “Effects of Motion”, “Effects of Attention”).
Of course, you can also explore the model results using the MATLAB command line by loading the model and inspecting the parameter estimates directly. These can be found in DCM.Ep.A
(endogenous coupling), DCM.Ep.B
(modulatory inputs) and DCM.Ep.C
(driving inputs).