PreProcessor#

class torch_ecg._preprocessors.PreProcessor[source]#

Bases: ReprMixin, ABC

Base class for preprocessors.

A preprocessor wraps a preprocessing function together with its hyper-parameters (config) and applies it to single-lead or multi-lead ECG segments via __call__() / apply(); preprocess_multi_lead_signal() and preprocess_single_lead_signal() compose them.

abstractmethod apply(sig: NDArray, fs: int | float) → Tuple[NDArray, int | float][source]#

Apply the preprocessor to sig.

Parameters:
  • sig (numpy.ndarray) – The ECG signal, can be - 1d array, which is a single-lead ECG; - 2d array, which is a multi-lead ECG of “lead_first” format; - 3d array, which is a tensor of several ECGs, of shape (batch, lead, siglen).

  • fs (int or float) – Sampling frequency of the ECG signal.