Motion
Bases: IntensityTransform
Simulate MRI motion artifacts.
Motion during MR acquisition corrupts different segments of k-space with different rigid-body transforms, producing characteristic ringing and blurring. This implementation follows Shaw et al., 2019.
The simulation:
- Splits k-space into num_transforms + 1 segments along a random axis.
- For each segment, applies a random rigid-body transform to the image and fills the corresponding k-space lines from the transformed image.
- Reconstructs the corrupted image via inverse FFT.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
degrees
|
float | tuple[float, float]
|
Rotation range in degrees. A scalar \(d\) means \(\theta_i \sim \mathcal{U}(-d, d)\). A 2-tuple \((a, b)\) means \(\theta_i \sim \mathcal{U}(a, b)\). |
10.0
|
translation
|
float | tuple[float, float]
|
Translation range in mm, same convention. |
10.0
|
num_transforms
|
int
|
Number of inter-segment motion events. More transforms produce more distortion. |
2
|
**kwargs
|
Any
|
See |
{}
|
Warning
Large numbers of transforms increase execution time significantly for 3D volumes.
Examples:
>>> import torchio as tio
>>> transform = tio.Motion()
>>> transform = tio.Motion(degrees=15, translation=10, num_transforms=4)
Source code in src/torchio/transforms/intensity/motion.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
inverse(params)
Return a transform that undoes this one.
Override in invertible subclasses. The returned transform, when applied, reverses the effect of the forward pass with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
params
|
dict[str, Any]
|
The parameters recorded in the forward pass. |
required |
Returns:
| Type | Description |
|---|---|
Transform
|
A new |
Source code in src/torchio/transforms/transform.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 |
Source code in src/torchio/transforms/transform.py
make_params(batch)
Sample motion parameters.
Source code in src/torchio/transforms/intensity/motion.py
apply_transform(batch, params)
Corrupt each selected image with simulated motion.