Skip to content

Commit 14f5b80

Browse files
ytl0623ericspod
andauthored
docs: clarify backward mapping logic for RandAffine and RandAffined (#8730)
Fixes #8726 ### Description - Updated `monai/transforms/spatial/array.py`: Added a Note to `RandAffine `explaining the inverse relationship for translation and scaling. - Updated `monai/transforms/spatial/dictionary.py`: Added a corresponding Note to `RandAffined `to ensure consistency for dictionary-based workflows. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: ytl0623 <david89062388@gmail.com> Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
1 parent 0651704 commit 14f5b80

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

monai/transforms/spatial/array.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,13 @@ def __init__(
24362436
- :py:class:`RandAffineGrid` for the random affine parameters configurations.
24372437
- :py:class:`Affine` for the affine transformation parameters configurations.
24382438
2439+
Note:
2440+
The affine transformations in MONAI use a 'backward mapping' (image-to-grid) logic.
2441+
This can be counter-intuitive:
2442+
- Translation: A positive value shifts the image in the negative direction.
2443+
- Scaling: Positive scale_range values decrease the image size; values in [-1, 0) increase it.
2444+
- Rotation: The direction (CW/CCW) may vary depending on the axis.
2445+
24392446
"""
24402447
RandomizableTransform.__init__(self, prob)
24412448
LazyTransform.__init__(self, lazy=lazy)

monai/transforms/spatial/dictionary.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,13 @@ def __init__(
11081108
- :py:class:`monai.transforms.compose.MapTransform`
11091109
- :py:class:`RandAffineGrid` for the random affine parameters configurations.
11101110
1111+
Note:
1112+
The affine transformations in MONAI use a 'backward mapping' (image-to-grid) logic.
1113+
This can be counter-intuitive:
1114+
- Translation: A positive value shifts the image in the negative direction.
1115+
- Scaling: Positive scale_range values decrease the image size; values in [-1, 0) increase it.
1116+
- Rotation: The direction (CW/CCW) may vary depending on the axis.
1117+
11111118
"""
11121119
MapTransform.__init__(self, keys, allow_missing_keys)
11131120
RandomizableTransform.__init__(self, prob)

0 commit comments

Comments
 (0)