From 2ab5653f8aab74cc7a2a605e17708aff1834da9d Mon Sep 17 00:00:00 2001
From: "li.yunhao"
Date: Thu, 12 Mar 2026 06:25:23 +0000
Subject: [PATCH] Fix #8340: Remove incorrect minus sign in rotate_range
documentation
Remove the extra minus sign in rotate_range[i][0] that was
incorrectly documented across multiple transform classes.
The actual implementation uses uniform(f[0], f[1]) without
any negation on the first parameter.
Affected transforms:
- RandAffineGrid, RandAffine
- Rand2DElastic, Rand3DElastic
- RandAffined, Rand2DElasticd, Rand3DElasticd
Signed-off-by: li.yunhao
---
monai/transforms/spatial/array.py | 8 ++++----
monai/transforms/spatial/dictionary.py | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/monai/transforms/spatial/array.py b/monai/transforms/spatial/array.py
index b6bf211cc4..55dab79c3d 100644
--- a/monai/transforms/spatial/array.py
+++ b/monai/transforms/spatial/array.py
@@ -1848,7 +1848,7 @@ def __init__(
"""
Args:
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
@@ -2386,7 +2386,7 @@ def __init__(
prob: probability of returning a randomized affine grid.
defaults to 0.1, with 10% chance returns a randomized grid.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
@@ -2656,7 +2656,7 @@ def __init__(
defaults to 0.1, with 10% chance returns a randomized elastic transform,
otherwise returns a ``spatial_size`` centered area extracted from the input image.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
@@ -2824,7 +2824,7 @@ def __init__(
defaults to 0.1, with 10% chance returns a randomized elastic transform,
otherwise returns a ``spatial_size`` centered area extracted from the input image.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
diff --git a/monai/transforms/spatial/dictionary.py b/monai/transforms/spatial/dictionary.py
index b811da7f3d..51ad0435fc 100644
--- a/monai/transforms/spatial/dictionary.py
+++ b/monai/transforms/spatial/dictionary.py
@@ -1061,7 +1061,7 @@ def __init__(
prob: probability of returning a randomized affine grid.
defaults to 0.1, with 10% chance returns a randomized grid.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
@@ -1246,7 +1246,7 @@ def __init__(
defaults to 0.1, with 10% chance returns a randomized grid,
otherwise returns a ``spatial_size`` centered area extracted from the input image.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`
@@ -1396,7 +1396,7 @@ def __init__(
defaults to 0.1, with 10% chance returns a randomized grid,
otherwise returns a ``spatial_size`` centered area extracted from the input image.
rotate_range: angle range in radians. If element `i` is a pair of (min, max) values, then
- `uniform[-rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
+ `uniform[rotate_range[i][0], rotate_range[i][1])` will be used to generate the rotation parameter
for the `i`th spatial dimension. If not, `uniform[-rotate_range[i], rotate_range[i])` will be used.
This can be altered on a per-dimension basis. E.g., `((0,3), 1, ...)`: for dim0, rotation will be
in range `[0, 3]`, and for dim1 `[-1, 1]` will be used. Setting a single value will use `[-x, x]`