Spatial transforms
spatial_transforms
#
InPlaneRotate
dataclass
#
InPlaneRotate(angle: float, interpolation: str = 'linear')
Bases: imgtools.transforms.spatial_transforms.SpatialTransform
InPlaneRotate operation class.
A callable class that rotates an image on a plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
The angle of rotation. |
required |
|
str
|
The interpolation method to use. Valid options are: - "linear" for bi/trilinear interpolation (default) - "nearest" for nearest neighbour interpolation - "bspline" for order-3 b-spline interpolation |
'linear'
|
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |
Resample
dataclass
#
Resample(
spacing: float | typing.Sequence[float] | numpy.ndarray,
interpolation: str = "linear",
anti_alias: bool = True,
anti_alias_sigma: float | None = None,
transform: SimpleITK.Transform | None = None,
output_size: list[float] | None = None,
)
Bases: imgtools.transforms.spatial_transforms.SpatialTransform
Resample operation class.
A callable class that resamples image to a given spacing, optionally applying a transformation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float | typing.Sequence[float] | numpy.ndarray
|
The new image spacing. If float, assumes the same spacing in all directions. Alternatively, a sequence of floats can be passed to specify spacing along each dimension. Passing 0 at any position will keep the original spacing along that dimension (useful for in-plane resampling). |
required |
|
str
|
The interpolation method to use. Valid options are: - "linear" for bi/trilinear interpolation (default) - "nearest" for nearest neighbour interpolation - "bspline" for order-3 b-spline interpolation |
'linear'
|
|
bool
|
Whether to smooth the image with a Gaussian kernel before resampling.
Only used when downsampling, i.e. when |
True
|
|
float | None
|
The standard deviation of the Gaussian kernel used for anti-aliasing. |
None
|
|
SimpleITK.Transform | None
|
Transform to apply to input coordinates when resampling. If None, defaults to identity transformation. |
None
|
|
list[float] | None
|
Size of the output image. If None, it is computed to preserve the whole extent of the input image. |
None
|
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |
Return whether this transform supports reference images.
|
|
Returns:
Type | Description |
---|---|
bool
|
Always True for spatial transforms. |
Resize
dataclass
#
Resize(
size: int | list[int] | numpy.ndarray,
interpolation: str = "linear",
anti_alias: bool = True,
anti_alias_sigma: float | None = None,
)
Bases: imgtools.transforms.spatial_transforms.SpatialTransform
Resize operation class.
A callable class that resizes image to a given size by resampling coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int | list[int] | numpy.ndarray
|
The new image size. If float, assumes the same size in all directions. Alternatively, a sequence of floats can be passed to specify size along each dimension. Passing 0 at any position will keep the original size along that dimension. |
required |
|
str
|
The interpolation method to use. Valid options are: - "linear" for bi/trilinear interpolation (default) - "nearest" for nearest neighbour interpolation - "bspline" for order-3 b-spline interpolation |
'linear'
|
|
bool
|
Whether to smooth the image with a Gaussian kernel before resampling.
Only used when downsampling, i.e. when |
True
|
|
float | None
|
The standard deviation of the Gaussian kernel used for anti-aliasing. |
None
|
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |
Rotate
dataclass
#
Rotate(
rotation_centre: list[int],
angles: float | list[float],
interpolation: str = "linear",
)
Bases: imgtools.transforms.spatial_transforms.SpatialTransform
Rotate operation class.
A callable class that rotates an image around a given centre.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[int]
|
The centre of rotation in image coordinates. |
required |
|
float | list[float]
|
The angles of rotation around x, y and z axes. |
required |
|
str
|
The interpolation method to use. Valid options are: - "linear" for bi/trilinear interpolation (default) - "nearest" for nearest neighbour interpolation - "bspline" for order-3 b-spline interpolation |
'linear'
|
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |
SpatialTransform
#
Bases: imgtools.transforms.base_transform.BaseTransform
Base class for spatial transforms.
Spatial transforms modify the spatial properties of an image, such as spacing, size, or orientation.
All spatial transforms support an optional reference image parameter in their call method.
Examples:
>>> # This is an abstract base class and cannot be instantiated directly.
>>> # Use one of its subclasses like Resample, Resize, etc.
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |
Zoom
dataclass
#
Zoom(
scale_factor: float | list[float],
interpolation: str = "linear",
anti_alias: bool = True,
anti_alias_sigma: float | None = None,
)
Bases: imgtools.transforms.spatial_transforms.SpatialTransform
Zoom operation class.
A callable class that rescales image, preserving its spatial extent.
The rescaled image will have the same spatial extent (size) but will be
rescaled by scale_factor
in each dimension. Alternatively, a separate
scale factor for each dimension can be specified by passing a sequence
of floats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float | list[float]
|
If float, each dimension will be scaled by that factor. If tuple, each dimension will be scaled by the corresponding element. |
required |
|
str
|
The interpolation method to use. Valid options are: - "linear" for bi/trilinear interpolation (default) - "nearest" for nearest neighbour interpolation - "bspline" for order-3 b-spline interpolation |
'linear'
|
|
bool
|
Whether to smooth the image with a Gaussian kernel before resampling.
Only used when downsampling, i.e. when |
True
|
|
float | None
|
The standard deviation of the Gaussian kernel used for anti-aliasing. |
None
|
Methods:
Name | Description |
---|---|
supports_reference |
Return whether this transform supports reference images. |
name
property
#
Return the name of the transform class for logging and debugging.
Returns:
Type | Description |
---|---|
str
|
The name of the transform class. |
supports_reference
#
Return whether this transform supports reference images.
Returns:
Type | Description |
---|---|
bool
|
False by default. Subclasses should override this method |