Note
Go to the end to download the full example code.
Colorizing a map with neurotransmitter receptor densities
Parcellation maps can be colorized with a dictionary of values. This is useful to visualize data features in 3D space. Here we demonstrate it for average densities of the GABAA receptor.
from nilearn import plotting
import siibra
# We start by selecting an atlas and the Julich-Brain parcellation.
atlas = siibra.atlases.MULTILEVEL_HUMAN_ATLAS
julich_brain = atlas.get_parcellation('julich 3')
As in the previous example, we extract all receptor density features linked to Julich-Brain.
fingerprints = siibra.features.get(julich_brain, siibra.features.molecular.ReceptorDensityFingerprint)
fingerprints[0].data
Colorizing a map requires a dictionary that maps region objects to scalar values. We build a dictionary mapping Julich-Brain regions to average receptor densities measured for GABAA. Note: For each receptor fingerprint, from the regions it is anchored to, we consider those that belong to the julich brain atlas, and store the mean receptor density for each of their leaf nodes.
receptor = 'GABAA'
mapping = {
c: fp.data['mean'][receptor]
for fp in fingerprints if receptor in fp.receptors
for r in fp.anchor.regions
if r in julich_brain
for c in r.leaves
}
Now colorize the Julich-Brain maximum probability map and plot it.
colorized_map = julich_brain.get_map(space='mni152').colorize(mapping).fetch()
plotting.view_img(
colorized_map, cmap='magma',
title=f"Average densities available for {receptor}", symmetric_cmap=False
)
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nilearn/image/resampling.py:492: UserWarning: The provided image has no sform in its header. Please check the provided file. Results may not be as expected.
warnings.warn(
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/numpy/core/fromnumeric.py:784: UserWarning: Warning: 'partition' will ignore the 'mask' of the MaskedArray.
a.partition(kth, axis=axis, kind=kind, order=order)
Alternatively, we can display this map on a surface mesh using nilearn. Note that, you can switch between the hemispheres or variants (inflated or pial) from the plot itself.
plotting.view_img_on_surf(colorized_map, cmap='magma', symmetric_cmap=False, surf_mesh="fsaverage6")
Added README.md to /home/runner/nilearn_data
Dataset created in /home/runner/nilearn_data/fsaverage6
Downloading data from https://osf.io/jzxyr/download ...
Downloaded 8118272 of 8456534 bytes (96.0%, 0.0s remaining) ...done. (3 seconds, 0 min)
Extracting data from /home/runner/nilearn_data/fsaverage6/18247b5dc31f58a90fcbddb5d0911cea/download..... done.