From 58d69c00c41ef4ae0c2b4ab42c9aa545ac771970 Mon Sep 17 00:00:00 2001 From: Szabolcs Botond Lorincz Molnar Date: Mon, 1 Apr 2024 10:31:27 +0200 Subject: [PATCH 1/2] ENH: generate_label_classes_crop_centers: warn only if ratio of missing class is not set to 0 --- monai/transforms/utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/monai/transforms/utils.py b/monai/transforms/utils.py index e282ecff24..7dfd4ee062 100644 --- a/monai/transforms/utils.py +++ b/monai/transforms/utils.py @@ -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_)) From 029dc31c6aa220210c8860b92f8cf26fe9ff068e Mon Sep 17 00:00:00 2001 From: Szabolcs Botond Lorincz Molnar Date: Mon, 1 Apr 2024 11:40:17 +0200 Subject: [PATCH 2/2] DCO Remediation Commit for Szabolcs Botond Lorincz Molnar I, Szabolcs Botond Lorincz Molnar , hereby add my Signed-off-by to this commit: 58d69c00c41ef4ae0c2b4ab42c9aa545ac771970 Signed-off-by: Szabolcs Botond Lorincz Molnar --- monai/transforms/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/transforms/utils.py b/monai/transforms/utils.py index 7dfd4ee062..455b0cfb7d 100644 --- a/monai/transforms/utils.py +++ b/monai/transforms/utils.py @@ -629,7 +629,7 @@ def generate_label_classes_crop_centers( 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." + f"no available indices of class {i} to crop, setting the crop ratio of this class to zero." ) centers = []