Visualizing a probabilistic atlas

Visualizing a probabilistic atlas requires visualizing the different maps that compose it.

The tools that we need to leverage are:

  • index_img to retrieve the various maps composing the atlas

  • Adding overlays on an existing brain display, to plot each of these maps

Alternatively, plot_prob_atlas allows to plot the maps in one step that with less control over the plot (see below).

dataset

Here we represent the nodes constituting the default mode network using the MSDL atlas.

Fetching Probabilistic atlas - MSDL atlas

from nilearn import datasets

atlas_data = datasets.fetch_atlas_msdl()
[fetch_atlas_msdl] Dataset directory found: /home/runner/work/nilearn/nilearn/nilearn_data/msdl_atlas
{'type': <class 'str'>, 'desc': 'Full path to nifti file containing the :term:`Probabilistic atlas` image (shape is equal to ``(40, 48, 35, 39)``).'}

Visualizing a probabilistic atlas with plot_stat_map and add_overlay object

from nilearn import image, plotting

# First plot the map for the PCC: index 4 in the atlas
display = plotting.plot_stat_map(
    image.index_img(atlas_data.maps, 4),
    colorbar=False,
    title="DMN nodes in MSDL atlas",
    cmap="inferno",
)

# Now add as an overlay the maps for the ACC and the left and right
# parietal nodes
cmaps = [
    plotting.cm.black_blue,
    plotting.cm.black_green,
    plotting.cm.black_pink,
]
for index, cmap in zip([5, 6, 3], cmaps, strict=False):
    display.add_overlay(image.index_img(atlas_data.maps, index), cmap=cmap)

plotting.show()
plot overlay

Visualizing a probabilistic atlas with plot_prob_atlas

Alternatively, we can create a new 4D-image by selecting the 3rd, 4th, 5th and 6th (zero-based) probabilistic map from atlas via index_img and use plot_prob_atlas (added in version 0.2) to plot the selected nodes in one step.

Unlike plot_stat_map this works with 4D images

dmn_nodes = image.index_img(atlas_data.maps, [3, 4, 5, 6])
# Note that dmn_node is now a 4D image
print(dmn_nodes.shape)
(40, 48, 35, 4)
display = plotting.plot_prob_atlas(
    dmn_nodes, cut_coords=(0, -55, 29), title="DMN nodes in MSDL atlas"
)
plotting.show()
plot overlay

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

Estimated memory usage: 276 MB

Gallery generated by Sphinx-Gallery