Note
Go to the end to download the full example code.
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
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())

/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"))

<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