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 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 34c9659147..727bea124b 100644 Binary files a/tests/testing_data/CT_DICOM/17106 and b/tests/testing_data/CT_DICOM/7106 differ 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 81949d1077..ed1222f80d 100644 Binary files a/tests/testing_data/CT_DICOM/17136 and b/tests/testing_data/CT_DICOM/7136 differ 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 e9cbc38b01..edadf552b2 100644 Binary files a/tests/testing_data/CT_DICOM/17166 and b/tests/testing_data/CT_DICOM/7166 differ 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 cc579d5425..d4c0f0795e 100644 Binary files a/tests/testing_data/CT_DICOM/17196 and b/tests/testing_data/CT_DICOM/7196 differ