Utilizing locations of interest

siibra provides common locations of interests on reference spaces as objects. These location objects can be used to query features or assignment to the maps, see Assigning coordinates to brain regions and Assign modes in activation maps to brain regions. The conversion of these locations to other spaces are done in the background but one can also be invoked when needed.

import siibra
from nilearn import plotting
import numpy as np

The simplest location type is a point. It can have a uncertainty variable or can be exact.

point = siibra.Point((27.75, -32.0, 63.725), space='mni152')
point_uncertain = siibra.Point((27.75, -32.0, 63.725), space='mni152', sigma_mm=3.)
point_uncertain
<Point((27.75, -32.0, 63.725), space='minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2', sigma_mm=3.0)>

We can create a PointSet from several points or a set of coordinates.

siibra.PointSet(
    [(27.75, -32.0, 63.725), (27.75, -32.0, 63.725)],
    space='mni152',
    sigma_mm=[0.0, 3.]
)
<PointSet(["<Point((27.75, -32.0, 63.725), space='minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2', sigma_mm=0.0)>", "<Point((27.75, -32.0, 63.725), space='minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2', sigma_mm=3.0)>"]), space='minds/core/referencespace/v1.0.0/dafcffc5-4826-4bf1-8ff6-46b8a31ff8e2'>

There are several helper properties and methods for locations, some specific to the location type. For example, we can warp the points to another space (currently limited only between MNI152, COLIN27, and BigBrain).

print(point.warp('bigbrain'))
print(point.warp('colin27'))
Point in BigBrain microscopic template (histology) [13.141,-5.65729,41.6915]
Point in MNI Colin 27 [26.5659,-40.0247,64.2493]

To explore further, let us first create a random pointset

ptset = siibra.PointSet(
    np.array([
        np.random.randn(10000) * 3 - 27.75,
        np.random.randn(10000) * 3 - 32.0,
        np.random.randn(10000) * 3 + 63.725
    ]).T,
    space='mni152'
)

We can display these points as a kernel density estimated volume

kde_volume = siibra.volumes.from_pointset(ptset)
plotting.view_img(kde_volume.fetch())
/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.


Moreover, a location object can be used to query features. While we can also, query with the pointset, let us use the bounding box that encloses these points. We will query for image features and print the assignment of the anatomical anchors to our BoundingBox

bbox = ptset.boundingbox
features_of_interest = siibra.features.get(bbox, 'image')
for f in features_of_interest:
    print(f.last_match_description)
'Bounding box from (-86.56,-86.62,-61.19) mm to (22.82,80.96,75.19)mm in BigBrain microscopic template (histology) space' contains 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-13.13,-58.79) mm to (68.44,-13.11,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-12.11,-58.79) mm to (68.44,-12.09,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-10.91,-58.79) mm to (68.43,-10.89,62.10)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-10.05,-58.79) mm to (68.43,-10.03,62.10)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-9.13,-58.79) mm to (68.44,-9.11,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-8.11,-58.79) mm to (68.44,-8.09,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-7.11,-58.79) mm to (68.44,-7.09,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-6.11,-58.79) mm to (68.44,-6.09,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-4.95,-58.79) mm to (68.44,-4.93,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-3.93,-58.79) mm to (68.44,-3.91,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-3.07,-58.79) mm to (68.44,-3.05,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-1.89,-58.79) mm to (68.44,-1.87,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-0.87,-58.79) mm to (68.44,-0.85,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,-0.03,-58.79) mm to (68.44,-0.01,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,1.09,-58.79) mm to (68.44,1.11,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,1.99,-58.79) mm to (68.44,2.01,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,2.87,-58.79) mm to (68.44,2.89,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-70.68,3.93,-58.79) mm to (68.44,3.95,62.11)mm in BigBrain microscopic template (histology) space' overlaps with 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-96.60,-132.60,-78.60) mm to (96.40,96.40,114.40)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space' contains 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-96.60,-132.60,-78.60) mm to (96.40,96.40,114.40)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space' contains 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-96.48,-132.48,-78.48) mm to (96.42,96.42,114.42)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space' contains 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'
'Bounding box from (-96.60,-132.60,-78.60) mm to (96.40,96.40,114.40)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space' contains 'Bounding box from (-40.59,-43.68,52.37) mm to (-12.19,-21.26,74.30)mm in MNI 152 ICBM 2009c Nonlinear Asymmetric space'

And now let us simply select the features that overlaps with our BoundingBox

selected_features = [
    f
    for f in features_of_interest
    if "overlaps" in str(f.last_match_result[0].qualification)
]
for f in selected_features:
    print(f.name)
#2845: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#2896: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#2956: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#2999: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3045: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3096: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3146: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3196: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3254: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3305: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3348: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3407: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3458: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3500: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3556: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3601: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3645: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)
#3698: selected 1 micron scans of BigBrain histological sections (v1.0) (cell body staining)

Total running time of the script: (0 minutes 17.822 seconds)

Gallery generated by Sphinx-Gallery