Spike
Bases: IntensityTransform
Add random MRI spike artifacts.
Also known as herringbone artifact, crisscross artifact, or corduroy artifact. Spikes in k-space create stripes in image space.
The artifact is simulated by adding point impulses to the Fourier
spectrum of the image. All operations use torch.fft and run
on GPU.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_spikes
|
int | tuple[int, int]
|
Number of spikes. A scalar \(n\) is deterministic; a 2-tuple \((a, b)\) samples \(n \sim \mathcal{U}(a, b) \cap \mathbb{N}\). |
1
|
intensity
|
float | tuple[float, float]
|
Ratio between the spike amplitude and the spectrum
maximum. A scalar is deterministic; a 2-tuple \((a, b)\)
means \(r \sim \mathcal{U}(a, b)\).
The default |
0.0
|
**kwargs
|
Any
|
See |
{}
|
Note
Execution time does not depend on the number of spikes.
Examples:
>>> import torchio as tio
>>> transform = tio.Spike(intensity=2.0)
>>> transform = tio.Spike(num_spikes=3, intensity=2.0)
Source code in src/torchio/transforms/intensity/spike.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 the number and positions of spikes.
Source code in src/torchio/transforms/intensity/spike.py
apply_transform(batch, params)
Add spike artifacts to each selected image.