io#

voxel.load_volume(filename, fmt=None) → Volume#

Load a volume from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

Volume – The loaded volume.

voxel.save_volume(volume, filename, fmt=None) → None#

Save a volume to a file.

Parameters:
  • volume (Volume) – The volume to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

voxel.load_geometry(filename, fmt=None) → VolumeGeometry#

Load only the acquisition geometry from a volume file, without reading voxel data into memory. Supported for nifti and nrrd files.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

VolumeGeometry – The loaded geometry.

voxel.load_slice_stack(filename, fmt=None) → SliceStack#

Load a slice stack from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

SliceStack – The loaded slice stack.

voxel.save_slice_stack(stack, filename, fmt=None) → None#

Save a slice stack to a file.

Parameters:
  • stack (SliceStack) – The slice stack to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

voxel.load_slice_stack_geometry(filename, fmt=None) → SliceStackGeometry#

Load only the geometry from a slice stack file, without reading pixel data into memory.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

SliceStackGeometry – The loaded geometry.

voxel.load_mesh(filename, fmt=None, **kwargs) → Mesh#

Load a mesh from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

  • **kwargs (Any) – Additional arguments to pass to the file reading method.

Returns:

Mesh – The loaded mesh.

voxel.save_mesh(mesh, filename, fmt=None, **kwargs) → None#

Save a mesh to a file.

Parameters:
  • mesh (Mesh) – The mesh to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

  • **kwargs (Any) – Additional arguments to pass to the file writing method.

voxel.load_transform(filename, fmt=None) → AffineMatrix | VectorField | VectorFieldPair | Warp | TransformSeries#

Load a transform from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

AnyTransform –

The loaded affine, vector field, field pair, or warp, or a

TransformSeries when the file holds several steps.

voxel.save_transform(transform, filename, fmt=None, **kwargs) → None#

Save a transform to a file. The native .vxx format holds any transform or series, other formats hold affines only.

Parameters:
  • transform (AnyTransform) – The transform to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

  • **kwargs (Any) – Additional arguments to pass to the file writing method.

voxel.load_affine(filename, fmt=None) → AffineMatrix#

Load an affine matrix from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

AffineMatrix – The loaded affine matrix.

voxel.save_affine(affine, filename, fmt=None, **kwargs) → None#

Save an affine matrix to a file.

Parameters:
  • affine (AffineMatrix) – The affine matrix to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

  • **kwargs (Any) – Additional arguments to pass to the file writing method.

voxel.load_bounding_box(filename) → BoundingBox#

Load a bounding box from file.

Parameters:

filename (Path) – Target file to load.

Returns:

BoundingBox – Loaded bounding box.

voxel.load_labels(filename, fmt=None) → LabelLookup#

Load a label lookup table from a file.

Parameters:
  • filename (PathLike) – The path to the file to load.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

Returns:

LabelLookup – The loaded lookup table.

voxel.save_labels(lookup, filename, fmt=None, **kwargs) → None#

Save a label lookup table to a file.

Parameters:
  • lookup (LabelLookup) – The lookup table to save.

  • filename (PathLike) – The path to the file to save.

  • fmt (str, optional) – The format of the file. If None, the format is determined by the file extension.

  • **kwargs (Any) – Additional arguments to pass to the file writing method.