# Copyright 2020 - 2021 MONAI Consortium
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import Callable, Union
from monai.handlers.iteration_metric import IterationMetric
from monai.metrics import DiceMetric
from monai.utils import MetricReduction
Computes Dice score metric from full size Tensor and collects average over batch, class-channels, iterations.
include_background: bool = True,
output_transform: Callable = lambda x: x,
device: Union[str, torch.device] = "cpu",
save_details: bool = True,
) -> None:
include_background: whether to include dice computation on the first channel of the predicted output.
Defaults to True.
output_transform: transform the ignite.engine.state.output into [y_pred, y] pair.
device: device specification in case of distributed computation usage.
save_details: whether to save metric computation details per image, for example: mean dice of every image.
default to True, will save to `engine.state.metric_details` dict with the metric name as key.
metric_fn = DiceMetric(