RPeaksDetectionMetrics¶
- class torch_ecg.components.RPeaksDetectionMetrics(thr: float = 0.075, extra_metrics: Callable | None = None)[source]¶
Bases:
Metrics
Metrics for the task of R peaks detection, as proposed in CPSC2019.
- Parameters:
thr (float, default 0.075) – Threshold for a prediction to be truth positive, with units in seconds,
extra_metrics (callable, optional) –
Extra metrics to compute, has to be a function with signature
def extra_metrics( labels : Sequence[Union[Sequence[int], np.ndarray]], outputs : Sequence[Union[Sequence[int], np.ndarray]], fs : int ) -> dict
- compute(labels: Sequence[ndarray | Sequence[int]], outputs: Sequence[ndarray | Sequence[int]], fs: int, thr: float | None = None) RPeaksDetectionMetrics [source]¶
QRS accuracy score, proposed in CPSC2019.
- Parameters:
labels (array_like) – array of ground truths of rpeaks locations (indices) from multiple records.
outputs (array_like) – predictions of ground truths of rpeaks locations (indices) for multiple records.
fs (numbers.Real) – Sampling frequency of ECG signal
thr (float, optional, defaults to self.thr) – Threshold for a prediction to be truth positive, with units in seconds.
- Returns:
self – The metrics object itself with the computed metrics.
Examples
>>> labels = [np.array([500, 1000])] >>> outputs = [np.array([500, 700, 1000])] # a false positive at 700 >>> metrics = RPeaksDetectionMetrics() >>> metrics = metrics.compute(labels, outputs, fs=500) >>> metrics.qrs_score 0.7
- Return type: