9.1.4. A introduction tutorial to fMRI decoding¶
Here is a simple tutorial on decoding with nilearn. It reproduces the Haxby 2001 study on a face vs cat discrimination task in a mask of the ventral stream.
J.V. Haxby et al. “Distributed and Overlapping Representations of Faces and Objects in Ventral Temporal Cortex”, Science vol 293 (2001), p 2425.-2430.
This tutorial is meant as an introduction to the various steps of a decoding
analysis using Nilearn meta-estimator:
It is not a minimalistic example, as it strives to be didactic. It is not meant to be copied to analyze new data: many of the steps are unnecessary.
188.8.131.52.1. First download the data¶
nilearn.datasets.fetch_haxby function will download the
Haxby dataset if not present on the disk, in the nilearn data directory.
It can take a while to download about 310 Mo of data from the Internet.
from nilearn import datasets # By default 2nd subject will be fetched haxby_dataset = datasets.fetch_haxby() # 'func' is a list of filenames: one for each subject fmri_filename = haxby_dataset.func # print basic information on the dataset print('First subject functional nifti images (4D) are at: %s' % fmri_filename) # 4D data
First subject functional nifti images (4D) are at: /home/nicolas/nilearn_data/haxby2001/subj2/bold.nii.gz
184.108.40.206.2. Visualizing the fmri volume¶
Because fmri data are 4D (they consist of many 3D EPI images), we cannot
plot them directly using
nilearn.plotting.plot_epi (which accepts
just 3D input). Here we are using
extract a single 3D EPI image from the fmri data.