Warp#

class voxel.Warp(coordinates, geometry=None)#

A dense warp of absolute world-space coordinates, held as a \((W, H, D, 3)\) tensor over the grid defined by geometry on the fixed-side domain. Each grid point maps to the world coordinate where a moving volume should be sampled (a pull-back mapping).

property baseshape: Size#

The spatial 3D \((W, H, D)\) shape of the warp grid.

property device: device#

Device of the warp coordinate tensor.

to(device) → Warp#

Move the warp coordinates to a device.

save(filename, fmt=None) → None#

Save the warp to a file.

Parameters:
  • 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.

as_volume() → Volume#

Convert the warp to a volume of 3-channel coordinate features.

Returns:

Volume – The warp coordinates as a volume.

as_displacement_field() → VectorField#

Convert to the field of world-space displacements between the warp coordinates and the identity grid.

Returns:

VectorField – The displacement field.

map(volume, mode='linear', padding_mode='zeros') → Volume#

Warp a volume by sampling it at the mapped coordinates, producing a pulled-back volume on the warp grid.

Parameters:
  • volume (Volume) – The moving volume to warp.

  • mode (str, optional) – The sampling mode, either ‘linear’ or ‘nearest’.

  • padding_mode (str, optional) – Padding mode for outside grid values.

Returns:

Volume – The warped volume.