Single-subject data (two runs) in native space

The example shows the analysis of an SPM dataset, with two conditions: viewing a face image or a scrambled face image.

This example takes a lot of time because the input are lists of 3D images sampled in different positions (encoded by different affine functions).

See also

For more information see the dataset description.

Fetch and inspect the data

Fetch the SPM multimodal_faces data.

[fetch_spm_multimodal_fmri] Dataset created in
/home/runner/nilearn_data/spm_multimodal_fmri
[fetch_spm_multimodal_fmri] Missing 390 functional scans for session 1.
[fetch_spm_multimodal_fmri] Data absent, downloading...
[fetch_spm_multimodal_fmri] Downloading data from
https://www.fil.ion.ucl.ac.uk/spm/download/data/mmfaces/multimodal_fmri.zip ...
[fetch_spm_multimodal_fmri] Downloaded 950272 of 134263085 bytes (0.7%%,  2.4min
remaining)
[fetch_spm_multimodal_fmri] Downloaded 1638400 of 134263085 bytes (1.2%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 2260992 of 134263085 bytes (1.7%%,
3.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 2867200 of 134263085 bytes (2.1%%,
3.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 3538944 of 134263085 bytes (2.6%%,
3.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 4128768 of 134263085 bytes (3.1%%,
3.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 4644864 of 134263085 bytes (3.5%%,
3.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 5193728 of 134263085 bytes (3.9%%,
3.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 5832704 of 134263085 bytes (4.3%%,
3.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 6561792 of 134263085 bytes (4.9%%,
3.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 7364608 of 134263085 bytes (5.5%%,
3.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 8028160 of 134263085 bytes (6.0%%,
3.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 8626176 of 134263085 bytes (6.4%%,
3.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 9109504 of 134263085 bytes (6.8%%,
3.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 9412608 of 134263085 bytes (7.0%%,
3.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 9699328 of 134263085 bytes (7.2%%,
3.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 10035200 of 134263085 bytes (7.5%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 10452992 of 134263085 bytes (7.8%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 10969088 of 134263085 bytes (8.2%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 11452416 of 134263085 bytes (8.5%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 11984896 of 134263085 bytes (8.9%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 12582912 of 134263085 bytes (9.4%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 13279232 of 134263085 bytes (9.9%%,
3.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 14065664 of 134263085 bytes (10.5%%,
3.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 14934016 of 134263085 bytes (11.1%%,
3.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 15917056 of 134263085 bytes (11.9%%,
3.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 17006592 of 134263085 bytes (12.7%%,
3.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 18169856 of 134263085 bytes (13.5%%,
3.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 19013632 of 134263085 bytes (14.2%%,
3.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 19718144 of 134263085 bytes (14.7%%,
3.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 20299776 of 134263085 bytes (15.1%%,
3.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 20930560 of 134263085 bytes (15.6%%,
2.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 21626880 of 134263085 bytes (16.1%%,
2.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 22274048 of 134263085 bytes (16.6%%,
2.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 23011328 of 134263085 bytes (17.1%%,
2.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 23650304 of 134263085 bytes (17.6%%,
2.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 24363008 of 134263085 bytes (18.1%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 24936448 of 134263085 bytes (18.6%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 25575424 of 134263085 bytes (19.0%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 26304512 of 134263085 bytes (19.6%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 27131904 of 134263085 bytes (20.2%%,
2.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 27901952 of 134263085 bytes (20.8%%,
2.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 28721152 of 134263085 bytes (21.4%%,
2.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 29532160 of 134263085 bytes (22.0%%,
2.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 30310400 of 134263085 bytes (22.6%%,
2.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 31203328 of 134263085 bytes (23.2%%,
2.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 32088064 of 134263085 bytes (23.9%%,
2.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 33054720 of 134263085 bytes (24.6%%,
2.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 33939456 of 134263085 bytes (25.3%%,
2.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 34897920 of 134263085 bytes (26.0%%,
2.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 35897344 of 134263085 bytes (26.7%%,
2.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 36732928 of 134263085 bytes (27.4%%,
2.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 37265408 of 134263085 bytes (27.8%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 37830656 of 134263085 bytes (28.2%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 38354944 of 134263085 bytes (28.6%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 38756352 of 134263085 bytes (28.9%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 39231488 of 134263085 bytes (29.2%%,
2.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 39682048 of 134263085 bytes (29.6%%,
2.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 40198144 of 134263085 bytes (29.9%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 40755200 of 134263085 bytes (30.4%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 41410560 of 134263085 bytes (30.8%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 42131456 of 134263085 bytes (31.4%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 42713088 of 134263085 bytes (31.8%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 43188224 of 134263085 bytes (32.2%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 43630592 of 134263085 bytes (32.5%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 44146688 of 134263085 bytes (32.9%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 44744704 of 134263085 bytes (33.3%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 45457408 of 134263085 bytes (33.9%%,
2.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 46260224 of 134263085 bytes (34.5%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 46948352 of 134263085 bytes (35.0%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 47595520 of 134263085 bytes (35.4%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 48160768 of 134263085 bytes (35.9%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 48693248 of 134263085 bytes (36.3%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 49299456 of 134263085 bytes (36.7%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 49995776 of 134263085 bytes (37.2%%,
2.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 50782208 of 134263085 bytes (37.8%%,
2.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 51650560 of 134263085 bytes (38.5%%,
2.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 52649984 of 134263085 bytes (39.2%%,
2.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 53723136 of 134263085 bytes (40.0%%,
2.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 54747136 of 134263085 bytes (40.8%%,
2.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 55779328 of 134263085 bytes (41.5%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 56688640 of 134263085 bytes (42.2%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 57597952 of 134263085 bytes (42.9%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 58245120 of 134263085 bytes (43.4%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 58720256 of 134263085 bytes (43.7%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 59170816 of 134263085 bytes (44.1%%,
1.9min remaining)
[fetch_spm_multimodal_fmri] Downloaded 59629568 of 134263085 bytes (44.4%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 60022784 of 134263085 bytes (44.7%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 60506112 of 134263085 bytes (45.1%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 61087744 of 134263085 bytes (45.5%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 61767680 of 134263085 bytes (46.0%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 62529536 of 134263085 bytes (46.6%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 63234048 of 134263085 bytes (47.1%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 64012288 of 134263085 bytes (47.7%%,
1.8min remaining)
[fetch_spm_multimodal_fmri] Downloaded 64839680 of 134263085 bytes (48.3%%,
1.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 65699840 of 134263085 bytes (48.9%%,
1.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 66650112 of 134263085 bytes (49.6%%,
1.7min remaining)
[fetch_spm_multimodal_fmri] Downloaded 67698688 of 134263085 bytes (50.4%%,
1.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 68845568 of 134263085 bytes (51.3%%,
1.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 69869568 of 134263085 bytes (52.0%%,
1.6min remaining)
[fetch_spm_multimodal_fmri] Downloaded 70688768 of 134263085 bytes (52.6%%,
1.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 71540736 of 134263085 bytes (53.3%%,
1.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 72409088 of 134263085 bytes (53.9%%,
1.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 73179136 of 134263085 bytes (54.5%%,
1.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 73940992 of 134263085 bytes (55.1%%,
1.5min remaining)
[fetch_spm_multimodal_fmri] Downloaded 74506240 of 134263085 bytes (55.5%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 75104256 of 134263085 bytes (55.9%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 75669504 of 134263085 bytes (56.4%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 76283904 of 134263085 bytes (56.8%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 76963840 of 134263085 bytes (57.3%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 77692928 of 134263085 bytes (57.9%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 78471168 of 134263085 bytes (58.4%%,
1.4min remaining)
[fetch_spm_multimodal_fmri] Downloaded 79003648 of 134263085 bytes (58.8%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 79560704 of 134263085 bytes (59.3%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 80199680 of 134263085 bytes (59.7%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 80920576 of 134263085 bytes (60.3%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 81477632 of 134263085 bytes (60.7%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 81960960 of 134263085 bytes (61.0%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 82403328 of 134263085 bytes (61.4%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 82935808 of 134263085 bytes (61.8%%,
1.3min remaining)
[fetch_spm_multimodal_fmri] Downloaded 83525632 of 134263085 bytes (62.2%%,
1.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 84221952 of 134263085 bytes (62.7%%,
1.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 85008384 of 134263085 bytes (63.3%%,
1.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 85893120 of 134263085 bytes (64.0%%,
1.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 86876160 of 134263085 bytes (64.7%%,
1.2min remaining)
[fetch_spm_multimodal_fmri] Downloaded 87990272 of 134263085 bytes (65.5%%,
1.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 89522176 of 134263085 bytes (66.7%%,
1.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 90447872 of 134263085 bytes (67.4%%,
1.1min remaining)
[fetch_spm_multimodal_fmri] Downloaded 91078656 of 134263085 bytes (67.8%%,
1.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 91734016 of 134263085 bytes (68.3%%,
1.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 92446720 of 134263085 bytes (68.9%%,
1.0min remaining)
[fetch_spm_multimodal_fmri] Downloaded 93265920 of 134263085 bytes (69.5%%,
59.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 93945856 of 134263085 bytes (70.0%%,
58.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 94748672 of 134263085 bytes (70.6%%,
57.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 95608832 of 134263085 bytes (71.2%%,
55.7s remaining)
[fetch_spm_multimodal_fmri] Downloaded 96509952 of 134263085 bytes (71.9%%,
54.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 97386496 of 134263085 bytes (72.5%%,
52.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 98074624 of 134263085 bytes (73.0%%,
51.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 98680832 of 134263085 bytes (73.5%%,
51.1s remaining)
[fetch_spm_multimodal_fmri] Downloaded 99229696 of 134263085 bytes (73.9%%,
50.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 99819520 of 134263085 bytes (74.3%%,
49.6s remaining)
[fetch_spm_multimodal_fmri] Downloaded 100376576 of 134263085 bytes (74.8%%,
48.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 101023744 of 134263085 bytes (75.2%%,
48.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 101466112 of 134263085 bytes (75.6%%,
47.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 101761024 of 134263085 bytes (75.8%%,
47.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 102137856 of 134263085 bytes (76.1%%,
46.8s remaining)
[fetch_spm_multimodal_fmri] Downloaded 102555648 of 134263085 bytes (76.4%%,
46.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 102965248 of 134263085 bytes (76.7%%,
45.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 103350272 of 134263085 bytes (77.0%%,
45.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 103800832 of 134263085 bytes (77.3%%,
44.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 104300544 of 134263085 bytes (77.7%%,
44.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 104808448 of 134263085 bytes (78.1%%,
43.6s remaining)
[fetch_spm_multimodal_fmri] Downloaded 105390080 of 134263085 bytes (78.5%%,
42.8s remaining)
[fetch_spm_multimodal_fmri] Downloaded 105979904 of 134263085 bytes (78.9%%,
41.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 106561536 of 134263085 bytes (79.4%%,
41.1s remaining)
[fetch_spm_multimodal_fmri] Downloaded 107216896 of 134263085 bytes (79.9%%,
40.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 107880448 of 134263085 bytes (80.4%%,
39.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 108388352 of 134263085 bytes (80.7%%,
38.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 108937216 of 134263085 bytes (81.1%%,
37.7s remaining)
[fetch_spm_multimodal_fmri] Downloaded 109559808 of 134263085 bytes (81.6%%,
36.8s remaining)
[fetch_spm_multimodal_fmri] Downloaded 110116864 of 134263085 bytes (82.0%%,
36.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 110698496 of 134263085 bytes (82.4%%,
35.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 111263744 of 134263085 bytes (82.9%%,
34.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 111845376 of 134263085 bytes (83.3%%,
33.6s remaining)
[fetch_spm_multimodal_fmri] Downloaded 112541696 of 134263085 bytes (83.8%%,
32.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 113311744 of 134263085 bytes (84.4%%,
31.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 114040832 of 134263085 bytes (84.9%%,
30.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 114827264 of 134263085 bytes (85.5%%,
29.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 115679232 of 134263085 bytes (86.2%%,
27.7s remaining)
[fetch_spm_multimodal_fmri] Downloaded 116383744 of 134263085 bytes (86.7%%,
26.7s remaining)
[fetch_spm_multimodal_fmri] Downloaded 117194752 of 134263085 bytes (87.3%%,
25.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 117874688 of 134263085 bytes (87.8%%,
24.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 118571008 of 134263085 bytes (88.3%%,
23.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 119357440 of 134263085 bytes (88.9%%,
22.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 120242176 of 134263085 bytes (89.6%%,
20.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 121159680 of 134263085 bytes (90.2%%,
19.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 122011648 of 134263085 bytes (90.9%%,
18.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 122568704 of 134263085 bytes (91.3%%,
17.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 122888192 of 134263085 bytes (91.5%%,
16.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 123224064 of 134263085 bytes (91.8%%,
16.5s remaining)
[fetch_spm_multimodal_fmri] Downloaded 123666432 of 134263085 bytes (92.1%%,
15.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 124198912 of 134263085 bytes (92.5%%,
15.1s remaining)
[fetch_spm_multimodal_fmri] Downloaded 124829696 of 134263085 bytes (93.0%%,
14.1s remaining)
[fetch_spm_multimodal_fmri] Downloaded 125558784 of 134263085 bytes (93.5%%,
13.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 126377984 of 134263085 bytes (94.1%%,
11.8s remaining)
[fetch_spm_multimodal_fmri] Downloaded 127385600 of 134263085 bytes (94.9%%,
10.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 128106496 of 134263085 bytes (95.4%%,
9.2s remaining)
[fetch_spm_multimodal_fmri] Downloaded 128679936 of 134263085 bytes (95.8%%,
8.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 129318912 of 134263085 bytes (96.3%%,
7.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 130056192 of 134263085 bytes (96.9%%,
6.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 130703360 of 134263085 bytes (97.3%%,
5.3s remaining)
[fetch_spm_multimodal_fmri] Downloaded 131317760 of 134263085 bytes (97.8%%,
4.4s remaining)
[fetch_spm_multimodal_fmri] Downloaded 131833856 of 134263085 bytes (98.2%%,
3.6s remaining)
[fetch_spm_multimodal_fmri] Downloaded 132325376 of 134263085 bytes (98.6%%,
2.9s remaining)
[fetch_spm_multimodal_fmri] Downloaded 132907008 of 134263085 bytes (99.0%%,
2.0s remaining)
[fetch_spm_multimodal_fmri] Downloaded 133603328 of 134263085 bytes (99.5%%,
1.0s remaining)
[fetch_spm_multimodal_fmri]  ...done. (202 seconds, 3 min)

[fetch_spm_multimodal_fmri] Extracting data from
/home/runner/nilearn_data/spm_multimodal_fmri/sub001/multimodal_fmri.zip...
[fetch_spm_multimodal_fmri] .. done.

[fetch_spm_multimodal_fmri] Downloading data from
https://www.fil.ion.ucl.ac.uk/spm/download/data/mmfaces/multimodal_smri.zip ...
[fetch_spm_multimodal_fmri] Downloaded 3063808 of 6852766 bytes (44.7%%,    1.3s
remaining)
[fetch_spm_multimodal_fmri] Downloaded 5873664 of 6852766 bytes (85.7%%,    0.3s
remaining)
[fetch_spm_multimodal_fmri]  ...done. (3 seconds, 0 min)

[fetch_spm_multimodal_fmri] Extracting data from
/home/runner/nilearn_data/spm_multimodal_fmri/sub001/multimodal_smri.zip...
[fetch_spm_multimodal_fmri] .. done.

Let’s inspect one of the event files before using them.

import pandas as pd

events = [subject_data.events1, subject_data.events2]

events_dataframe = pd.read_csv(events[0], sep="\t")
events_dataframe["trial_type"].value_counts()
trial_type
scrambled    86
faces        64
Name: count, dtype: int64

We can confirm there are only 2 conditions in the dataset.

from nilearn.plotting import plot_event, show

plot_event(events)

show()
plot spm multimodal faces
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:41: UserWarning: You are using the 'agg' matplotlib backend that is non-interactive.
No figure will be plotted when calling matplotlib.pyplot.show() or nilearn.plotting.show().
You can fix this by installing a different backend: for example via
        pip install PyQt6
  show()

Resample the images: this is achieved by the concat_imgs function of Nilearn.

import warnings

from nilearn.image import concat_imgs, mean_img, resample_img

# Avoid getting too many warnings due to resampling
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fmri_img = [
        concat_imgs(subject_data.func1, auto_resample=True),
        concat_imgs(subject_data.func2, auto_resample=True),
    ]
affine, shape = fmri_img[0].affine, fmri_img[0].shape
print("Resampling the second image (this takes time)...")
fmri_img[1] = resample_img(fmri_img[1], affine, shape[:3])
Resampling the second image (this takes time)...

Let’s create mean image for display purposes.

Fit the model

Fit the GLM for the 2 runs by specifying a FirstLevelModel and then fitting it.

# Sample at the beginning of each acquisition.
slice_time_ref = 0.0
# We use a discrete cosine transform to model signal drifts.
drift_model = "cosine"
# The cutoff for the drift model is 0.01 Hz.
high_pass = 0.01
# The hemodynamic response function
hrf_model = "spm + derivative"

from nilearn.glm.first_level import FirstLevelModel

print("Fitting a GLM")
fmri_glm = FirstLevelModel(
    smoothing_fwhm=None,
    t_r=subject_data.t_r,
    hrf_model=hrf_model,
    drift_model=drift_model,
    high_pass=high_pass,
    verbose=1,
)


fmri_glm = fmri_glm.fit(fmri_img, events=events)
Fitting a GLM
[FirstLevelModel.fit] Loading data from <nibabel.nifti1.Nifti1Image object at
0x7f0fc0a70670>
[FirstLevelModel.fit] Computing mask
[FirstLevelModel.fit] Resampling mask
[FirstLevelModel.fit] Finished fit
[FirstLevelModel.fit] Computing run 1 out of 2 runs (go take a coffee, a big
one).
[FirstLevelModel.fit] Performing mask computation.
[FirstLevelModel.fit] Loading data from <nibabel.nifti1.Nifti1Image object at
0x7f0fc0a70670>
[FirstLevelModel.fit] Extracting region signals
[FirstLevelModel.fit] Cleaning extracted signals
[FirstLevelModel.fit] Masking took 1 seconds.
[FirstLevelModel.fit] Performing GLM computation.
[FirstLevelModel.fit] GLM took 1 seconds.
[FirstLevelModel.fit] Computing run 2 out of 2 runs (2 seconds remaining).
[FirstLevelModel.fit] Performing mask computation.
[FirstLevelModel.fit] Loading data from <nibabel.nifti1.Nifti1Image object at
0x7f0fe8009060>
[FirstLevelModel.fit] Extracting region signals
[FirstLevelModel.fit] Cleaning extracted signals
[FirstLevelModel.fit] Masking took 1 seconds.
[FirstLevelModel.fit] Performing GLM computation.
[FirstLevelModel.fit] GLM took 1 seconds.
[FirstLevelModel.fit] Computation of 2 runs done in 5 seconds.

View the results

Now we can compute contrast-related statistical maps (in z-scale), and plot them.

from nilearn.plotting import plot_stat_map

print("Computing contrasts")
Computing contrasts

We actually want more interesting contrasts. The simplest contrast just makes the difference between the two main conditions. We define the two opposite versions to run one-tailed t-tests.

contrasts = ["faces - scrambled", "scrambled - faces"]

Let’s store common parameters for all plots.

We plot the contrasts values overlaid on the mean fMRI image and we will use the z-score values as transparency, with any voxel with | Z-score | > 3 being fully opaque and any voxel with 0 < | Z-score | < 1.96 being partly transparent.

plot_param = {
    "vmin": 0,
    "display_mode": "z",
    "cut_coords": 3,
    "black_bg": True,
    "bg_img": mean_image,
    "cmap": "inferno",
    "transparency_range": [0, 3],
}

# Iterate on contrasts to compute and plot them.
for contrast_id in contrasts:
    print(f"\tcontrast id: {contrast_id}")

    results = fmri_glm.compute_contrast(contrast_id, output_type="all")

    plot_stat_map(
        results["stat"],
        title=contrast_id,
        transparency=results["z_score"],
        **plot_param,
    )
  • plot spm multimodal faces
  • plot spm multimodal faces
        contrast id: faces - scrambled
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:134: RuntimeWarning: The same contrast will be used for all 2 runs. If the design matrices are not the same for all runs, (for example with different column names or column order across runs) you should pass contrast as an expression using the name of the conditions as they appear in the design matrices.
  results = fmri_glm.compute_contrast(contrast_id, output_type="all")
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
        contrast id: scrambled - faces
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:134: RuntimeWarning: The same contrast will be used for all 2 runs. If the design matrices are not the same for all runs, (for example with different column names or column order across runs) you should pass contrast as an expression using the name of the conditions as they appear in the design matrices.
  results = fmri_glm.compute_contrast(contrast_id, output_type="all")
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals

We also define the effects of interest contrast, a 2-dimensional contrasts spanning the two conditions.

import numpy as np

contrasts = np.eye(2)

results = fmri_glm.compute_contrast(contrasts, output_type="all")

plot_stat_map(
    results["stat"],
    title="effects of interest",
    transparency=results["z_score"],
    **plot_param,
)

show()
plot spm multimodal faces
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:151: RuntimeWarning: The same contrast will be used for all 2 runs. If the design matrices are not the same for all runs, (for example with different column names or column order across runs) you should pass contrast as an expression using the name of the conditions as they appear in the design matrices.
  results = fmri_glm.compute_contrast(contrasts, output_type="all")
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:151: UserWarning: F contrasts should have 20 columns, but it has only 2. The rest of the contrast was padded with zeros.
  results = fmri_glm.compute_contrast(contrasts, output_type="all")
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:151: UserWarning: Running approximate fixed effects on F statistics.
  results = fmri_glm.compute_contrast(contrasts, output_type="all")
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
[FirstLevelModel.compute_contrast] Computing image from signals
/home/runner/work/nilearn/nilearn/examples/04_glm_first_level/plot_spm_multimodal_faces.py:160: UserWarning: You are using the 'agg' matplotlib backend that is non-interactive.
No figure will be plotted when calling matplotlib.pyplot.show() or nilearn.plotting.show().
You can fix this by installing a different backend: for example via
        pip install PyQt6
  show()

Based on the resulting maps we observe that the analysis results in wide activity for the ‘effects of interest’ contrast, showing the implications of large portions of the visual cortex in the conditions. By contrast, the differential effect between “faces” and “scrambled” involves sparser, more anterior and lateral regions. It also displays some responses in the frontal lobe.

Total running time of the script: (4 minutes 32.238 seconds)

Estimated memory usage: 968 MB

Gallery generated by Sphinx-Gallery