deepali.spatial.linear#

Linear transformation models.

Module Contents#

Classes#

HomogeneousTransform

Arbitrary homogeneous coordinate transformation.

Translation

Translation.

EulerRotation

Euler rotation.

QuaternionRotation

Quaternion based rotation in 3D.

IsotropicScaling

Isotropic scaling.

AnisotropicScaling

Anisotropic scaling.

Shearing

Shear transformation.

RigidTransform

Rigid transformation.

RigidQuaternionTransform

Rigid transformation parameterized by rotation quaternion.

SimilarityTransform

Similarity transformation with isotropic scaling.

AffineTransform

Affine transformation without shearing.

FullAffineTransform

Affine transformation including shearing.

class HomogeneousTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.HomogeneousTransform

Arbitrary homogeneous coordinate transformation.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – Homogeneous transform as tensor of shape (N, D, D + 1).

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

matrix_(arg: torch.Tensor) HomogeneousTransform[source]#

Set transformation matrix.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D + 1).

extra_repr() str[source]#

Print current transformation.

class Translation(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.Translation

Translation.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – Translation offsets as tensor of shape (N, D) or (N, D, 1).

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

offset() torch.Tensor[source]#

Get current translation offset in cube units.

offset_(arg: torch.Tensor) Translation[source]#

Reset parameters to given translation in cube units.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, 1).

extra_repr() str[source]#

Print current transformation.

class EulerRotation(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, order: Optional[str] = None)[source]#
Inheritance diagram of deepali.spatial.linear.EulerRotation

Euler rotation.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be 1 or equal to batch size.

  • params – Rotation angles in degrees. This parameterization is adopted from MIRTK and ensures that rotation angles and scaling factors (percentage) are within a similar range of magnitude which is useful for direct optimization of these parameters. If parameters are predicted by a callable torch.nn.Module, different output activations may be chosen before converting these to degrees.

  • order – Order in which to compose elementary rotations. For example in 3D, “zxz” means that the first rotation occurs about z, the second about x, and the third rotation about z again. In 2D, this argument is ignored and a single rotation about z (plane normal) is applied.

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

property nangles: int#

Number of Euler angles.

angles() torch.Tensor[source]#

Get Euler angles in radians.

angles_(arg: torch.Tensor) EulerRotation[source]#

Reset parameters to given Euler angles in radians.

matrix_(arg: torch.Tensor) EulerRotation[source]#

Set rotation angles from rotation matrix.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D).

extra_repr() str[source]#

Print current transformation.

class QuaternionRotation(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.QuaternionRotation

Quaternion based rotation in 3D.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – (normalized quaternion as 2-dimensional tensor of (N, 4).

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

reset_parameters() None[source]#

Reset transformation parameters.

quaternion() torch.Tensor[source]#

Get rotation quaternion.

quaternion_(arg: torch.Tensor) QuaternionRotation[source]#

Set rotation quaternion.

matrix_(arg: torch.Tensor) QuaternionRotation[source]#

Set rotation quaternion from rotation matrix.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D).

extra_repr() str[source]#

Print current transformation.

class IsotropicScaling(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.IsotropicScaling

Isotropic scaling.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – Isotropic scaling factor as a percentage. This parameterization is adopted from MIRTK and ensures that rotation angles in degrees and scaling factors are within a similar range of magnitude which is useful for direct optimization of these parameters. If parameters are predicted by a callable torch.nn.Module, different output activations may be chosen before converting these to percentages (i.e., multiplied by 100).

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

reset_parameters() None[source]#

Reset transformation parameters.

scales() torch.Tensor[source]#

Get scaling factors.

scales_(arg: torch.Tensor) IsotropicScaling[source]#

Set transformation parameters from scaling factors.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D).

extra_repr() str[source]#

Print current transformation.

class AnisotropicScaling(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.AnisotropicScaling

Anisotropic scaling.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – Anisotropic scaling factors as percentages. This parameterization is adopted from MIRTK and ensures that rotation angles in degrees and scaling factors are within a similar range of magnitude which is useful for direct optimization of these parameters. If parameters are predicted by a callable torch.nn.Module, different output activations may be chosen before converting these to percentages (i.e., multiplied by 100).

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

reset_parameters() None[source]#

Reset transformation parameters.

scales() torch.Tensor[source]#

Get scaling factors.

scales_(arg: torch.Tensor) AnisotropicScaling[source]#

Set transformation parameters from scaling factors.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D).

extra_repr() str[source]#

Print current transformation.

class Shearing(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.Shearing

Shear transformation.

Initialize transformation parameters.

Parameters
  • grid – Grid domain on which transformation is defined.

  • groups – Number of transformations. Must be either 1 or equal to batch size.

  • params – Shearing angles in degrees. This parameterization is adopted from MIRTK and ensures that rotation angles and scaling factors (percentage) are within a similar range of magnitude which is useful for direct optimization of these parameters. If parameters are predicted by a callable torch.nn.Module, different output activations may be chosen before converting these to degrees.

property data_shape: torch.Size#

Get shape of transformation parameters tensor.

property nangles: int#

Number of shear angles.

angles() torch.Tensor[source]#

Get shear angles in radians.

angles_(arg: torch.Tensor) Shearing[source]#

Set transformation parameters from shear angles in radians.

tensor() torch.Tensor[source]#

Get tensor representation of this transformation

Returns

Batch of homogeneous transformation matrices as tensor of shape (N, D, D).

extra_repr() str[source]#

Print current transformation.

class RigidTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, rotation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, translation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.RigidTransform

Rigid transformation.

Initialize transformation parameters.

Parameters
  • grid – Domain with respect to which transformation is defined.

  • groups – Number of transformations N.

  • rotation – Parameters of EulerRotation.

  • translation – Parameters of Translation.

class RigidQuaternionTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, rotation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, translation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.RigidQuaternionTransform

Rigid transformation parameterized by rotation quaternion.

Initialize transformation parameters.

Parameters
  • grid – Domain with respect to which transformation is defined.

  • groups – Number of transformations N.

  • rotation – Parameters of QuaternionRotation.

  • translation – Parameters of Translation.

class SimilarityTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, scaling: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, rotation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, translation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.SimilarityTransform

Similarity transformation with isotropic scaling.

Initialize transformation parameters.

Parameters
  • grid – Domain with respect to which transformation is defined.

  • groups – Number of transformations N.

  • scaling – Parameters of IsotropicScaling.

  • rotation – Parameters of EulerRotation.

  • translation – Parameters of Translation.

class AffineTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, scaling: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, rotation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, translation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.AffineTransform

Affine transformation without shearing.

Initialize transformation parameters.

Parameters
  • grid – Domain with respect to which transformation is defined.

  • groups – Number of transformations N.

  • scaling – Parameters of AnisotropicScaling.

  • rotation – Parameters of EulerRotation.

  • translation – Parameters of Translation.

class FullAffineTransform(grid: deepali.core.grid.Grid, groups: Optional[int] = None, scaling: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, shearing: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, rotation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True, translation: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
Inheritance diagram of deepali.spatial.linear.FullAffineTransform

Affine transformation including shearing.

Initialize transformation parameters.

Parameters
  • grid – Domain with respect to which transformation is defined.

  • groups – Number of transformations N.

  • scaling – Parameters of AnisotropicScaling.

  • shearing – Parameters of Shearing.

  • rotation – Parameters of EulerRotation.

  • translation – Parameters of Translation.