spine.io.augment

Data augmentation managers and modules.

class spine.io.augment.AugmentManager(**augmenters: Mapping[str, Any] | None)[source]

Generic class to handle ordered data augmentation modules.

Methods

__call__(data)

Augment the data products in one event.

copy_meta(meta)

Return a detached copy of the metadata.

static copy_meta(meta: ImageMeta3D) ImageMeta3D[source]

Return a detached copy of the metadata.

Parameters:

meta (Meta) – Metadata object to copy

Returns:

Detached metadata copy

Return type:

Meta

spine.io.augment.Augmenter

alias of AugmentManager

class spine.io.augment.AugmentBase[source]

Base class for augmentation modules.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Apply an augmentation to one event.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = ''
abstractmethod apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Apply an augmentation to one event.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context built by the manager

Returns:

Updated data dictionary and shared metadata

Return type:

Tuple[Dict[str, Any], Meta]

static resolve_center(meta: ImageMeta3D, center: ndarray | None = None, use_geo_center: bool = False) ndarray[source]

Resolve the pivot center for a geometric transform.

Parameters:
  • meta (Meta) – Current image metadata

  • center (np.ndarray, optional) – Explicit center in detector coordinates (cm)

  • use_geo_center (bool, default False) – If True, use the detector TPC center from the geometry manager

Returns:

(3,) Pivot center in detector coordinates (cm)

Return type:

np.ndarray

static voxel_to_cm(coords: ndarray, meta: ImageMeta3D) ndarray[source]

Convert voxel indices to detector coordinates at voxel centers.

Parameters:
  • coords (np.ndarray) – (N, 3) Array of voxel indices

  • meta (Meta) – Metadata used to convert voxel indices to detector coordinates

Returns:

(N, 3) Detector coordinates in cm at voxel centers

Return type:

np.ndarray

static cm_to_voxel(coords_cm: ndarray, meta: ImageMeta3D, dtype: dtype) ndarray[source]

Convert detector coordinates at voxel centers back to indices.

Parameters:
  • coords_cm (np.ndarray) – (N, 3) Detector coordinates in cm at voxel centers

  • meta (Meta) – Metadata used to convert detector coordinates back to pixel space

  • dtype (np.dtype) – Output dtype to use for the returned voxel indices

Returns:

(N, 3) Array of voxel indices

Return type:

np.ndarray

static parse_optional_vector(value: float | list[float] | tuple[float, ...] | ndarray | None, name: str) ndarray | None[source]

Parse an optional scalar-or-vector parameter into a length-3 array.

Parameters:
  • value (float or sequence or np.ndarray, optional) – Input value to parse. Scalars are broadcast to all three axes.

  • name (str) – Parameter name used in validation error messages.

Returns:

Length-3 vector if a value is provided, otherwise None

Return type:

np.ndarray or None

static resolve_activity_center(data: dict[str, Any], keys: list[str], meta: ImageMeta3D, weighted: bool = False, feature_index: int = 0) ndarray[source]

Estimate an activity center from all coordinate-carrying tensors.

Parameters:
  • data (dict) – Dictionary of event data products

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • meta (Meta) – Shared image metadata

  • weighted (bool, default False) – If True, weight the center by the absolute feature value in the requested feature column

  • feature_index (int, default 0) – Feature column to use when weighted=True

Returns:

(3,) Activity center in detector coordinates (cm)

Return type:

np.ndarray

static resolve_activity_stats(data: dict[str, Any], keys: list[str], meta: ImageMeta3D, weighted: bool = False, feature_index: int = 0) tuple[ndarray, ndarray | None][source]

Estimate activity center and spread from coordinate-carrying tensors.

Parameters:
  • data (dict) – Dictionary of event data products

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • meta (Meta) – Shared image metadata

  • weighted (bool, default False) – If True, weight the center and spread by the absolute feature value in the requested feature column

  • feature_index (int, default 0) – Feature column to use when weighted=True

Returns:

(3,) Activity center and standard deviation in detector coordinates (cm). If no activity is available, the center falls back to the metadata center and the spread is None.

Return type:

Tuple[np.ndarray, np.ndarray or None]

static sample_box_lower(lower: ndarray, upper: ndarray, dimensions: ndarray, anchor: ndarray | None = None, spread: ndarray | None = None) ndarray[source]

Sample the lower corner of a crop/mask box.

Parameters:
  • lower (np.ndarray) – Lower detector bounds of the allowed sampling region in cm

  • upper (np.ndarray) – Upper detector bounds of the allowed sampling region in cm

  • dimensions (np.ndarray) – Requested crop or mask box dimensions in cm

  • anchor (np.ndarray, optional) – Preferred box center in cm. If provided, sampling is biased around this center.

  • spread (np.ndarray, optional) – Standard deviation of the Gaussian proposal in cm when sampling around an anchor. If not provided, a fraction of the available range is used.

Returns:

  • np.ndarray – Lower detector corner of the sampled box in cm

  • If an anchor is provided, sample the box center around it with a normal

  • distribution and clamp to the valid range. Otherwise use a uniform draw.

static make_grid_aligned_meta(meta: ImageMeta3D, lower_bound: ndarray, upper_bound: ndarray, count: ndarray, sampled_lower: ndarray) ImageMeta3D[source]

Build a box metadata object snapped to the source voxel grid.

Parameters:
  • meta (Meta) – Reference metadata that defines the source voxel grid

  • lower_bound (np.ndarray) – Minimum allowed lower edge in detector coordinates (cm)

  • upper_bound (np.ndarray) – Maximum allowed upper edge in detector coordinates (cm)

  • count (np.ndarray) – Requested number of voxels along each axis

  • sampled_lower (np.ndarray) – Proposed lower edge in detector coordinates (cm)

Returns:

Grid-aligned metadata for the sampled box

Return type:

Meta

static make_snapped_meta(meta: ImageMeta3D, size: ndarray, count: ndarray, lower: ndarray) ImageMeta3D[source]

Build metadata snapped to the source grid from a proposed lower edge.

Parameters:
  • meta (Meta) – Reference metadata that defines the source voxel grid

  • size (np.ndarray) – Pixel size for the transformed metadata

  • count (np.ndarray) – Pixel counts for the transformed metadata

  • lower (np.ndarray) – Proposed lower edge in detector coordinates (cm)

Returns:

Grid-aligned metadata for the transformed image volume

Return type:

Meta

class spine.io.augment.CropAugment(min_dimensions: ndarray | None = None, max_dimensions: ndarray | None = None, lower: ndarray | None = None, upper: ndarray | None = None, use_geo_boundaries: bool = False, center_mode: str = 'uniform', center_spread: ndarray | None = None, center_feature_index: int = 0, active_volume: bool = False, keep_meta: bool = True)[source]

Generic class to handle cropping images.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

active_volume_mask(coords_cm)

Check which detector coordinates lie inside any module active volume.

apply(data, meta, keys, context)

Randomly crop the image within the pre-defined range.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

generate_active_volume_meta(meta)

Generate metadata aligned to the detector active-volume envelope.

generate_crop(data, meta, keys)

Generate crop box metadata to apply to voxel index sets.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'crop'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Randomly crop the image within the pre-defined range.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and cropped metadata

Return type:

Tuple[Dict[str, Any], Meta]

active_volume_mask(coords_cm: ndarray) ndarray[source]

Check which detector coordinates lie inside any module active volume.

Parameters:

coords_cm (np.ndarray) – (N, 3) Detector coordinates in cm

Returns:

Boolean mask selecting coordinates inside at least one module box

Return type:

np.ndarray

generate_active_volume_meta(meta: ImageMeta3D) ImageMeta3D[source]

Generate metadata aligned to the detector active-volume envelope.

Parameters:

meta (Meta) – Metadata of the current image volume

Returns:

Metadata covering the overlap between the current image grid and the detector active-volume envelope

Return type:

Meta

generate_crop(data: dict[str, Any], meta: ImageMeta3D, keys: list[str]) ImageMeta3D[source]

Generate crop box metadata to apply to voxel index sets.

Parameters:
  • data (dict) – Dictionary of event data products used to estimate an activity center when activity-biased sampling is enabled

  • meta (Meta) – Metadata of the original image

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

Returns:

Metadata describing the cropped image volume

Return type:

Meta

class spine.io.augment.FlipAugment(axis: int, center: ndarray | None = None, use_geo_center: bool = False, keep_meta: bool = True, p: float = 1.0)[source]

Reflect voxel coordinates across a plane normal to one detector axis.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Reflect coordinates across the requested plane.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

flip_points(points, pivot)

Reflect detector coordinates across the configured plane.

generate_meta(meta, pivot)

Generate metadata for the reflected image.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'flip'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Reflect coordinates across the requested plane.

Parameters:
  • data (dict) – Dictionary of event data products to reflect

  • meta (Meta) – Shared image metadata before reflection

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and reflected metadata

Return type:

Tuple[Dict[str, Any], Meta]

flip_points(points: ndarray, pivot: ndarray) ndarray[source]

Reflect detector coordinates across the configured plane.

Parameters:
  • points (np.ndarray) – (N, 3) Detector coordinates in cm

  • pivot (np.ndarray) – (3,) Point on the reflection plane in detector coordinates (cm)

Returns:

(N, 3) Reflected detector coordinates in cm

Return type:

np.ndarray

generate_meta(meta: ImageMeta3D, pivot: ndarray) ImageMeta3D[source]

Generate metadata for the reflected image.

Parameters:
  • meta (Meta) – Metadata of the image before reflection

  • pivot (np.ndarray) – (3,) Point on the reflection plane in detector coordinates (cm)

Returns:

Metadata of the reflected image volume

Return type:

Meta

class spine.io.augment.JitterAugment(max_offset: int | tuple[int, int, int] | list[int] | ndarray, distribution: str = 'uniform', poisson_lambda: float | tuple[float, float, float] | list[float] | ndarray = 1.0, clip: bool = True)[source]

Generic class to handle voxel coordinate jitter.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Apply per-voxel coordinate jitter.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

generate_offsets(num_voxels)

Generate random integer voxel offsets.

generate_poisson_offsets(num_voxels)

Generate signed Poisson-distributed voxel offsets.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'jitter'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Apply per-voxel coordinate jitter.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and unchanged metadata

Return type:

Tuple[Dict[str, Any], Meta]

generate_offsets(num_voxels: int) ndarray[source]

Generate random integer voxel offsets.

Parameters:

num_voxels (int) – Number of voxel coordinates to jitter

Returns:

Integer per-voxel offsets of shape (num_voxels, 3)

Return type:

np.ndarray

generate_poisson_offsets(num_voxels: int) ndarray[source]

Generate signed Poisson-distributed voxel offsets.

Parameters:

num_voxels (int) – Number of voxel coordinates to jitter

Returns:

Integer per-voxel offsets of shape (num_voxels, 3)

Return type:

np.ndarray

class spine.io.augment.MaskAugment(min_dimensions: ndarray | None = None, max_dimensions: ndarray | None = None, lower: ndarray | None = None, upper: ndarray | None = None, use_geo_boundaries: bool = False, center_mode: str = 'uniform', center_spread: ndarray | None = None, center_feature_index: int = 0)[source]

Generic class to handle cutting out regions of an image.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Randomly mask a portion of the image.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

generate_mask(data, meta, keys)

Generate a masking box metadata to apply to voxel index sets.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'mask'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Randomly mask a portion of the image.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and unchanged metadata

Return type:

Tuple[Dict[str, Any], Meta]

generate_mask(data: dict[str, Any], meta: ImageMeta3D, keys: list[str]) ImageMeta3D[source]

Generate a masking box metadata to apply to voxel index sets.

Parameters:
  • data (dict) – Dictionary of event data products used to estimate an activity center when activity-biased sampling is enabled

  • meta (Meta) – Metadata of the original image

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

Returns:

Metadata describing the masked box

Return type:

Meta

class spine.io.augment.RotateAugment(axes: tuple[int, int] = (0, 1), k: int | None = None, center: ndarray | None = None, use_geo_center: bool = False, keep_meta: bool = True)[source]

Generic class to handle right-angle image rotations.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Rotate the image by quarter turns in the requested plane.

apply_image_frame_rotation(data, meta, keys, k)

Apply the historical image-frame rotation behavior.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

generate_centered_meta(meta, pivot, k)

Generate metadata for a rotation about an explicit pivot.

generate_meta(meta, k)

Generate the metadata for the rotated image.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

rotate_coords(coords, count, k)

Rotate voxel coordinates by quarter turns.

rotate_points(points, pivot, k)

Rotate detector coordinates by quarter turns around a pivot.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

sample_k()

Sample the number of quarter turns to apply.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'rotate'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Rotate the image by quarter turns in the requested plane.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and rotated metadata

Return type:

Tuple[Dict[str, Any], Meta]

generate_centered_meta(meta: ImageMeta3D, pivot: ndarray, k: int) ImageMeta3D[source]

Generate metadata for a rotation about an explicit pivot.

Parameters:
  • meta (Meta) – Metadata of the image before rotation

  • pivot (np.ndarray) – (3,) Rotation center in detector coordinates (cm)

  • k (int) – Number of 90-degree turns to apply

Returns:

Metadata of the rotated image volume

Return type:

Meta

apply_image_frame_rotation(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], k: int) tuple[dict[str, Any], ImageMeta3D][source]

Apply the historical image-frame rotation behavior.

Parameters:
  • data (dict) – Dictionary of event data products to rotate

  • meta (Meta) – Shared image metadata before rotation

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • k (int) – Number of 90-degree turns to apply

Returns:

Updated data dictionary and rotated metadata

Return type:

Tuple[Dict[str, Any], Meta]

sample_k() int[source]

Sample the number of quarter turns to apply.

Parameters:

None

Returns:

Number of 90-degree turns to apply

Return type:

int

rotate_coords(coords: ndarray, count: ndarray, k: int) ndarray[source]

Rotate voxel coordinates by quarter turns.

Parameters:
  • coords (np.ndarray) – Voxel coordinates to rotate

  • count (np.ndarray) – Original voxel counts along each axis

  • k (int) – Number of 90-degree turns to apply

Returns:

Rotated voxel coordinates

Return type:

np.ndarray

rotate_points(points: ndarray, pivot: ndarray, k: int) ndarray[source]

Rotate detector coordinates by quarter turns around a pivot.

Parameters:
  • points (np.ndarray) – (N, 3) Detector coordinates in cm

  • pivot (np.ndarray) – (3,) Rotation center in detector coordinates (cm)

  • k (int) – Number of 90-degree turns to apply

Returns:

(N, 3) Rotated detector coordinates in cm

Return type:

np.ndarray

generate_meta(meta: ImageMeta3D, k: int) ImageMeta3D[source]

Generate the metadata for the rotated image.

Parameters:
  • meta (Meta) – Metadata of the image before rotation

  • k (int) – Number of 90-degree turns to apply

Returns:

Metadata of the rotated image

Return type:

Meta

class spine.io.augment.TranslateAugment(lower: ndarray | None = None, upper: ndarray | None = None, use_geo: bool = False)[source]

Generic class to handle moving images around.

Methods

__call__(data, meta, keys, context)

Apply an augmentation module.

apply(data, meta, keys, context)

Move an image around within the pre-defined volume.

cm_to_voxel(coords_cm, meta, dtype)

Convert detector coordinates at voxel centers back to indices.

generate_offset(meta, target_meta)

Generate a voxel offset within the target bounding box.

get_target_meta(meta[, original_meta])

Resolve the target translation volume metadata.

make_grid_aligned_meta(meta, lower_bound, ...)

Build a box metadata object snapped to the source voxel grid.

make_snapped_meta(meta, size, count, lower)

Build metadata snapped to the source grid from a proposed lower edge.

parse_optional_vector(value, name)

Parse an optional scalar-or-vector parameter into a length-3 array.

resolve_activity_center(data, keys, meta[, ...])

Estimate an activity center from all coordinate-carrying tensors.

resolve_activity_stats(data, keys, meta[, ...])

Estimate activity center and spread from coordinate-carrying tensors.

resolve_center(meta[, center, use_geo_center])

Resolve the pivot center for a geometric transform.

sample_box_lower(lower, upper, dimensions[, ...])

Sample the lower corner of a crop/mask box.

voxel_to_cm(coords, meta)

Convert voxel indices to detector coordinates at voxel centers.

name = 'translate'
apply(data: dict[str, Any], meta: ImageMeta3D, keys: list[str], context: dict[str, Any]) tuple[dict[str, Any], ImageMeta3D][source]

Move an image around within the pre-defined volume.

Parameters:
  • data (dict) – Dictionary of event data products to augment

  • meta (Meta) – Shared image metadata

  • keys (List[str]) – Keys corresponding to data products that carry coordinates

  • context (dict) – Shared augmentation context

Returns:

Updated data dictionary and translated metadata

Return type:

Tuple[Dict[str, Any], Meta]

get_target_meta(meta: ImageMeta3D, original_meta: ImageMeta3D | None = None) ImageMeta3D[source]

Resolve the target translation volume metadata.

Parameters:
  • meta (Meta) – Current image metadata

  • original_meta (Meta, optional) – Original pre-augmentation metadata

Returns:

Metadata describing the translation target volume

Return type:

Meta

generate_offset(meta: ImageMeta3D, target_meta: ImageMeta3D) ndarray[source]

Generate a voxel offset within the target bounding box.

Parameters:
  • meta (Meta) – Metadata of the image to translate

  • target_meta (Meta) – Metadata of the translation target volume

Returns:

Integer voxel offset to apply along each axis

Return type:

np.ndarray