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 per batch element when per-instance augmentation is active (the default for batches), and once otherwise.
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
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |
apply_transform(batch, params)
Apply the spatial mapping to every selected image in batch.
One sampling grid is built per batch element when per-instance parameters are present, and a single shared grid otherwise.
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. Per-instance parameters are inverted
element by element.
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 |