torch_ecg.utils.compute_wave_delineation_metrics#
- torch_ecg.utils.compute_wave_delineation_metrics(truth_masks: Sequence[NDArray], pred_masks: Sequence[NDArray], class_map: Dict[str, int], fs: int, mask_format: str = 'channel_first', tol: float = 0.15) Dict[str, Dict[str, float]][source]#
Compute metrics for the task of ECG wave delineation (sensitivity, precision, f1_score, mean error and standard deviation of the mean errors) for multiple evaluations.
- Parameters:
truth_masks (Sequence[numpy.ndarray]) – A sequence of ground truth masks, each of which can also hold multiple masks from different samples (differ by record or by lead). Each mask is of shape
(n_channels, n_timesteps)or(n_timesteps, n_channels).pred_masks (Sequence[numpy.ndarray]) – Predictions corresponding to truth_masks, of the same shapes.
class_map (dict) – Class map, mapping names to waves to numbers from 0 to n_classes-1, the keys should contain “pwave”, “qrs”, “twave”.
fs (int) – Sampling frequency of the signal corresponding to the masks, used to compute the duration of each waveform, and thus the error and standard deviations of errors.
mask_format (str, default "channel_first") – Format of the mask, one of the following: “channel_last” (alias “lead_last”), or “channel_first” (alias “lead_first”)
tol (float, default 0.15) – Tolerance for the duration of the waveform, with units in seconds.
- Returns:
scorings – scorings of onsets and offsets of pwaves, qrs complexes, twaves. Each scoring is a dict consisting of the following metrics: sensitivity, precision, f1_score, mean_error, standard_deviation
- Return type: