Skip to content

Commit dda343e

Browse files
authored
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>
1 parent 7f6b7e5 commit dda343e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

monai/apps/nuclick/transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ def inclusion_map(self, mask, dtype):
367367

368368
def exclusion_map(self, others, dtype, jitter_range, drop_rate):
369369
point_mask = torch.zeros_like(others, dtype=dtype)
370-
if np.random.choice([True, False], p=[drop_rate, 1 - drop_rate]):
370+
if self.R.choice([True, False], p=[drop_rate, 1 - drop_rate]):
371371
return point_mask
372372

373373
max_x = point_mask.shape[0] - 1
374374
max_y = point_mask.shape[1] - 1
375375
stats = measure.regionprops(convert_to_numpy(others))
376376
for stat in stats:
377-
if np.random.choice([True, False], p=[drop_rate, 1 - drop_rate]):
377+
if self.R.choice([True, False], p=[drop_rate, 1 - drop_rate]):
378378
continue
379379

380380
# random jitter

0 commit comments

Comments
 (0)