volume#

voxel.volume.stack(*vols) → Volume#

Concatenate (stack) multiple volumes channel-wise. Assumes the volumes are in the same image space (with the same base shape).

Parameters:

*vols (Volume) – Volumes to merge.

Returns:

Volume – Single channel-stacked volume instance.

voxel.volume.volume_grid(baseshape, transform=None, localshape=None, device=None) → Tensor#

Construct a grid of 3D voxel coordinates of the shape (W, H, D, 3).

Parameters:
  • baseshape (Size) – Spatial (3D) shape of the volume grid.

  • transform (AffineMatrix, optional) – Grid voxel coordinate transform.

  • localshape (Size, optional) – If provided, the grid is normalized to the range [-1, 1] using this spatial shape and the coordinate order is swapped (for torch sampling methods).

  • device (device, optional) – Device on which to allocate the grid data.

Returns:

Tensor – Grid volume tensor.

voxel.volumes_equal(a, b, vol_tol=1e-6, geom_tol=1e-6) → bool#

Check if two volumes are equal within a given tolerance.

Parameters:
  • a (Volume) – First volume to compare.

  • b (Volume) – Second volume to compare.

  • vol_tol (float, optional) – Absolute tolerance for volume tensor comparison.

  • geom_tol (float, optional) – Absolute tolerance for geometry comparison.

Returns:

bool – True if the volumes are equal, False otherwise.