3.3. Extracting resting-state networks with ICA

Page summary

This page demonstrates the use of multi-subject Independent Component Analysis (ICA) of resting-state fMRI data to extract brain networks in an data-driven way. Here we use the ‘CanICA’ approach, that implements a multivariate random effects model across subjects.

References

  • G. Varoquaux et al. “A group model for stable multi-subject ICA on fMRI datasets”, NeuroImage Vol 51 (2010), p. 288-299

3.3.1. Data preparation: retrieving example data

We will use sample data from the ADHD 200 resting-state dataset has been preprocessed using CPAC. We use nilearn functions to fetch data from Internet and get the filenames (more on data loading):

from nilearn import datasets

adhd_dataset = datasets.fetch_adhd()
func_filenames = adhd_dataset.func  # list of 4D nifti files for each subject

# print basic information on the dataset
print('First functional nifti image (4D) is at: %s' %
      adhd_dataset.func[0])  # 4D data

3.3.2. Applying CanICA

CanICA is a ready-to-use object that can be applied to multi-subject Nifti data, for instance presented as filenames, and will perform a multi-subject ICA decomposition following the CanICA model. As with every object in nilearn, we give its parameters at construction, and then fit it on the data.

from nilearn.decomposition.canica import CanICA

n_components = 20
canica = CanICA(n_components=n_components, smoothing_fwhm=6.,
                memory="nilearn_cache", memory_level=5,
                threshold=3., verbose=10, random_state=0)
canica.fit(func_filenames)

# Retrieve the independent components in brain space
components_img = canica.masker_.inverse_transform(canica.components_)
# components_img is a Nifti Image object, and can be saved to a file with
# the following line:
components_img.to_filename('canica_resting_state.nii.gz')

The components estimated are found as the components_ attribute of the object.

3.3.3. Visualizing the results

We can visualize the components as in the previous examples. The first plot shows a map generated from all the components. Then we plot an axial cut for each component separately.

import matplotlib.pyplot as plt
from nilearn.plotting import plot_prob_atlas
from nilearn.plotting import plot_stat_map
from nilearn.image import iter_img

# Plot all ICA components together
plot_prob_atlas(components_img, title='All ICA components')

# Plot the map for each ICA component separately
for i, cur_img in enumerate(iter_img(components_img)):
    plot_stat_map(cur_img, display_mode="z", title="IC %d" % i, cut_coords=1,
                  colorbar=False)

plt.show()
../_images/plot_canica_resting_state_0011.png

left_img right_img

See also

The full code can be found as an example: Group analysis of resting-state fMRI with ICA: CanICA

Note

Note that as the ICA components are not ordered, the two components displayed on your computer might not match those of the documentation. For a fair representation, you should display all components and investigate which one resemble those displayed above.