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 median filtering.

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

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

  • window2 (float, default 0.6) – The larger window size of the median filter, 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: Tensor) Tensor[source]

Apply the preprocessor to the signal tensor.

Parameters:

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

Returns:

The median filtered (hence baseline removed) ECG signals, of shape (batch, lead, siglen).

Return type:

torch.Tensor