RPeaksDetectionOutput

class torch_ecg.components.RPeaksDetectionOutput(*args: Any, **kwargs: Any)[source]

Bases: BaseOutput

Class that maintains the output of an R peaks detection task.

Parameters:
  • rpeak_indices (Sequence[Sequence[int]]) – Rpeak indices for each batch sample.

  • prob (numpy.ndarray) – Probabilities at each time step (each sample point), of shape (batch_size, signal_length).

Note

Known issues:

  • fields of type dict are not well supported due to the limitations of the base class CFG, for example

>>> output = RPeaksDetectionOutput(rpeak_indices=[[2]], thr=0.5, prob=np.ones((1,3,3)), d={"d":1})
>>> output
{'rpeak_indices': [[2]],
    'prob': array([[[1., 1., 1.],
            [1., 1., 1.],
            [1., 1., 1.]]]),
    'thr': 0.5,
    'd': {'d': 1}}
>>> output.d  # has to access via `output["d"]`
AttributeError: 'RPeaksDetectionOutput' object has no attribute 'd'
compute_metrics(fs: int, thr: float = 0.075) ClassificationMetrics[source]

Compute metrics from the output.

Parameters:
  • fs (int) – Sampling frequency of the signal corresponding to the masks.

  • thr (float, default 0.075) – Threshold for a prediction to be truth positive, with units in seconds.

Returns:

metrics – Metrics computed from the output.

Return type:

RPeaksDetectionMetrics

required_fields() Set[str][source]

The required fields of the output class.