From d0d36df0e791c0e570d48f133ded1ce040efb52e Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Tue, 24 May 2022 10:26:33 +0100 Subject: [PATCH 1/2] improve test cases Signed-off-by: Wenqi Li --- tests/testing_data/CT_DICOM/{17106 => 7106} | Bin 3810 -> 3808 bytes tests/testing_data/CT_DICOM/{17136 => 7136} | Bin 3812 -> 3810 bytes tests/testing_data/CT_DICOM/{17166 => 7166} | Bin 3812 -> 3810 bytes tests/testing_data/CT_DICOM/{17196 => 7196} | Bin 3812 -> 3810 bytes 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/testing_data/CT_DICOM/{17106 => 7106} (92%) rename tests/testing_data/CT_DICOM/{17136 => 7136} (92%) rename tests/testing_data/CT_DICOM/{17166 => 7166} (92%) rename tests/testing_data/CT_DICOM/{17196 => 7196} (92%) diff --git a/tests/testing_data/CT_DICOM/17106 b/tests/testing_data/CT_DICOM/7106 similarity index 92% rename from tests/testing_data/CT_DICOM/17106 rename to tests/testing_data/CT_DICOM/7106 index 34c96591477a9aa24ed8cda79931908aaad240a7..727bea124b15505483d036c4f57e648ff62ec16c 100644 GIT binary patch delta 26 ecmaDP`#^R>3o|bdgRj4zqh}nL+&r1tpBn&pC}3o}0-gG+vDoMTaPMrKlCPRizq%>LW}l_v?} diff --git a/tests/testing_data/CT_DICOM/17136 b/tests/testing_data/CT_DICOM/7136 similarity index 92% rename from tests/testing_data/CT_DICOM/17136 rename to tests/testing_data/CT_DICOM/7136 index 81949d10775852eb1aa25a2b00f0d5ff3b8dc6cc..ed1222f80d06afcf018b2027f9e0d87837fdfa6d 100644 GIT binary patch delta 26 ecmaDN`$%>}3o|bdgRj4zqh}nL+&q~%kQ)GakO({g delta 28 jcmaDP`$Tp_3o}0-gG+vDoMTaPMrKlCPRizq%z@khm6r+V diff --git a/tests/testing_data/CT_DICOM/17166 b/tests/testing_data/CT_DICOM/7166 similarity index 92% rename from tests/testing_data/CT_DICOM/17166 rename to tests/testing_data/CT_DICOM/7166 index e9cbc38b01c742fc5b2646e55f8a4252c723a72a..edadf552b2d70b646f61a287103a78239d45bebb 100644 GIT binary patch delta 26 ecmaDN`$%>}3o|bdgRj4zqh}nL+&q~%kQ)GakO({g delta 28 jcmaDP`$Tp_3o}0-gG+vDoMTaPMrKlCPRizq%z@khm6r+V diff --git a/tests/testing_data/CT_DICOM/17196 b/tests/testing_data/CT_DICOM/7196 similarity index 92% rename from tests/testing_data/CT_DICOM/17196 rename to tests/testing_data/CT_DICOM/7196 index cc579d5425975c388bb6aab998508ba836984409..d4c0f0795e3044e68891e83e29b14aafffc4a293 100644 GIT binary patch delta 26 ecmaDN`$%>}3o|bdgRj4zqh}nL+&q~%kQ)GakO({g delta 28 jcmaDP`$Tp_3o}0-gG+vDoMTaPMrKlCPRizq%z@khm6r+V From b0901216ee9c389db9a6e11f74054ea369a843a9 Mon Sep 17 00:00:00 2001 From: Wenqi Li Date: Tue, 24 May 2022 10:34:44 +0100 Subject: [PATCH 2/2] revise docstring Signed-off-by: Wenqi Li --- monai/metrics/confusion_matrix.py | 2 +- monai/metrics/meandice.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/monai/metrics/confusion_matrix.py b/monai/metrics/confusion_matrix.py index 9d5af51a58..38834ee8cf 100644 --- a/monai/metrics/confusion_matrix.py +++ b/monai/metrics/confusion_matrix.py @@ -30,7 +30,7 @@ class ConfusionMatrixMetric(CumulativeIterationMetric): The `include_background` parameter can be set to ``False`` for an instance to exclude the first category (channel index 0) which is by convention assumed to be background. If the non-background segmentations are small compared to the total image size they can get overwhelmed by the signal from the - background so excluding it in such cases helps convergence. + background. Args: include_background: whether to skip metric computation on the first channel of diff --git a/monai/metrics/meandice.py b/monai/metrics/meandice.py index b64c556d05..c450e17c5f 100644 --- a/monai/metrics/meandice.py +++ b/monai/metrics/meandice.py @@ -22,14 +22,14 @@ class DiceMetric(CumulativeIterationMetric): """ - Compute average Dice loss between two tensors. It can support both multi-classes and multi-labels tasks. + Compute average Dice score between two tensors. It can support both multi-classes and multi-labels tasks. Input `y_pred` is compared with ground truth `y`. `y_preds` is expected to have binarized predictions and `y` should be in one-hot format. You can use suitable transforms in ``monai.transforms.post`` first to achieve binarized values. - The `include_background` parameter can be set to ``False`` for an instance of DiceLoss to exclude + The `include_background` parameter can be set to ``False`` to exclude the first category (channel index 0) which is by convention assumed to be background. If the non-background segmentations are small compared to the total image size they can get overwhelmed by the signal from the - background so excluding it in such cases helps convergence. + background. `y_preds` and `y` can be a list of channel-first Tensor (CHW[D]) or a batch-first Tensor (BCHW[D]). Args: @@ -80,7 +80,7 @@ def _compute_tensor(self, y_pred: torch.Tensor, y: torch.Tensor): # type: ignor warnings.warn("y should be a binarized tensor.") dims = y_pred.ndimension() if dims < 3: - raise ValueError("y_pred should have at least three dimensions.") + raise ValueError(f"y_pred should have at least 3 dimensions (batch, channel, spatial), got {dims}.") # compute dice (BxC) for each channel for each batch return compute_meandice( y_pred=y_pred, y=y, include_background=self.include_background, ignore_empty=self.ignore_empty