Skip to content

Commit 5d1456e

Browse files
committed
refactor: Remove dead compute_channel method from DiceHelper
No longer called after vectorization of __call__(). Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
1 parent 8b2e316 commit 5d1456e

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

monai/metrics/meandice.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -278,25 +278,6 @@ def __init__(
278278
self.ignore_empty = ignore_empty
279279
self.num_classes = num_classes
280280

281-
def compute_channel(self, y_pred: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
282-
"""
283-
Compute the dice metric for binary inputs which have only spatial dimensions. This method is called separately
284-
for each batch item and for each channel of those items.
285-
286-
Args:
287-
y_pred: input predictions with shape HW[D].
288-
y: ground truth with shape HW[D].
289-
"""
290-
y_o = torch.sum(y)
291-
if y_o > 0:
292-
return (2.0 * torch.sum(torch.masked_select(y, y_pred))) / (y_o + torch.sum(y_pred))
293-
if self.ignore_empty:
294-
return torch.tensor(float("nan"), device=y_o.device)
295-
denorm = y_o + torch.sum(y_pred)
296-
if denorm <= 0:
297-
return torch.tensor(1.0, device=y_o.device)
298-
return torch.tensor(0.0, device=y_o.device)
299-
300281
def __call__(self, y_pred: torch.Tensor, y: torch.Tensor) -> torch.Tensor | tuple[torch.Tensor, torch.Tensor]:
301282
"""
302283
Compute the metric for the given prediction and ground truth.

0 commit comments

Comments
 (0)