Skip to content

Commit

Permalink
Improve docs for "isotropic" arg in RandomAffine (#1163)
Browse files Browse the repository at this point in the history
* Detailed documentation for isotropic argument in random affine transform

As discussed in #1158, additinal documentation is added to prevent confusion.

* flake8 line too long resolved

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update src/torchio/transforms/augmentation/spatial/random_affine.py

Co-authored-by: Fernando Pérez-García <[email protected]>

* Update src/torchio/transforms/augmentation/spatial/random_affine.py

Co-authored-by: Fernando Pérez-García <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Fernando Pérez-García <[email protected]>
  • Loading branch information
3 people committed Apr 18, 2024
1 parent 4fae718 commit b7fbb18
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/torchio/transforms/augmentation/spatial/random_affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ class RandomAffine(RandomTransform, SpatialTransform):
10 mm to the right, 20 mm to the front, and 30 mm upwards.
If the image was in, e.g., PIR+ orientation, the sample will move
10 mm to the back, 20 mm downwards, and 30 mm to the right.
isotropic: If ``True``, the scaling factor along all dimensions is the
same, i.e. :math:`s_1 = s_2 = s_3`.
isotropic: If ``True``, only one scaling factor will be sampled for all dimensions,
i.e. :math:`s_1 = s_2 = s_3`.
If one value :math:`x` is provided in :attr:`scales`, the scaling factor along all
dimensions will be :math:`s \sim \mathcal{U}(1 - x, 1 + x)`.
If two values provided :math:`(a, b)` in :attr:`scales`, the scaling factor along all
dimensions will be :math:`s \sim \mathcal{U}(a, b)`.
center: If ``'image'``, rotations and scaling will be performed around
the image center. If ``'origin'``, rotations and scaling will be
performed around the origin in world coordinates.
Expand Down Expand Up @@ -442,7 +446,9 @@ def _parse_scales_isotropic(scales, isotropic):
if isotropic and len(scales) in (3, 6):
message = (
'If "isotropic" is True, the value for "scales" must have'
f' length 1 or 2, but "{scales}" was passed'
f' length 1 or 2, but "{scales}" was passed.'
' If you want to set isotropic scaling, use a single value or two values as a range'
' for the scaling factor. Refer to the documentation for more information.'
)
raise ValueError(message)

Expand Down

0 comments on commit b7fbb18

Please sign in to comment.