siibra.core.region
Representation of a brain region.
Attributes
Classes
Representation of a region with name and more optional attributes |
|
A collection of methods on finding related regions and the quantification |
Functions
|
Given a region, obtain the Parcellation Entity ID. |
|
Get assessments on relations of a region to others defined on EBRAINS. |
Module Contents
- 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, prerelease: bool = False)
Representation of a region with name and more optional attributes
- __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__()
- __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:
- Returns:
None if there is no Qualification found.
- Return type:
AnatomicalAssignment or None
- compute_centroids(space: siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold_statistical: float = 0.0, split_components: bool = True, **fetch_kwargs) siibra.locations.pointcloud.PointCloud
Compute the centroids of the region in the given space.
- 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, default: 0.0) – When masking a statistical map, use this threshold to convert it to a binary mask before finding its centroids.
- Returns:
Found centroids (as Point objects) in a PointCloud
- Return type:
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.
- get_boundingbox(space: siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold_statistical: float = 0.0, restrict_space: bool = True, **fetch_kwargs) siibra.locations.boundingbox.BoundingBox | None
Compute the bounding box of this region in the given space.
- Parameters:
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, default: 0.0) – When masking a statistical map, use this threshold to convert it to a binary mask before finding its bounding box.
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:
- get_regional_map(space: str | siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED) siibra.volumes.volume.FilteredVolume | siibra.volumes.volume.Volume | siibra.volumes.volume.Subvolume
Get a volume representing this region in the given space and MapType.
Note
If a region is not mapped in any of the `Map`s in the registry, then siibra will get the maps of its children recursively and merge them. If no map is available this way as well, an exception is raised.
- get_regional_mask(space: str | siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold: float = 0.0) siibra.volumes.volume.FilteredVolume
Get a binary mask of this region in the given space, using the specified MapTypes.
- Parameters:
- Return type:
Volume (use fetch() to get a NiftiImage)
Get assessments on relations of this region to others defined on EBRAINS.
- Yields:
Qualification
Example
>>> region = siibra.get_region("monkey", "PG") >>> for assessment in region.get_related_regions(): >>> print(assessment) '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.
- intersection(other: siibra.locations.location.Location) siibra.locations.location.Location
Use this region for filtering a location object.
- mapped_in_space(space, recurse: bool = False) bool
Verifies whether this region is defined by an explicit map in the given space.
- matches(regionspec)
Checks whether this region matches the given region specification.
- render_tree()
Prints the tree representation of the region
- spatial_props(space: siibra.core.space.Space, maptype: siibra.commons.MapType = MapType.LABELLED, threshold_statistical: float = 0.0, split_components: bool = True, **fetch_kwargs)
Compute spatial properties for connected components of this region in the given space.
- 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, default: 0.0) – if not None, masks will be preferably constructed by thresholding statistical maps with the given value.
- Returns:
List of region’s component spatial properties
- Return type:
List
- tree2str()
Render region-tree as a string
- children: List[Region] = []
All child nodes.
>>> from anytree import Node >>> n = Node("n") >>> a = Node("a", parent=n) >>> b = Node("b", parent=n) >>> c = Node("c", parent=n) >>> n.children (Node('/n/a'), Node('/n/b'), Node('/n/c'))
Modifying the children attribute modifies the tree.
Detach
The children attribute can be updated by setting to an iterable.
>>> n.children = [a, b] >>> n.children (Node('/n/a'), Node('/n/b'))
Node c is removed from the tree. In case of an existing reference, the node c does not vanish and is the root of its own tree.
>>> c Node('/c')
Attach
>>> d = Node("d") >>> d Node('/d') >>> n.children = [a, b, d] >>> n.children (Node('/n/a'), Node('/n/b'), Node('/n/d')) >>> d Node('/n/d')
Duplicate
A node can just be the children once. Duplicates cause a
TreeError
:>>> n.children = [a, b, d, a] Traceback (most recent call last): ... anytree.node.exceptions.TreeError: Cannot add node Node('/n/a') multiple times as child.
- find
- property id
- property names
- property parcellation
- parent: Region = None
Parent Node.
On set, the node is detached from any previous parent node and attached to the new node.
>>> from anytree import Node, RenderTree >>> udo = Node("Udo") >>> marc = Node("Marc") >>> lian = Node("Lian", parent=marc) >>> print(RenderTree(udo)) Node('/Udo') >>> print(RenderTree(marc)) Node('/Marc') └── Node('/Marc/Lian')
Attach
>>> marc.parent = udo >>> print(RenderTree(udo)) Node('/Udo') └── Node('/Udo/Marc') └── Node('/Udo/Marc/Lian')
Detach
To make a node to a root node, just set this attribute to None.
>>> marc.is_root False >>> marc.parent = None >>> marc.is_root True
- rgb = None
- property spaces
- property species
- property supported_spaces: List[siibra.core.space.Space]
The list of spaces for which a mask could be extracted from an existing map or combination of masks of its children.
- class siibra.core.region.RegionRelationAssessments
A collection of methods on finding related regions and the quantification of the relationship.
- classmethod get_object(obj: str)
Gets given a object (path), loads the content and serializes to json. Relative to the bucket ‘reference-atlas-data’.
- classmethod get_snapshot_factory(type_str: str)
Factory method for given type.
- static get_uuid(long_id: str | Dict) str
Returns the uuid portion of either a fully formed openminds id, or get the ‘id’ property first, and extract the uuid portion of the id.
- Parameters:
- Return type:
- Raises:
- classmethod parse_from_region(region: Region) Iterable[RegionRelationAssessments]
Main entry on how related regions should be retrieved. Given a region, retrieves all RegionRelationAssessments
- Parameters:
region (Region) –
- Return type:
Iterable[RegionRelationAssessments]
- static parse_id_arg(_id: str | List[str]) List[str]
Normalizes the ebrains id property. The ebrains id field can be either a str or list[str]. This method normalizes it to always be list[str].
- Parameters:
- Return type:
- Raises:
- classmethod parse_relationship_assessment(src: Region, assessment)
Given a region, and the fetched assessment json, yield RegionRelationAssignment object.
- Parameters:
- Return type:
Iterable[RegionRelationAssessments]
- classmethod translate_cae(src: Region, _id: str | List[str])
Register how CustomAnatomicalEntity should be parsed
- Parameters:
- Return type:
Iterable[RegionRelationAssessments]
- classmethod translate_pes(src: Region, _id: str | List[str])
Register how ParcellationEntity should be parsed
- Parameters:
- Return type:
Iterable[RegionRelationAssessments]
- classmethod translate_pevs(src: Region, _id: str | List[str])
Register how ParcellationEntityVersion should be parsed
- Parameters:
- Return type:
Iterable[RegionRelationAssessments]
- anony_client
- siibra.core.region.get_peid_from_region(region: Region) str
Given a region, obtain the Parcellation Entity ID.
Get assessments on relations of a region to others defined on EBRAINS.
- Parameters:
region (Region) –
- Yields:
Qualification
Example
>>> region = siibra.get_region("monkey", "PG") >>> for assessment in siibra.core.region.get_related_regions(region): >>> print(assessment) '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'
- siibra.core.region.REGEX_TYPE
- siibra.core.region.THRESHOLD_STATISTICAL_MAPS = None