Skip to content

Commit 00e5ecf

Browse files
committed
Documentation: Added BSc student documentation on an example 2nd-level analyses
1 parent 7845aee commit 00e5ecf

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Second-level analysis example
2+
The material here is for students doing the **CLNE0068: Research Methods and Data Analysis in Human Neuroscience** course at UCL.
3+
4+
First of all, create a folder to save your results into.
5+
Then start MATLAB and type
6+
```matlab
7+
spm fmri
8+
```
9+
10+
## Loading participant information
11+
12+
Age and sex of the participants is stored in a spreadsheet.
13+
You can load this information into MATLAB by typing the following:
14+
```matlab
15+
filename = 'S:\FBS_CLNE0068\Data\Faces\Subject_details.xlsx';
16+
contents = readmatrix(filename,'OutputType','string')
17+
subjects = contents(:,1); % Participants
18+
age = str2double(contents(:,2)); % Convert text into numbers
19+
sex = double(contents(:,3)=="F"); % One denotes female, zero denotes male
20+
```
21+
22+
This gives `age` and `sex` variables in the MATLAB workspace that can be entered into a design matrix.
23+
24+
25+
## Specify 2nd-level
26+
Press the `Specify 2nd-level` button on the "Menu" window to get a `Factorial design specification` job in the batch editor.
27+
Modify the design so it looks like the following
28+
```matlab
29+
Directory [specify the directory you created]
30+
Design
31+
. Multiple regression
32+
. . Scans [select the 1st-leve contrast images]
33+
. . Covariates
34+
. . . Covariate
35+
. . . . Vector [enter the age variable]
36+
. . . . Name age
37+
. . . . Centering Overall mean
38+
. . . Covariate
39+
. . . . Vector [enter the sex variable]
40+
. . . . Name sex
41+
. . . . Centering Overall mean
42+
. . Intercept Include Intercept
43+
Covariates
44+
Multiple covariates
45+
Masking
46+
. Threshold masking
47+
. . None
48+
. Implicit mask Yes
49+
. Explicit mask
50+
Global calculation
51+
. Omit
52+
Global normalisation
53+
. Overall grand mean scaling
54+
. . No
55+
. Normalisation None
56+
```
57+
You can save this as `second_level_spec_job.m` and click the green run button (unless you've forgotten anything) to save the specification.
58+
59+
Once this has finished, you can `Review` the model if you like, and then press the `Estimate` button on the "Menu" window.
60+
Select the `SPM.mat` file that has just been created and press the green run button.
61+
Wait a little while until this finished before going on to looking at the results.
62+
63+
64+
## 2nd-level Results
65+
Press the `Results` button on the "Menu" window and select the `SPM.mat` file in order to open the contrast manager.
66+
there are a few things you could look at from this model.
67+
Remember that the columns of the design matrix correspond with:
68+
69+
1. `mean` - a column of ones to model the mean
70+
2. `age` - the participants' ages (years)
71+
3. `sex` - whether or not the participants are female (1=female, 0=male)
72+
73+
74+
### Main Effect
75+
When the aim is to assess whether the average values in the contrast image are greater than zero, we can simply assess the first beta image, which encodes the mean.
76+
The t contrast vector to do this is
77+
```matlab
78+
1 0 0
79+
```
80+
Note that this is an ANCOVA model because effects of age and sex are covaried out.
81+
82+
### Any age effect
83+
Age is encoded by the second column of the design matrix.
84+
To see both positive and negative age effects, we would need a two-tailed t test.
85+
This can be achieved using an F contrast of
86+
```matlab
87+
0 1 0
88+
```
89+
With data from only 16 participants and three columns in theh design matrix, the statistical analyses have only 13 degrees of freedom.
90+
It may therefore not be very sensitive to age-related effects.
91+
92+
### Any age or sex effect
93+
Now we are intersted in any variance explained by the second and third columns of the design matrix.
94+
This can be done using the following F contrast:
95+
```matlab
96+
0 1 0
97+
0 0 1
98+
```
99+

docs/tutorials/beginners/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232

3333
* [fMRI Overview](fmri/index.md)
3434
* [fMRI Preprocessing](fmri/preprocessing.md)
35-
* [fMRI First Level](fmri/first_level.md)
35+
* [fMRI First-level](fmri/first_level.md)
36+
* [fMRI Second-level Example](fmri/second_level_example.md)
3637

mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ nav:
8484
- 'Statistical Tests': 'tutorials/beginners/linear_model.md'
8585
- 'Haemodynamic Modelling': 'tutorials/beginners/haemodynamic_modelling.md'
8686
- 'fMRI analysis':
87-
- 'Overview': 'tutorials/beginners/fmri/index.md'
87+
- 'Overview': 'tutorials/beginners/fmri/index.md'
8888
- 'Preprocessing': 'tutorials/beginners/fmri/preprocessing.md'
89-
- 'First-level': 'tutorials/beginners/fmri/first_level.md'
89+
- 'First-level': 'tutorials/beginners/fmri/first_level.md'
90+
- 'Second-level': 'tutorials/beginners/fmri/second_level_example.md'
9091
- 'fMRI':
9192
- 'tutorials/fmri/index.md'
9293
- 'Block design fMRI':

0 commit comments

Comments
 (0)