siibra.core.parcellation
Hierarchal brain regions and metadata.
Classes
Representation of a region with name and more optional attributes |
|
Functions
|
Find regions matching the given region specification across all parcellation |
Module Contents
- class siibra.core.parcellation.Parcellation(identifier: str, name: str, species: siibra.commons.Species | str, regions: List[siibra.core.region.Region] | siibra.core.region.Region = (), shortname: str = '', description: str = '', version: ParcellationVersion = None, modality: str = None, publications: list = [], datasets: list = [], prerelease: bool = False)
Representation of a region with name and more optional attributes
- __getitem__(regionspec: str | int)
Retrieve a region object from the parcellation by labelindex or partial name.
- __lt__(other)
We sort parcellations by their version
- get_map(space: str | siibra.core.space.Space, maptype: Literal['labelled', 'statistical'] | siibra.commons.MapType = MapType.LABELLED, spec: str = '')
Get the maps for the parcellation in the requested template space.
This might in general include multiple 3D volumes. For example, the Julich-Brain atlas provides two separate maps, one per hemisphere. Per default, multiple maps are concatenated into a 4D array, but you can choose to retrieve a dict of 3D volumes instead using return_dict=True.
- Parameters:
space (Space or str) – reference space specification such as name, id, or a Space instance.
maptype (MapType or str) – Type of map requested (e.g., statistical or labelled). Use MapType.STATISTICAL to request probability maps. Defaults to MapType.LABELLED.
spec (str, optional) – In case of multiple matching maps for the given parcellation, space and type, use this field to specify keywords matching the desired parcellation map name. Otherwise, siibra will default to the first in the list of matches (and inform with a log message)
- Returns:
A ParcellationMap representing the volumetric map or a SparseMap representing the list of statistical maps.
- Return type:
- get_region(regionspec: str | siibra.core.region.Region, find_topmost: bool = False, allow_tuple: bool = False)
Given a unique specification, return the corresponding region.
The spec could be a (possibly incomplete) name, or a region object. This method is meant to definitely determine a valid region. Therefore, if no match is found, it raises a ValueError. If multiple matches are found, the method tries to return only the common parent node. If there is no common parent, an exception is raised, except when allow_tuple=True - then a tuple of matched regions is returned.
- Parameters:
a string with a possibly inexact name (matched both against the name and the identifier key)
a Region object
find_topmost (bool, default: False) – If True, will automatically return the parent of a decoded region the decoded region is its only child.
allow_tuple (bool, default: False) – If multiple candidates without a common parent are found, return a tuple of matches instead of raising an exception.
- Returns:
A region object defined in the parcellation.
Note
If the spec exactly matched with more than one region, the first will be returned.
- Return type:
- Raises:
RuntimeError – If the spec matches multiple regions
ValueError – If the spec cannot be matched against any region.
- matches(spec)
Checks whether this region matches the given region specification.
- property id
- property is_newest_version
- version = None
- class siibra.core.parcellation.ParcellationVersion(name, parcellation, collection=None, prev_id=None, next_id=None, deprecated=False)
- __eq__(other)
- __iter__()
- __lt__(other: ParcellationVersion)
< operator, useful for sorting by version FIXME: this is only by name, not recursing into parcellations, to avoid importing the registry here.
- __repr__()
- __str__()
- collection = None
- deprecated = False
- name
- next_id = None
- parcellation
- prev_id = None
- siibra.core.parcellation.find_regions(regionspec: str, filter_children=True, find_topmost=False)
Find regions matching the given region specification across all parcellation instances in the registry.
- Parameters:
regionspec (str, regex, 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 https://docs.python.org/3/library/re.html#flags)
a regex applied to region names
a Region object
filter_children (bool, default: True) – If True, children of matched parents will not be returned
find_topmost (bool, default: False) – 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: