siibra.locations
Handles spatial concepts and spatial operation like warping between spaces.
Submodules
Package Contents
Classes
A 3D axis-aligned bounding box spanned by two 3D corner points. |
|
Abstract base class for locations in a given reference space. |
|
A single 3D point in reference space. |
|
A set of 3D points in the same reference space, |
Functions
|
Create a PointSet from an iterable of Points. |
|
Add two locations of same or diffrent type to find their union as a |
- class siibra.locations.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.
- property center: siibra.locations.point.Point
- property id: str
- property is_planar: bool
- property shape: float
The distances of the diagonal points in each axis. (Accounts for sigma).
- property volume: float
The volume of the boundingbox in mm^3
- __eq__(other: BoundingBox)
Required to provide comparison and making the object hashable
- __hash__()
Return hash(self).
- __iter__()
Iterate the min- and maxpoint of this bounding box.
- __str__()
Return str(self).
- 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)
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.
- class siibra.locations.Location(space)
-
Abstract base class for locations in a given reference space.
- property space
- property species
- BIGBRAIN_ID = 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588'
- SPACEWARP_IDS
- SPACEWARP_SERVER = 'https://hbp-spatial-backend.apps.hbp.eu/v1'
- abstract __eq__()
Required to provide comparison and making the object hashable
- __hash__() int
Return hash(self).
- __repr__()
Return repr(self).
- __str__()
Return str(self).
- abstract transform(affine: numpy.ndarray, space=None)
Returns a new location obtained by transforming the reference 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.
- abstract static union(loc0: Location, loc1: Location) Location
Reassigned at the locations module level for static typing and to avoid circular imports. See siibra.locations.__init__.reassign_union()
- abstract warp(space)
Generates a new location by warping the current one into another reference space.
- class siibra.locations.Point(coordinatespec, space=None, sigma_mm: float = 0.0, label: int | float | tuple = None)
-
A single 3D point in reference space.
- property boundingbox
- property homogeneous
The homogenous coordinate of this point as a 4-tuple, obtained by appending ‘1’ to the original 3-tuple.
- property id: str
- property volume
The volume of a point can be nonzero if it has a location uncertainty.
- __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)
Return self>=value.
- __getitem__(index)
Index access to the coefficients of this point.
- __gt__(other)
Return self>value.
- __hash__()
Return hash(self).
- __iter__()
Return an iterator over the location, so the Point can be easily cast to list or tuple.
- __le__(other)
Return self<=value.
- __len__()
- __lt__(other)
Return self<value.
- __mul__(number: float)
Return a new point with multiplied coordinates in the same space.
- __repr__()
Return repr(self).
- __setitem__(index, value)
Write access to the coefficients of this point.
- __sub__(other)
Substract 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)
Creates a new point by warping this point to another space TODO this needs to maintain the sigma parameter!
- class siibra.locations.PointSet(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.
- property boundingbox
Return the bounding box of these points. TODO revisit the numerical margin of 1e-6, should not be necessary.
- 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.
- property volume
- __eq__(other: PointSet)
Required to provide comparison and making the object hashable
- __getitem__(index: int)
- __hash__()
Return hash(self).
- __iter__()
Return an iterator over the coordinate locations.
- __len__()
The number of points in this PointSet.
- __str__()
Return str(self).
- as_list()
Return the point set as a list of 3D tuples.
- find_clusters(min_fraction=1 / 200, max_fraction=1 / 8)
- 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 PointSet 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, chunksize=1000)
Creates a new point set by warping its points to another space
- siibra.locations.from_points(points: List[siibra.locations.point.Point], newlabels: List[int | float | tuple] = None) PointSet
Create a PointSet from an iterable of Points.
- Parameters:
points (Iterable[point.Point]) –
newlabels (List[int], optional) – Use these labels instead of the original labels of the points.
- Return type:
- siibra.locations.reassign_union(loc0: location.Location, loc1: location.Location) location.Location
Add two locations of same or diffrent type to find their union as a Location object. .. note:: loc1 will be warped to loc0 they are not in the same space.
- Parameters:
- Returns:
Point U Point = PointSet
Point U PointSet = PointSet
PointSet U PointSet = PointSet
BoundingBox U BoundingBox = BoundingBox
BoundingBox U PointSet = BoundingBox
BoundingBox U Point = BoundingBox
WholeBrain U Location = NotImplementedError
(all operations are commutative)
- Return type: