Note
Go to the end to download the full example code.
Intermediate
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.
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)
plotting.view_img(
colorized_map, cmap='magma',
title=f"Average densities available for {receptor}", symmetric_cmap=False
)
[NiftiLabelsMasker.fit] Loading regions from <nibabel.nifti1.Nifti1Image object at 0x7f8f19d800d0>
[NiftiLabelsMasker.fit] Finished fit
[NiftiLabelsMasker.inverse_transform] Computing image from signals
/actions-runner/_work/siibra-python/siibra-python/.ci-docs-38406885610-1-notebooks/venv/lib/python3.11/site-packages/numpy/_core/fromnumeric.py:840: 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)
Total running time of the script: (0 minutes 34.618 seconds)
Estimated memory usage: 331 MB