SomeOf
Bases: Transform
Apply a random subset of the given transforms.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transforms
|
Sequence[Transform] | None
|
Sequence of candidate transforms. |
None
|
num_transforms
|
int | tuple[int, int]
|
How many transforms to apply. An |
1
|
replace
|
bool
|
If |
False
|
**kwargs
|
Any
|
See |
{}
|
Examples:
>>> import torchio as tio
>>> augmentation = tio.SomeOf(
... [tio.Noise(), tio.Flip(), tio.Noise(std=0.5)],
... num_transforms=2,
... )
Source code in src/torchio/transforms/compose.py
invertible
property
Whether this transform can be inverted.
make_params(batch)
Sample random parameters for this transform.
Override in subclasses that have random behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
SubjectsBatch
|
A |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict of sampled parameters. |
Source code in src/torchio/transforms/transform.py
apply_transform(batch, params)
Apply the transform with the given parameters.
Must be overridden by subclasses. Receives a SubjectsBatch
whose ImagesBatch entries contain 5D tensors
(B, C, I, J, K). Use negative indexing (-3, -2,
-1) for spatial dims.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
SubjectsBatch
|
A |
required |
params
|
dict[str, Any]
|
Parameters from |
required |
Returns:
| Type | Description |
|---|---|
SubjectsBatch
|
Transformed |
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 |