BaselineRemove

class torch_ecg._preprocessors.BaselineRemove(window1: float = 0.2, window2: float = 0.6, **kwargs: Any)[source]

Bases: PreProcessor

Baseline removal using median filter.

Parameters:
  • window1 (float, default 0.2) – The smaller window size of the median filter, with units in seconds.

  • highcut (float, default 0.6) – The larger window size of the median filter, with units in seconds.

Examples

from torch_ecg.cfg import DEFAULTS
sig = DEFAULTS.RNG.randn(1000)
pp = BaselineRemove(window1=0.2, window2=0.6)
sig, _ = pp(sig, 500)
apply(sig: ndarray, fs: Real) Tuple[ndarray, int][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 (numbers.Real) – Sampling frequency of the ECG signal.

Returns:

  • filtered_sig (numpy.ndarray) – The median filtered (hence baseline removed) ECG signal.

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

extra_repr_keys() List[str][source]

Extra keys for __repr__() and __str__().