siibra.locations.boundingbox

A box defined by two farthest corner coordinates on a specific space.

Classes

BoundingBox

A 3D axis-aligned bounding box spanned by two 3D corner points.

Functions

from_array(→ BoundingBox)

Find the bounding box of non-background values for any 3D array.

Module Contents

class siibra.locations.boundingbox.BoundingBox(point1, point2, space: str | siibra.core.space.Space = None, minsize: float = None, sigma_mm=None)
Inheritance diagram of siibra.locations.boundingbox.BoundingBox

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

Parameters:
  • affine (numpy 4x4 ndarray) – affine matrix

  • space (reference space (str, Space, or None)) – 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)

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

siibra.locations.boundingbox.from_array(array: numpy.ndarray, background: int | float = 0.0, space: siibra.core.space.Space = None) BoundingBox

Find the bounding box of non-background values for any 3D array.

Parameters:
  • array (np.ndarray) –

  • background (int or float, default: 0.0) –

  • space (Space, default: None) –