U vPh @sPddlmZddlmZddlmZddlmZddlm Z GdddeZ dS) ) annotations)Callable)IgniteMetricHandler)SurfaceDistanceMetric)MetricReductionc sFeZdZdZdddejdddfdddd d dd d fd d ZZS)SurfaceDistancezv Computes surface distance from full size Tensor and collects average over batch, class-channels, iterations. F euclideancCs|S)N)xr r T/home/dell461/cl/sdc2/HISourceFinder-master-l/src/monai/handlers/surface_distance.py zSurfaceDistance.TboolstrzMetricReduction | strrNone)include_background symmetricdistance_metric reductionoutput_transform save_detailsreturncs&t||||d}tj|||ddS)a Args: include_background: whether to include distance computation on the first channel of the predicted output. Defaults to ``False``. symmetric: whether to calculate the symmetric average surface distance between `seg_pred` and `seg_gt`. Defaults to ``False``. distance_metric: : [``"euclidean"``, ``"chessboard"``, ``"taxicab"``] the metric used to compute surface distance. Defaults to ``"euclidean"``. reduction: define the mode to reduce metrics, will only execute reduction on `not-nan` values, available reduction modes: {``"none"``, ``"mean"``, ``"sum"``, ``"mean_batch"``, ``"sum_batch"``, ``"mean_channel"``, ``"sum_channel"``}, default to ``"mean"``. if "none", will not do reduction. output_transform: callable to extract `y_pred` and `y` from `ignite.engine.state.output` then construct `(y_pred, y)` pair, where `y_pred` and `y` can be `batch-first` Tensors or lists of `channel-first` Tensors. the form of `(y_pred, y)` is required by the `update()`. `engine.state` and `output_transform` inherit from the ignite concept: https://pytorch.org/ignite/concepts.html#state, explanation and usage example are in the tutorial: https://github.com/Project-MONAI/tutorials/blob/master/modules/batch_output_transform.ipynb. save_details: whether to save metric computation details per image, for example: surface dice of every image. default to True, will save to `engine.state.metric_details` dict with the metric name as key. )rrrr) metric_fnrrN)rsuper__init__)selfrrrrrrr __class__r r rszSurfaceDistance.__init__)__name__ __module__ __qualname____doc__rMEANr __classcell__r r rr rsrN) __future__rcollections.abcrmonai.handlers.ignite_metricr monai.metricsr monai.utilsrrr r r r  s