WaveDelineationOutput#

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

Bases: SequenceTaggingOutput

Class that maintains the output of a wave delineation task.

Parameters:
  • classes (Sequence[str]) – class names.

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

  • mask (numpy.ndarray) – Predicted class indices at each time step (each sample point), or binary predictions at each time step (each sample point), of shape (batch_size, num_channels, signal_length).

compute_metrics(fs: int, class_map: Dict[str, int], macro: bool = True, tol: float = 0.15) → ClassificationMetrics[source]#

Compute metrics from the output

Parameters:
  • 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.

  • class_map (dict) – Class map, mapping names to waves to numbers from 0 to n_classes-1, the keys should contain “pwave”, “qrs”, “twave”.

  • macro (bool) – Whether to use macro-averaged metrics or not.

  • tol (float, default 0.15) – Tolerance for the duration of the waveform, with units in seconds.

Returns:

metrics – Metrics computed from the output

Return type:

WaveDelineationMetrics

required_fields() → Set[str][source]#

The required fields of the output class.