Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions monai/apps/nuclick/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +370 to 371
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is intended to improve reproducibility by using the transform's local RandomState, but there’s no regression test covering deterministic behavior. Consider adding a unit test (e.g., in tests/apps/nuclick/test_nuclick_transforms.py) that sets AddPointGuidanceSignald.set_random_state(seed=...) (and/or runs under Compose.set_random_state) and asserts the produced exclusion map / output image is identical across repeated calls with the same seed and differs with a different seed.

Copilot uses AI. Check for mistakes.

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
Expand Down
Loading