siibra.core.region

Representation of a brain region.

Module Contents

Classes

Region

Representation of a region with name and more optional attributes

RegionRelationAssessments

Represents a qualified assignment between anatomical structures.

SpatialProp

SpatialPropCmpt

Attributes

REGEX_TYPE

THRESHOLD_STATISTICAL_MAPS

class siibra.core.region.Region(name: str, children: List[Region] = [], parent: Region = None, shortname: str = '', description: str = '', modality: str = '', publications: list = [], datasets: list = [], rgb: str = None, spec=None)
Inheritance diagram of siibra.core.region.Region

Representation of a region with name and more optional attributes

property id
property names
property parcellation
property spaces
property species
property supported_spaces: List[siibra.core.space.Space]

The set of spaces for which a mask could be extracted. Overwrites the corresponding method of AtlasConcept.

__contains__(other: siibra.locations.location.Location | Region) bool
__eq__(other)

Compare this region with other objects. If other is a string, compare to key, name or id.

__hash__()

Return hash(self).

__iter__()

Returns an iterator that goes through all regions in this subtree (including this parent region)

assign(other: siibra.core.structure.BrainStructure) siibra.core.assignment.AnatomicalAssignment

Compute assignment of a location to this region.

Two cases: 1) other is location -> get region map, call regionmap.assign(other) 2) other is region -> just do a semantic check for the regions

Parameters:

other (Location or Region) –

Returns:

None if there is no Qualification found.

Return type:

AnatomicalAssignment or None

compute_centroids(space: siibra.core.space.Space) siibra.locations.pointset.PointSet

Compute the centroids of the region in the given space.

Parameters:

space (Space) – reference space in which the computation will be performed

Returns:

Found centroids (as Point objects) in a PointSet

Return type:

PointSet

Note

A region can generally have multiple centroids if it has multiple connected components in the map.

static copy(other: Region)

copy constructor must detach the parent to avoid problems with the Anytree implementation.

find(regionspec, filter_children=False, find_topmost=True) List[Region]

Find regions that match the given region specification in the subtree headed by this region.

Parameters:
  • regionspec (str, regex, int, Region) –

    • a string with a possibly inexact name (matched both against the name and the identifier key)

    • a string in ‘/pattern/flags’ format to use regex search (acceptable flags: aiLmsux, see at https://docs.python.org/3/library/re.html#flags)

    • a regex applied to region names

    • a Region object

  • filter_children (bool, default: False) – If True, children of matched parents will not be returned

  • find_topmost (bool, default: True) – If True (requires filter_children=True), will return parent structures if all children are matched, even though the parent itself might not match the specification.

Returns:

list of regions matching to the regionspec

Return type:

list[Region]

Tip

See example 01-003, find regions.

get_boundingbox(space: siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold_statistical=None, restrict_space=False, **fetch_kwargs)

Compute the bounding box of this region in the given space.

Parameters:
  • space (Space or str) – Requested reference space

  • maptype (MapType, default: MapType.LABELLED) – Type of map to build (‘labelled’ will result in a binary mask, ‘statistical’ attempts to build a statistical mask, possibly by elementwise maximum of statistical maps of children)

  • threshold_statistical (float, or None) – if not None, masks will be preferably constructed by thresholding statistical maps with the given value.

  • restrict_space (bool, default: False) – If True, it will not try to fetch maps from other spaces and warp its boundingbox to requested space.

Return type:

BoundingBox

get_regional_map(space: str | siibra.core.space.Space, maptype: siibra.commons.MapType = SIIBRA_DEFAULT_MAPTYPE, threshold: float = SIIBRA_DEFAULT_MAP_THRESHOLD, via_space: str | siibra.core.space.Space = None) siibra.volumes.volume.Volume

Attempts to build a binary mask of this region in the given space, using the specified MapTypes.

Parameters:
  • space (Space or str) – The requested reference space

  • maptype (MapType, default: SIIBRA_DEFAULT_MAPTYPE) – The type of map to be used (‘labelled’ or ‘statistical’)

  • threshold (float, optional) – When fetching a statistical map, use this threshold to convert it to a binary mask

  • via_space (Space or str) –

    If specified, fetch the map in this space first, and then perform a linear warping from there to the requested space.

    Tip

    You might want to use this if a map in the requested space is not available.

    Note

    This linear warping is an affine approximation of the nonlinear deformation, computed from the warped corner points of the bounding box (see siibra.locations.BoundingBox.estimate_affine()). It does not require voxel resampling, just replaces the affine matrix, but is less accurate than a full nonlinear warping, which is currently not supported in siibra-python for images.

Return type:

Volume (use fetch() to get a NiftiImage)

Get assements on relations of this region to others defined on EBRAINS.

Yields:

Qualification

Example

>>> region = siibra.get_region("monkey", "PG")
>>> for assesment in region.get_related_regions():
>>>    print(assesment)
'PG' is homologous to 'Area PGa (IPL)'
'PG' is homologous to 'Area PGa (IPL) left'
'PG' is homologous to 'Area PGa (IPL) right'
'PG' is homologous to 'Area PGa (IPL)'
'PG' is homologous to 'Area PGa (IPL) left'
'PG' is homologous to 'Area PGa (IPL) right'
'PG' is homologous to 'Area PGa (IPL)'
'PG' is homologous to 'Area PGa (IPL) right'
'PG' is homologous to 'Area PGa (IPL) left'
has_parent(parent)
includes(region)

Determine whether this region-tree includes the given region.

Parameters:

region (Region) –

Returns:

True if the region is in the region-tree.

Return type:

bool

intersection(other: siibra.locations.location.Location) siibra.locations.location.Location

Use this region for filtering a location object.

mapped_in_space(space, recurse: bool = True) bool

Verifies wether this region is defined by an explicit map in the given space.

Parameters:
  • space (Space or str) – reference space

  • recurse (bool, default: True) – If True, check if all child regions are mapped instead

Return type:

bool

matches(regionspec)

Checks whether this region matches the given region specification.

Parameters:

regionspec (str, regex, Region) –

  • a string with a possibly inexact name, which is matched both against the name and the identifier key,

  • a regex applied to region names,

  • a region object

Returns:

If the regionspec matches to the Region.

Return type:

bool

render_tree()

Prints the tree representation of the region

spatial_props(space: siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold_statistical=None) SpatialProp

Compute spatial properties for connected components of this region in the given space.

TODO: this should go to the Volume class and just be called from here.

Parameters:
  • space (Space) – reference space in which the computation will be performed

  • maptype (MapType, default: MapType.LABELLED) – Type of map to build (‘labelled’ will result in a binary mask, ‘statistical’ attempts to build a statistical mask, possibly by elementwise maximum of statistical maps of children)

  • threshold_statistical (float, or None) – if not None, masks will be preferably constructed by thresholding statistical maps with the given value.

Returns:

Dictionary of region’s spatial properties

Return type:

Dict

supports_space(space: siibra.core.space.Space)

Return true if this region supports the given space, else False.

tree2str()

Render region-tree as a string

class siibra.core.region.RegionRelationAssessments
Inheritance diagram of siibra.core.region.RegionRelationAssessments

Represents a qualified assignment between anatomical structures.

anony_client
classmethod get_object(obj: str)
classmethod get_snapshot_factory(type_str: str)
static get_uuid(long_id: str | Dict)
classmethod parse_from_region(region: Region) Iterable[RegionRelationAssessments]
static parse_id_arg(_id: str | List[str]) List[str]
classmethod parse_relationship_assessment(src: Region, assessment)
classmethod translate_cae(src: Region, _id: str | List[str])
classmethod translate_pevs(src: Region, _id: str | List[str])
class siibra.core.region.SpatialProp
cog: SpatialPropCmpt
components: List[SpatialPropCmpt]
space: siibra.core.space.Space
class siibra.core.region.SpatialPropCmpt
centroid: siibra.locations.point.Point
volume: int
siibra.core.region.REGEX_TYPE
siibra.core.region.THRESHOLD_STATISTICAL_MAPS