Resample
Bases: Spatial
Resample images to a different space.
Convenience wrapper around Spatial exposing
only the resampling parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
TypeTarget
|
Output space (see |
1
|
image_interpolation
|
TypeInterpolation
|
See |
'linear'
|
label_interpolation
|
TypeInterpolation
|
See |
'nearest'
|
antialias
|
bool
|
See |
False
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> transform = tio.Resample(2) # 2 mm isotropic
>>> transform = tio.Resample("t1") # match "t1" space
>>> transform = tio.Resample((1, 1, 3)) # anisotropic
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 |