Skip to content

Commit

Permalink
ENH: generate_label_classes_crop_centers: warn only if ratio of missi…
Browse files Browse the repository at this point in the history
…ng class is not set to 0
  • Loading branch information
lorinczszabolcs committed Apr 1, 2024
1 parent c885100 commit 58d69c0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions monai/transforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,12 @@ def generate_label_classes_crop_centers(

for i, array in enumerate(indices):
if len(array) == 0:
ratios_[i] = 0
if warn:
warnings.warn(f"no available indices of class {i} to crop, set the crop ratio of this class to zero.")
if ratios_[i] != 0:
ratios_[i] = 0
if warn:
warnings.warn(
f"no available indices of class {i} to crop, set the crop ratio of this class to zero."
)

centers = []
classes = rand_state.choice(len(ratios_), size=num_samples, p=np.asarray(ratios_) / np.sum(ratios_))
Expand Down

0 comments on commit 58d69c0

Please sign in to comment.