Adding a custom parcellation map

Sometimes you might want to use a custom parcellation map to perform feature queries in siibra. For this example, we retrieve a freely available AICHA - Atlas of Intrinsic Connectivity of Homotopic Areas (Tzourio-Mazoyer N, Landeau B, Papathanassiou D, Crivello F, Etard O, Delcroix N, Mazoyer B, Joliot M (2002) Automated anatomical labeling of activations in SPM using a macroscopic anatomical parcellation of the MNI MRI single-subject brain. Neuroimage 15:273-289.). This atlas provided in the MNI ICBM 152 space.

import siibra
from nilearn import plotting

Load the custom parcellation map from the online resource. For the retrieval, siibra’s zipfile connector is very helpful. We can use the resulting NIfTI to create a custom parcellation map inside siibra.

# connect to the online zip file
base_url = "https://object.cscs.ch/v1/AUTH_4791e0a3b3de43e2840fe46d9dc2b334/ext-d000069_AICHA_pub/v2.0"

# the NIfTI file is easily retrieved:
nii = siibra.retrieval.requests.HttpRequest(f"{base_url}/AICHA1mm.nii").get()
# and create a volume on space MNI152 (note that this assumes our
# external knowledge that the map is in MNI152 space)
volume = siibra.volumes.from_nifti(nii, 'mni152', "AICHA")

# The text file with label mappings has a custom format. We provide a tsv
# decoder to extract the list of region/label pairs since the txt file is tab
# separated.
volume_info = siibra.retrieval.requests.HttpRequest(f"{base_url}/AICHA1mm_vol3.txt", func=siibra.retrieval.requests.DECODERS['.tsv']).get()
volume_info
nom_c nom_l nom_s color vol_vox vol_mm3 xv yv zv xmm ymm zmm
0 G_Frontal_Sup-1-L G_Frontal_Sup-1-L F1_1_L 1 1012 1012 107 192 86 -15.946640 65.023715 13.068182
1 G_Frontal_Sup-1-R G_Frontal_Sup-1-R F1_1_R 2 129 129 78 195 83 12.558140 67.806202 10.271318
2 G_Frontal_Sup-2-L G_Frontal_Sup-2-L F1_2_L 3 8541 8541 103 174 114 -11.906568 47.021192 41.249034
3 G_Frontal_Sup-2-R G_Frontal_Sup-2-R F1_2_R 4 8773 8773 79 173 115 11.971389 45.788100 41.598199
4 G_Frontal_Sup-3-L G_Frontal_Sup-3-L F1_3_L 5 328 328 111 143 136 -19.814024 16.405488 62.707317
... ... ... ... ... ... ... ... ... ... ... ... ...
379 N_Thalamus-7-R N_Thalamus-7-R THA7_R 380 204 204 82 100 82 8.725490 -26.735294 8.799020
380 N_Thalamus-8-L N_Thalamus-8-L THA8_L 381 316 316 95 101 87 -4.234177 -25.867089 14.107595
381 N_Thalamus-8-R N_Thalamus-8-R THA8_R 382 239 239 88 102 87 3.414226 -25.284519 13.627615
382 N_Thalamus-9-L N_Thalamus-9-L THA9_L 383 2234 2234 96 116 66 -5.167860 -10.663832 -7.366159
383 N_Thalamus-9-R N_Thalamus-9-R THA9_R 384 1787 1787 86 117 67 4.612199 -10.105764 -6.470621

384 rows × 12 columns



Now we can add this map to current configuration:

regionnames = volume_info['nom_l'].tolist()
labels = [int(label) for label in volume_info['color']]
aicha_map = siibra.volumes.parcellationmap.from_volume(
    name="AICHA - Atlas of Intrinsic Connectivity of Homotopic Areas",
    volume=volume,
    regionnames=regionnames,
    regionlabels=labels
)
/home/runner/work/siibra-python/siibra-python/siibra/volumes/parcellationmap.py:1244: RuntimeWarning: invalid value encountered in cast
  labels_in_volume = np.unique(arr)[1:].astype('int')

Let us plot the full map to test

plotting.plot_roi(aicha_map.fetch())
007 adding custom parcellation
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/nilearn/plotting/img_plotting.py:238: UserWarning: Non-finite values detected. These values will be replaced with zeros.
  data = safe_get_data(img, ensure_finite=True)

<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7fadc13ffa00>

Now let’s fetch a specific region

plotting.plot_roi(aicha_map.fetch("G_Fusiform-1-L"))
007 adding custom parcellation
<nilearn.plotting.displays._slicers.OrthoSlicer object at 0x7fad7b326310>

We can already use this map to find spatial features, such as BigBrain intensity profiles, gene expressions, volume of interests, sections…

region = aicha_map.parcellation.get_region('S_Rolando-1-L')
intensity_profiles = siibra.features.get(
    region,
    siibra.features.cellular.BigBrainIntensityProfile
)[0]
print(f"{len(intensity_profiles)} {intensity_profiles.name} found.")
2118 2118 BigBrain Intensity Profile features found.

On the other hand, some features are only anchored to a semantic region object and the link to the custom region is not directly known to siibra. However, siibra circumvents this by comparing volumes of these regions to assign a link between them.

volume = region.get_regional_mask('mni152')
receptor_profiles = siibra.features.get(
    volume,
    siibra.features.molecular.ReceptorDensityFingerprint
)
print(f"{len(receptor_profiles)} {receptor_profiles[0].name} found intersecting with this region.")

# The relation of volume to the anatomical anchor is provided in
# `anchor.last_match_description`
for d in receptor_profiles:
    print(d.anchor.last_match_description)
5 Receptor Density Fingerprint found intersecting with this region.
'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v3.0.3))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v1.18))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v2.9))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric'
'FilteredVolume Mask of 'Area PFt (IPL) (Julich-Brain Cytoarchitectonic Atlas (v2.9))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area PFt (IPL) (Julich-Brain Cytoarchitectonic Atlas (v3.1))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area PFt (IPL) (Julich-Brain Cytoarchitectonic Atlas (v3.0.3))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric'
'FilteredVolume Mask of 'Area 3b (PostCG) (Julich-Brain Cytoarchitectonic Atlas (v2.9))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 3b (PostCG) (Julich-Brain Cytoarchitectonic Atlas (v3.1))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 3b (PostCG) (Julich-Brain Cytoarchitectonic Atlas (v1.18))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 3b (PostCG) (Julich-Brain Cytoarchitectonic Atlas (v3.0.3))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric'
'FilteredVolume Mask of 'Area 4p (PreCG) (Julich-Brain Cytoarchitectonic Atlas (v3.1))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 4p (PreCG) (Julich-Brain Cytoarchitectonic Atlas (v2.9))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 4p (PreCG) (Julich-Brain Cytoarchitectonic Atlas (v3.0.3))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 4p (PreCG) (Julich-Brain Cytoarchitectonic Atlas (v1.18))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric'
'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v3.0.3))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v1.18))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric' and 'FilteredVolume Mask of 'Area 44 (IFG) (Julich-Brain Cytoarchitectonic Atlas (v2.9))' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' (built by merging the mask  of its descendants) in space MNI 152 ICBM 2009c Nonlinear Asymmetric' overlaps with 'FilteredVolume Mask of 'S_Rolando-1-L (AICHA Atlas of Intrinsic Connectivity of Homotopic Areas)' in 'MNI 152 ICBM 2009c Nonlinear Asymmetric' in space MNI 152 ICBM 2009c Nonlinear Asymmetric'

To get a more detailed assignment scores, one can make use of map assignment discussed in Anatomical Assignment, see Assign modes in activation maps to brain regions.

Total running time of the script: (5 minutes 0.962 seconds)

Estimated memory usage: 882 MB

Gallery generated by Sphinx-Gallery