Composite transforms#

Spatial transforms which are composed of other spatial transforms are referred to as composite transforms with common type CompositeTransform. Two main composite types are distinguished based on how these compose the individual spatial transforms: MultiLevelTransform and SequentialTransform. A special kind of sequential transform is the GenericSpatialTransform, which can be configured to represent most common spatial transformation models.

Multi-level transform#

Sum of spatial transformations applied to any set of points.

A MultiLevelTransform adds the sum of the displacement vectors across all spatial transforms at the input points that are being mapped to new locations, i.e.,

\[\vec{y} = \vec{x} + \sum_{i=0}^{n-1} \vec{u}_i(\vec{x})\]

Sequential transform#

Composition of spatial transformations applied to any set of points.

A SequentialTransform is the functional composition of spatial transforms, i.e.,

\[\vec{y} = \vec{u}_{n-1} \circ \cdots \circ \vec{u}_0 \circ \vec{x}\]

Generic transform#

A GenericSpatialTransform sequentially applies a configured set of transformations.

Configuration#

The types of transformations and their order of application can be configured via a TransformConfig, which can be programmatically created or initialized from a configuration file in JSON or YAML format (cf. DataclassConfig.read()).

class TransformConfig(transform: str = 'Affine o SVF', affine_model: str = 'TRS', rotation_model: str = 'ZXZ', control_point_spacing: Union[int, Tuple[int, ...]] = 1, scaling_and_squaring_steps: int = 6, flip_grid_coords: bool = False)[source]

Configuration of generic spatial transformation model.

affine_model: str = 'TRS'

String encoding of composition of elementary linear transformations.

The string value of this configuration entry can be in one of two forms:

  • Matrix notation: Each letter is a factor in the sequence of matrix-matrix products.

  • Function composition: Use deliminator ” o ” between transformations to denote composition.

Valid elementary linear transform identifiers are:

control_point_spacing: Union[int, Tuple[int, ...]] = 1

Control point spacing of non-rigid transformations.

The spacing must be given in voxel units of the grid domain with respect to which the transformations are defined.

flip_grid_coords: bool = False

Whether predicted transformation parameters are with respect to a grid with point coordinates in the order (…, x) instead of (x, …).

rotation_model: str = 'ZXZ'

Order of elementary Euler rotations.

This configuration value is only used when affine_model contains an EulerRotation denoted by letter “R”. Valid values are “ZXZ”, “XZX”, … (cf. core.affine.euler_rotation_matrix()).

scaling_and_squaring_steps: int = 6

Number of scaling and squaring steps in case of a stationary velocity field transform.

transform: str = 'Affine o SVF'

String encoding of spatial transformation model to use.

The linear transforms making up the Affine component are defined by affine_model.

The non-rigid component can be one of the following:

Parameters#

The parameters of a GenericSpatialTransform are either the parameters specified as params, or a dictionary of parameters inferred by a neural network. The keys of the params dictionary must match the names of the configured spatial transforms making up the SequentialTransform.

Keys for affine component parameters:

  • A: "affine"

  • K: "shearing"

  • T: "translation" or "offset"

  • R: "rotation" or "angles"

  • S: "scaling" or "scales"

  • Q: "quaternion"

Keys of non-rigid component parameters:

  • "nonrigid" or "vfield".