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.
We start by selecting an atlas and the Julich-Brain parcellation.
import siibra
atlas = siibra.atlases.MULTILEVEL_HUMAN_ATLAS
jubrain = atlas.get_parcellation('julich 2.9')
As in the previous example, we extract all receptor density features linked to Julich-Brain.
fingerprints = siibra.features.get(jubrain, 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 jubrain
for c in r.leaves
}
Now colorize the Julich-Brain maximum probability map and plot it.
colorized_map = jubrain.get_map(space='mni152').colorize(mapping)
from nilearn import plotting
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/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 7602176 of 8456534 bytes (89.9%, 0.1s remaining) ...done. (3 seconds, 0 min)
Extracting data from /home/runner/nilearn_data/fsaverage6/18247b5dc31f58a90fcbddb5d0911cea/download..... done.