BaselineRemove#

class torch_ecg.preprocessors.BaselineRemove(fs: Real, window1: float = 0.2, window2: float = 0.6, inplace: bool = True, **kwargs: Any)[source]#

Bases: Module

Baseline removal using sliding average (median filter alternative).

Parameters:
  • fs (numbers.Real) – Sampling frequency of the ECG signal to be filtered.

  • window1 (float, default 0.2) – The smaller window size, with units in seconds.

  • window2 (float, default 0.6) – The larger window size, with units in seconds.

  • inplace (bool, default True) – Whether to perform the filtering in-place.

  • kwargs (dict, optional) – Other keyword arguments for torch.nn.Module.

forward(sig: ndarray | Tensor) ndarray | Tensor[source]#

Apply the preprocessor to the signal.

Parameters:

sig (numpy.ndarray or torch.Tensor) – The ECG signal, of shape (batch, lead, siglen) or (lead, siglen).

Returns:

The baseline removed ECG signals, of same shape and type as sig.

Return type:

numpy.ndarray or torch.Tensor