From dda343ecb148d639d81e52c3f4777eb6e8198d87 Mon Sep 17 00:00:00 2001 From: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com> Date: Mon, 20 Apr 2026 17:14:52 +0200 Subject: [PATCH] fix(apps/nuclick): replace np.random.choice with self.R.choice in AddPointGuidanceSignald In AddPointGuidanceSignald.exclusion_map, two calls to np.random.choice were using the global NumPy random state instead of the instance's self.R (RandomState). Since AddPointGuidanceSignald already inherits from Randomizable, replacing with self.R.choice ensures reproducibility when set_determinism() or manual seeding is used. Ref #6888 Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com> Signed-off-by: Zeeshan Modi <92383127+Zeesejo@users.noreply.github.com> --- monai/apps/nuclick/transforms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monai/apps/nuclick/transforms.py b/monai/apps/nuclick/transforms.py index 4828bd2e5a..6b6542308a 100644 --- a/monai/apps/nuclick/transforms.py +++ b/monai/apps/nuclick/transforms.py @@ -367,14 +367,14 @@ def inclusion_map(self, mask, dtype): def exclusion_map(self, others, dtype, jitter_range, drop_rate): point_mask = torch.zeros_like(others, dtype=dtype) - if np.random.choice([True, False], p=[drop_rate, 1 - drop_rate]): + if self.R.choice([True, False], p=[drop_rate, 1 - drop_rate]): return point_mask max_x = point_mask.shape[0] - 1 max_y = point_mask.shape[1] - 1 stats = measure.regionprops(convert_to_numpy(others)) for stat in stats: - if np.random.choice([True, False], p=[drop_rate, 1 - drop_rate]): + if self.R.choice([True, False], p=[drop_rate, 1 - drop_rate]): continue # random jitter