Noise
Bases: IntensityTransform
Add Gaussian or Rician noise with random parameters.
Add noise sampled from a normal distribution with random
parameters. When rician=True, the magnitude of complex
Gaussian noise is used instead, producing
Rician-distributed
noise typical of MRI acquisitions:
where \(n_1, n_2 \sim \mathcal{N}(\mu, \sigma^2)\) independently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
float | tuple[float, float] | Distribution
|
Mean \(\mu\) of the Gaussian distribution from which the
noise is sampled. If two values \((a, b)\) are provided,
then \(\mu \sim \mathcal{U}(a, b)\).
If only one value \(d\) is provided, \(\mu = d\)
(deterministic). A |
0.0
|
std
|
float | tuple[float, float] | Distribution
|
Standard deviation \(\sigma\) of the Gaussian distribution
from which the noise is sampled. If two values \((a, b)\)
are provided, then \(\sigma \sim \mathcal{U}(a, b)\).
If only one value \(d\) is provided, \(\sigma = d\)
(deterministic). Must be non-negative.
A |
0.25
|
rician
|
bool
|
If |
False
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> # Gaussian noise (default)
>>> transform = tio.Noise(std=0.1)
>>> # Rician noise (typical for MRI)
>>> transform = tio.Noise(std=0.1, rician=True)
>>> # Random std from a uniform range
>>> transform = tio.Noise(std=(0.05, 0.2))
>>> # Custom distribution for std
>>> from torch.distributions import LogNormal
>>> transform = tio.Noise(std=LogNormal(loc=-2, scale=0.5))
Source code in src/torchio/transforms/intensity/noise.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
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 |