Visualizing 4D probabilistic atlas maps#

This example shows how to visualize probabilistic atlases made of 4D images. There are 3 different display types:

  1. “contours”, which means maps or ROIs are shown as contours delineated by colored lines.

  2. “filled_contours”, maps are shown as contours same as above but with fillings inside the contours.

  3. “continuous”, maps are shown as just color overlays.

A colorbar can optionally be added.

The nilearn.plotting.plot_prob_atlas function displays each map with each different color which are picked randomly from the colormap which is already defined.

See Plotting brain images for more information to know how to tune the parameters.

Load 4D probabilistic atlases

from nilearn import datasets, plotting

# Allen RSN networks
allen = datasets.fetch_atlas_allen_2011()

# ICBM tissue probability
icbm = datasets.fetch_icbm152_2009()

# Smith ICA BrainMap 2009
smith_bm20 = datasets.fetch_atlas_smith_2009(resting=False, dimension=20)[
    "maps"
]
Dataset created in /home/remi/nilearn_data/allen_rsn_2011

Downloading data from https://osf.io/hrcku/download ...

Downloaded 2064384 of 32347736 bytes (6.4%,   14.7s remaining)
Downloaded 7585792 of 32347736 bytes (23.5%,    6.5s remaining)
Downloaded 12910592 of 32347736 bytes (39.9%,    4.6s remaining)
Downloaded 16826368 of 32347736 bytes (52.0%,    3.7s remaining)
Downloaded 21561344 of 32347736 bytes (66.7%,    2.5s remaining)
Downloaded 26263552 of 32347736 bytes (81.2%,    1.4s remaining)
Downloaded 32030720 of 32347736 bytes (99.0%,    0.1s remaining) ...done. (9 seconds, 0 min)
Extracting data from /home/remi/nilearn_data/allen_rsn_2011/5f8f4a26df3a57a30ddc4285d4d5c6c2/download..... done.

Dataset created in /home/remi/nilearn_data/icbm152_2009

Downloading data from https://osf.io/7pj92/download ...

Downloaded 3989504 of 63027871 bytes (6.3%,   14.8s remaining)
Downloaded 9461760 of 63027871 bytes (15.0%,   11.3s remaining)
Downloaded 14983168 of 63027871 bytes (23.8%,    9.6s remaining)
Downloaded 21307392 of 63027871 bytes (33.8%,    7.8s remaining)
Downloaded 27598848 of 63027871 bytes (43.8%,    6.4s remaining)
Downloaded 33185792 of 63027871 bytes (52.7%,    5.4s remaining)
Downloaded 39411712 of 63027871 bytes (62.5%,    4.2s remaining)
Downloaded 45785088 of 63027871 bytes (72.6%,    3.0s remaining)
Downloaded 52125696 of 63027871 bytes (82.7%,    1.9s remaining)
Downloaded 58236928 of 63027871 bytes (92.4%,    0.8s remaining)
Downloaded 61775872 of 63027871 bytes (98.0%,    0.2s remaining) ...done. (13 seconds, 0 min)
Extracting data from /home/remi/nilearn_data/icbm152_2009/e05b733c275cab0eec856067143c9dc9/download..... done.
Downloading data from https://www.fmrib.ox.ac.uk/datasets/brainmap+rsns/bm20.nii.gz ...

Downloaded 1531904 of 19114114 bytes (8.0%,   11.5s remaining)
Downloaded 3268608 of 19114114 bytes (17.1%,    9.8s remaining)
Downloaded 4808704 of 19114114 bytes (25.2%,    9.0s remaining)
Downloaded 6225920 of 19114114 bytes (32.6%,    8.3s remaining)
Downloaded 7954432 of 19114114 bytes (41.6%,    7.2s remaining)
Downloaded 9625600 of 19114114 bytes (50.4%,    6.0s remaining)
Downloaded 11214848 of 19114114 bytes (58.7%,    5.0s remaining)
Downloaded 12754944 of 19114114 bytes (66.7%,    4.1s remaining)
Downloaded 14376960 of 19114114 bytes (75.2%,    3.0s remaining)
Downloaded 16343040 of 19114114 bytes (85.5%,    1.7s remaining)
Downloaded 18276352 of 19114114 bytes (95.6%,    0.5s remaining) ...done. (12 seconds, 0 min)

Visualization

# "contours" example
plotting.plot_prob_atlas(allen.rsn28, title="Allen2011")

# "continuous" example
plotting.plot_prob_atlas(
    (icbm["wm"], icbm["gm"], icbm["csf"]), title="ICBM tissues"
)

# "filled_contours" example. An optional colorbar can be set.
plotting.plot_prob_atlas(
    smith_bm20,
    title="Smith2009 20 Brainmap (with colorbar)",
    colorbar=True,
)

plotting.show()
  • plot prob atlas
  • plot prob atlas
  • plot prob atlas
/home/remi/github/nilearn/env/lib/python3.11/site-packages/nilearn/plotting/displays/_axes.py:74: UserWarning: linewidths is ignored by contourf
  im = getattr(ax, type)(

Other probabilistic atlases accessible with nilearn#

To save build time, the following code is not executed. Try running it locally to get the same plots as above for each of the listed atlases.

# Harvard Oxford Atlas
harvard_oxford = datasets.fetch_atlas_harvard_oxford("cort-prob-2mm")
harvard_oxford_sub = datasets.fetch_atlas_harvard_oxford("sub-prob-2mm")

# Smith ICA Atlas and Brain Maps 2009
smith_rsn10 = datasets.fetch_atlas_smith_2009(
    resting=True, dimension=10
)["maps"]
smith_rsn20 = datasets.fetch_atlas_smith_2009(
    resting=True, dimension=20
)["maps"]
smith_rsn70 = datasets.fetch_atlas_smith_2009(
    resting=True, dimension=70
)["maps"]
smith_bm10 = datasets.fetch_atlas_smith_2009(
    resting=False, dimension=10
)["maps"]
smith_bm70 = datasets.fetch_atlas_smith_2009(
    resting=False, dimension=70
)["maps"]

# Multi Subject Dictionary Learning Atlas
msdl = datasets.fetch_atlas_msdl()

# Pauli subcortical atlas
subcortex = datasets.fetch_atlas_pauli_2017()

# Dictionaries of Functional Modes (“DiFuMo”) atlas
dim = 64
res = 2
difumo = datasets.fetch_atlas_difumo(
    dimension=dim, resolution_mm=res, legacy_format=False
)

# Visualization
atlas_types = {
    "Harvard_Oxford": harvard_oxford.maps,
    "Harvard_Oxford sub": harvard_oxford_sub.maps,
    "Smith 2009 10 RSNs": smith_rsn10,
    "Smith2009 20 RSNs": smith_rsn20,
    "Smith2009 70 RSNs": smith_rsn70,
    "Smith2009 10 Brainmap": smith_bm10,
    "Smith2009 70 Brainmap": smith_bm70,
    "MSDL": msdl.maps,
    "Pauli2017 Subcortical Atlas": subcortex.maps,
    f"DiFuMo dimension {dim} resolution {res}": difumo.maps,
}

for name, atlas in sorted(atlas_types.items()):
    plotting.plot_prob_atlas(atlas, title=name)

plotting.show()

Total running time of the script: (0 minutes 54.183 seconds)

Estimated memory usage: 342 MB

Gallery generated by Sphinx-Gallery