ElasticDeformation
Bases: Spatial
Apply a dense random elastic deformation.
Convenience wrapper around Spatial exposing
only the elastic parameters.
A random displacement is assigned to a coarse grid of control points and trilinearly upsampled to the image resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_points
|
TypeControlPoints | None
|
See |
None
|
num_control_points
|
int | TypeThreeInts
|
See |
7
|
max_displacement
|
TypeParameterValue
|
See |
7.5
|
locked_borders
|
int
|
See |
2
|
image_interpolation
|
TypeInterpolation
|
See |
'linear'
|
label_interpolation
|
TypeInterpolation
|
See |
'nearest'
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> transform = tio.ElasticDeformation()
>>> transform = tio.ElasticDeformation(
... max_displacement=10,
... num_control_points=5,
... )
Source code in src/torchio/transforms/spatial/spatial.py
invertible
property
Whether this transform can be inverted.
forward(data)
Apply the transform.
The output type always matches the input type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
Input data to transform. |
required |
Source code in src/torchio/transforms/transform.py
make_params(batch)
Sample random parameters and resolve the output space.
Scales, degrees, translation, and control-point displacements are sampled once and applied identically to every sample and every image in the batch.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict of serializable parameters for |
dict[str, Any]
|
history replay. |
Source code in src/torchio/transforms/spatial/spatial.py
apply_transform(batch, params)
Apply the spatial mapping to every selected image in batch.
The sampling grid is built once from the parameters produced by
make_params and reused for all images and all batch samples.
Source code in src/torchio/transforms/spatial/spatial.py
inverse(params)
Build the inverse transform from recorded parameters.
The affine component is inverted exactly. The elastic component
is approximated by negating the sampled displacement field. The
affine_first flag is flipped so that the inverse operations
run in the opposite order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[str, Any]
|
The parameter dict produced by |
required |
Returns:
| Type | Description |
|---|---|
_SpatialInverse
|
A |
Source code in src/torchio/transforms/spatial/spatial.py
to_hydra()
Export as a Hydra-compatible config dict.
Returns a dict with _target_ set to the fully qualified
class name and only non-default field values included.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict suitable for |