o  i !@sddlmZddlmZddlmZddlmZmZm Z m Z ddl m Z GdddeZ Gdd d eZGd d d eZGd d d eZdS)) annotations)Callable)IgniteMetricHandler) MAEMetric MSEMetric PSNRMetric RMSEMetric)MetricReductionc0eZdZdZejdddfdfd d ZZS)MeanSquaredErrorzh Computes Mean Squared Error from full size Tensor and collects average over batch, iterations. cC|SNxrrc/home/dell461/cl/sdc2/last_ska_mid/HISourceFinder-master-l/src/monai/handlers/regression_metrics.pyzMeanSquaredError.T reductionMetricReduction | stroutput_transformr save_detailsboolreturnNonec t|d}tj|||ddS)a Args: 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: mean squared error of every image. default to True, will save to `engine.state.metric_details` dict with the metric name as key. See also: :py:class:`monai.metrics.MSEMetric` r metric_fnrrN)rsuper__init__selfrrrr __class__rrr  zMeanSquaredError.__init__rrrrrrrr__name__ __module__ __qualname____doc__r MEANr __classcell__rrr#rr  r cr )MeanAbsoluteErrorzi Computes Mean Absolute Error from full size Tensor and collects average over batch, iterations. cCr r rrrrrr>rzMeanAbsoluteError.Trrrrrrrrcr)a Args: 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: mean squared error of every image. default to True, will save to `engine.state.metric_details` dict with the metric name as key. See also: :py:class:`monai.metrics.MAEMetric` rrN)rrr r!r#rrr ;r%zMeanAbsoluteError.__init__r&r'rrr#rr/6r.r/cr )RootMeanSquaredErrorzm Computes Root Mean Squared Error from full size Tensor and collects average over batch, iterations. cCr r rrrrrr_rzRootMeanSquaredError.Trrrrrrrrcr)a  Args: 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: mean squared error of every image. default to True, will save to `engine.state.metric_details` dict with the metric name as key. See also: :py:class:`monai.metrics.RMSEMetric` rrN)rrr r!r#rrr \r%zRootMeanSquaredError.__init__r&r'rrr#rr0Wr.r0cs0eZdZdZejdddfdfdd ZZS)PeakSignalToNoiseRatiozp Computes Peak Signal to Noise Ratio from full size Tensor and collects average over batch, iterations. cCr r rrrrrrrzPeakSignalToNoiseRatio.Tmax_val int | floatrrrrrrrrcs"t||d}tj|||ddS)a Args: max_val: The dynamic range of the images/volumes (i.e., the difference between the maximum and the minimum allowed values e.g. 255 for a uint8 image). 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: mean squared error of every image. default to True, will save to `engine.state.metric_details` dict with the metric name as key. reduction: {``"none"``, ``"mean"``, ``"sum"``, ``"mean_batch"``, ``"sum_batch"``, See also: :py:class:`monai.metrics.PSNRMetric` )r2rrN)rrr )r"r2rrrrr#rrr }s zPeakSignalToNoiseRatio.__init__) r2r3rrrrrrrrr'rrr#rr1xs r1N) __future__rcollections.abcrmonai.handlers.ignite_metricr monai.metricsrrrr monai.utilsr r r/r0r1rrrrs   !!!