vreg.Volume3D#
- class vreg.Volume3D(values: ndarray, affine: ndarray, coords: list | None = None, dims: list | None = None, prec: int | None = None)[source]#
A spatially aware numpy array
- Parameters:
values (np.ndarray) – Numpy array of values (3 or more dimensions)
affine (np.ndarray) – 4x4 numpy array with the affine matrix of the value array. If not provided, the identity is assumed. Defaults to None.
coords (list) – For values with more than 3 dimensions, provide a list of coordinate arrays for the locations of the replicated volumes. If not provided, index arrays are used for the coordinates of the extra dimensions.
dims (list) – Names of the extra dimensions for volumes with more than 3 dimensions.
prec (int) – internal precision to be used when comparing positions. If not provided, the exact floating point values of locations are used. Defaults to None.
Methods
add
(v, *args, **kwargs)Add another volume
bounding_box
([mask, margin])Return the bounding box
center_of_mass
([coords])Center of mass.
copy
(**kwargs)Return a copy
crop
([mask, margin])Crop to a box
distance
(target, transform, params[, ...])Distance to a target volume after a transform
extract_slice
([z])Extract a slice at index z
find_rotate_to
(target[, rotation, metric, ...])Find the rigid transform to a static target volume.
find_transform_rigid_to
(target[, params, ...])Find the rigid transform to a static target volume.
find_transform_to
(target, transform[, ...])Coregister a volume to a static target volume.
find_translate_to
(target[, translation, ...])Find the translation to a static target volume.
resample
([spacing, stretch])Resample volume to new pixel spacing
reslice
([affine, orient, rotation, center, ...])Reslice the volume.
rotate
(rotation[, center, values, reshape, ...])Rotate the volume.
rotate_to
(target, rotation[, center, coords])Apply a rotation and reslice the result to the geometry of a target volume.
separate
([axis])Separate a volume along one or more time axes.
set_affine
(affine)Set a new affine for the volume
set_coords
(coords)Set new coordinates for the volume
set_dims
(dims)Set new names for the non-spatial dimensions
set_values
(values)Set new values for the volume
slice_like
(v)Slice the volume to the geometry of another volume
split
([n, axis, gap])Split a volume into slices (2D volumes)
stretch
(stretch[, values, reshape])Stretch the volume.
stretch_to
(target, stretch)Stretch and reslice to the geometry of a target volume.
subtract
(v, *args, **kwargs)Subtract another volume
transform
(transform, params, **kwargs)Transform a volume
transform_affine
(params[, center, values, ...])Apply an affine transformation.
transform_affine_to
(target, params[, ...])Apply an affine transformation and reslice the result to the geometry of a target volume.
transform_rigid
(params[, values, reshape, ...])Apply a rigid transformation.
transform_rigid_to
(target, params[, center, ...])Apply a rigid transformation and reslice the result to the geometry of a target volume.
transform_to
(target, transform, params, **kwargs)Transform a volume to a target volume
translate
(translation[, values, reshape, ...])Translate the volume.
translate_to
(target, translation[, coords, dir])Apply a translation and reslice the result to the geometry of a target volume.
truncate
(shape)Truncate the volume to a smaller shape.
Attributes