siibra
Submodules
Attributes
Classes
A 3D axis-aligned bounding box spanned by two 3D corner points. |
|
Generic enumeration. |
|
A 3D plane in reference space. |
|
A single 3D point in reference space. |
|
A set of 3D points in the same reference space, |
|
int([x]) -> integer |
Functions
|
|
|
|
|
|
|
|
|
|
|
siibra runs maintenance on its local cache to keep it under a predetermined |
|
|
|
|
|
Preload preconfigured siibra concepts. |
Package Contents
- class siibra.BoundingBox(point1, point2, space: str | siibra.core.space.Space = None, minsize: float = None, sigma_mm=None)
A 3D axis-aligned bounding box spanned by two 3D corner points. The box does not necessarily store the given points, instead it computes the real minimum and maximum points from the two corner points.
- __eq__(other: BoundingBox)
Required to provide comparison and making the object hashable
- __hash__()
- __iter__()
Iterate the min- and maxpoint of this bounding box.
- __str__()
- clip(xyzmax, xyzmin=(0, 0, 0))
Returns a new bounding box obtained by clipping at the given maximum coordinate.
- estimate_affine(space)
Computes an affine transform which approximates the nonlinear warping of the eight corner points to the desired target space. The transform is estimated using a least squares solution to A*x = b, where A is the matrix of point coefficients in the space of this bounding box, and b are the target coefficients in the given space after calling the nonlinear warping.
- intersection(other: siibra.core.structure.BrainStructure, dims=[0, 1, 2])
Computes the intersection of this bounding box with another one.
- Parameters:
other (BrainStructure) –
dims (List[int], default: all three) – Dimensions where the intersection should be computed (applies only to bounding boxes). Along dimensions not listed, the union is applied instead.
- shift(offset)
- transform(affine: numpy.ndarray, space=None)
Returns a new bounding box obtained by transforming the min- and maxpoint of this one with the given affine matrix.
TODO process the sigma values o the points
- warp(space: str | Dict | siibra.core.space.Space)
Returns a new bounding box obtained by warping the min- and maxpoint of this one into the new target space.
TODO process the sigma values o the points
- zoom(ratio: float)
Create a new bounding box by zooming this one around its center.
- property center: siibra.locations.point.Point
- property corners
Returns all 8 corners of the box as a pointcloud.
Note
x0, y0, z0 = self.minpoint x1, y1, z1 = self.maxpoint all_corners = [
(x0, y0, z0), (x1, y0, z0), (x0, y1, z0), (x1, y1, z0), (x0, y0, z1), (x1, y0, z1), (x0, y1, z1), (x1, y1, z1)
]
TODO: deal with sigma. Currently, returns the mean of min and max point.
- property id: str
- property is_planar: bool
- maxpoint
- minpoint
- property shape: float
The distances of the diagonal points in each axis. (Accounts for sigma).
- sigma_mm
- property volume: float
The volume of the boundingbox in mm^3
- class siibra.MapType

Generic enumeration.
Derive from this class to define new enumerations.
- LABELLED = 1
- STATISTICAL = 2
- class siibra.Plane(point1: siibra.locations.point.Point, point2: siibra.locations.point.Point, point3: siibra.locations.point.Point)
A 3D plane in reference space. TODO This shall eventually be derived from siibra.Location
- classmethod from_image(image: siibra.volumes.volume.Volume)
Derive an image plane by assuming the volume to be a 2D image. The smallest dimension in voxel space is considered flat. The plane is defined in the physical space of the volume.
- get_enclosing_patch(points: siibra.locations.pointcloud.PointCloud, margin=[0.5, 0.5])
Computes the enclosing patch in the given plane which contains the projections of the given points. The orientation of the patch follows the principal axis.
- intersect_line_segments(startpoints: numpy.ndarray, endpoints: numpy.ndarray)
Intersects a set of straight line segments with the plane. Returns the set of intersection points. The line segments are given by two Nx3 arrays of their start- and endpoints. The result is an Nx3 list of intersection coordinates.
- intersect_mesh(mesh: dict) List[siibra.locations.pointcloud.Contour]
Intersects a 3D surface mesh with the plane. Returns a set of split 2D contours, represented by ordered coordinate lists. The output contour coordinates are intersection points of mesh edges going through the plane, and only combined into a contour if arising from neighboring edges in the mesh. The mesh is passed as a dictionary with an Nx3 array “verts” of vertex coordinates, and an Mx3 array “faces” of face definitions. Each row in the face array corresponds to the three indices of vertices making up the triangle. The result is a list of contour segments, each represented as a PointCloud holding the ordered list of contour points. The point labels in each “contour” PointCloud hold the index of the face in the mesh which made up each contour point.
- project_points(points: siibra.locations.pointcloud.PointCloud)
projects the given points onto the plane.
- sidedness(points: numpy.ndarray)
Computes labels for a set of 3D coordinates classifying them by the halfspaces spanned by this plane.
- property distance_from_origin
- property normal
- space
- class siibra.Point(coordinatespec, space=None, sigma_mm: float = 0.0, label: int | float | tuple = None)
A single 3D point in reference space.
- __add__(other)
Add the coordinates of two points to get a new point representing.
- __eq__(other: Point)
Required to provide comparison and making the object hashable
- __ge__(other)
- __getitem__(index)
Index access to the coefficients of this point.
- __gt__(other)
- __hash__()
- __iter__()
Return an iterator over the location, so the Point can be easily cast to list or tuple.
- __le__(other)
- __len__()
- __lt__(other)
- __mul__(number: float)
Return a new point with multiplied coordinates in the same space.
- __repr__()
- __setitem__(index, value)
Write access to the coefficients of this point.
- __sub__(other)
Subtract the coordinates of two points to get a new point representing the offset vector. Alternatively, subtract an integer from the all coordinates of this point to create a new one. TODO this needs to maintain sigma
- __truediv__(number: float)
Return a new point with divided coordinates in the same space.
- bigbrain_section()
Estimate the histological section number of BigBrain which corresponds to this point. If the point is given in another space, a warping to BigBrain space will be tried.
- get_enclosing_cube(width_mm)
Create a bounding box centered around this point with the given width. TODO this should respect sigma (in addition or instead of the offset)
- intersection(other: siibra.locations.location.Location) Point
Return the intersection of two BrainStructures, ie. the other BrainStructure filtered by this BrainStructure.
- static parse(spec, unit='mm') Tuple[float, float, float]
Converts a 3D coordinate specification into a 3D tuple of floats.
- transform(affine: numpy.ndarray, space=None)
Returns a new Point obtained by transforming the coordinate of this one with the given affine matrix. TODO this needs to maintain sigma
- warp(space: str | Dict | siibra.core.space.Space)
Creates a new point by warping this point to another space TODO this needs to maintain the sigma parameter!
- coordinate
- property homogeneous
The homogeneous coordinate of this point as a 4-tuple, obtained by appending ‘1’ to the original 3-tuple.
- property id: str
- label = None
- sigma = 0.0
- property volume
The volume of a point can be nonzero if it has a location uncertainty.
- class siibra.PointCloud(coordinates: List[Tuple] | numpy.ndarray, space=None, sigma_mm: int | float | List[int | float] = 0, labels: List[int | float | tuple] = None)
A set of 3D points in the same reference space, defined by a list of coordinates.
- __eq__(other: PointCloud)
Required to provide comparison and making the object hashable
- __getitem__(index: int)
- __hash__()
- __iter__()
Return an iterator over the coordinate locations.
- __len__()
The number of points in this PointCloud.
- __str__()
- as_list()
Return the point set as a list of 3D tuples.
- find_clusters(min_fraction: float = 1 / 200, max_fraction: float = 1 / 8) List[int]
Find clusters using HDBSCAN (https://dl.acm.org/doi/10.1145/2733381) implementation of scikit-learn (https://dl.acm.org/doi/10.5555/1953048.2078195).
- Parameters:
min_fraction (min cluster size as a fraction of total points in the PointCloud) –
max_fraction (max cluster size as a fraction of total points in the PointCloud) –
- Returns:
Returns the cluster labels found by skilearn.cluster.HDBSCAN.
Note
Replaces the labels of the PointCloud instance with these labels.
- Return type:
List[int]
- Raises:
RuntimeError – If a sklearn version without HDBSCAN is installed.
- intersection(other: siibra.locations.location.Location)
Return the subset of points that are inside the given mask.
NOTE: The affine matrix of the image must be set to warp voxels coordinates into the reference space of this Bounding Box.
- transform(affine: numpy.ndarray, space=None)
Returns a new PointCloud obtained by transforming the coordinates of this one with the given affine matrix.
- Parameters:
affine (numpy 4x4 ndarray) – affine matrix
space (reference space (id, name, or Space)) – Target reference space which is reached after applying the transform. Note that the consistency of this cannot be checked and is up to the user.
- warp(space: str | Dict | siibra.core.space.Space, chunksize: int = 1000)
Creates a new point set by warping its points to another space
- property boundingbox
Return the bounding box of these points, or None in the special case of an empty PointCloud.
- property centroid
- property coordinates: numpy.ndarray
- property has_constant_sigma: bool
- property homogeneous
Access the list of 3D point as an Nx4 array of homogeneous coordinates.
- property label_colors
return a color for the given label.
- labels = None
- property volume
- class siibra.Warmup
- classmethod deregister_warmup_fn(original_fn)
- static fn_eql(wrapped_fn, original_fn)
- classmethod is_registered(fn)
- classmethod register_warmup_fn(warmup_level: WarmupLevel = WarmupLevel.INSTANCE, *, is_factory=False)
- classmethod warmup(warmup_level: WarmupLevel = WarmupLevel.INSTANCE, *, max_workers=4)
- class siibra.WarmupLevel

int([x]) -> integer int(x, base=10) -> integer
Convert a number or string to an integer, or return 0 if no arguments are given. If x is a number, return x.__int__(). For floating point numbers, this truncates towards zero.
If x is not a number or if base is given, then x must be a string, bytes, or bytearray instance representing an integer literal in the given base. The literal can be preceded by ‘+’ or ‘-’ and be surrounded by whitespace. The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to interpret the base from the string as an integer literal. >>> int(‘0b100’, base=0) 4
- DATA = 5
- INSTANCE = 1
- TEST = -1000
- siibra.__dir__()
- siibra.__getattr__(attr: str)
- siibra.get_map(parcellation: str, space: str, maptype: commons.MapType = MapType.LABELLED, **kwargs)
- siibra.get_template(space_spec: str, **kwargs)
- siibra.set_cache_size(maxsize_gbyte: int)
siibra runs maintenance on its local cache to keep it under a predetermined size of 2 gigabytes. This method changes the cache size.
- Parameters:
maxsize_gbyte (int) –
- siibra.set_feasible_download_size(maxsize_gbyte)
- siibra.set_log_level(level)
- siibra.warm_cache(level=WarmupLevel.INSTANCE)
Preload preconfigured siibra concepts.
Siibra relies on preconfigurations that simplify integrating various concepts such as parcellations, reference spaces, and multimodal data features. By preloading the instances, siibra commits all preconfigurations to the memory at once instead of committing them when required.
- siibra.QUIET
- siibra.VERBOSE
- siibra.__version__
- siibra.cache = None
- siibra.find_regions
- siibra.from_json
- siibra.logger = None