From f9f311c19d3988ab37c31ad8b81016edcd2ac4bc Mon Sep 17 00:00:00 2001 From: ytl0623 Date: Tue, 3 Feb 2026 11:06:30 +0800 Subject: [PATCH] docs: clarify backward mapping logic for RandAffine and RandAffined Signed-off-by: ytl0623 --- monai/transforms/spatial/array.py | 7 +++++++ monai/transforms/spatial/dictionary.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py index 1208a339dc..b6bf211cc4 100644 --- a/monai/transforms/spatial/array.py +++ b/monai/transforms/spatial/array.py @@ -2436,6 +2436,13 @@ def __init__( - :py:class:`RandAffineGrid` for the random affine parameters configurations. - :py:class:`Affine` for the affine transformation parameters configurations. + Note: + The affine transformations in MONAI use a 'backward mapping' (image-to-grid) logic. + This can be counter-intuitive: + - Translation: A positive value shifts the image in the negative direction. + - Scaling: Positive scale_range values decrease the image size; values in [-1, 0) increase it. + - Rotation: The direction (CW/CCW) may vary depending on the axis. + """ RandomizableTransform.__init__(self, prob) LazyTransform.__init__(self, lazy=lazy) diff --git a/monai/transforms/spatial/dictionary.py b/monai/transforms/spatial/dictionary.py index a61d794183..fde5ea3867 100644 --- a/monai/transforms/spatial/dictionary.py +++ b/monai/transforms/spatial/dictionary.py @@ -1100,6 +1100,13 @@ def __init__( - :py:class:`monai.transforms.compose.MapTransform` - :py:class:`RandAffineGrid` for the random affine parameters configurations. + Note: + The affine transformations in MONAI use a 'backward mapping' (image-to-grid) logic. + This can be counter-intuitive: + - Translation: A positive value shifts the image in the negative direction. + - Scaling: Positive scale_range values decrease the image size; values in [-1, 0) increase it. + - Rotation: The direction (CW/CCW) may vary depending on the axis. + """ MapTransform.__init__(self, keys, allow_missing_keys) RandomizableTransform.__init__(self, prob)