deepali.spatial.linear
#
Linear transformation models.
Module Contents#
Classes#
Arbitrary homogeneous coordinate transformation. |
|
Translation. |
|
Euler rotation. |
|
Quaternion based rotation in 3D. |
|
Isotropic scaling. |
|
Anisotropic scaling. |
|
Shear transformation. |
|
Rigid transformation. |
|
Rigid transformation parameterized by rotation quaternion. |
|
Similarity transformation with isotropic scaling. |
|
Affine transformation without shearing. |
|
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]#
-
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.
- class Translation(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
-
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_(arg: torch.Tensor) Translation [source]#
Reset parameters to given translation in cube units.
- 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]#
-
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_(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.
- class QuaternionRotation(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
-
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.
- quaternion_(arg: torch.Tensor) QuaternionRotation [source]#
Set rotation quaternion.
- matrix_(arg: torch.Tensor) QuaternionRotation [source]#
Set rotation quaternion from rotation matrix.
- class IsotropicScaling(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
-
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.
- scales_(arg: torch.Tensor) IsotropicScaling [source]#
Set transformation parameters from scaling factors.
- class AnisotropicScaling(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
-
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.
- scales_(arg: torch.Tensor) AnisotropicScaling [source]#
Set transformation parameters from scaling factors.
- class Shearing(grid: deepali.core.grid.Grid, groups: Optional[int] = None, params: Optional[Union[bool, torch.Tensor, Callable[Ellipsis, torch.Tensor]]] = True)[source]#
-
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_(arg: torch.Tensor) Shearing [source]#
Set transformation parameters from shear angles in radians.
- 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]#
-
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]#
-
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]#
-
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]#
-
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]#
-
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
.