Resample

class torch_ecg.preprocessors.Resample(fs: int | None = None, dst_fs: int | None = None, siglen: int | None = None, inplace: bool = False, **kwargs: Any)[source]

Bases: Module

Resample the signal into fixed sampling frequency or length.

Parameters:
  • fs (int, optional) – Sampling frequency of the source signal to be resampled.

  • dst_fs (int, optional) – Sampling frequency of the resampled ECG.

  • siglen (int, optional) – Number of samples in the resampled ECG.

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

Note

One and only one of fs and siglen should be set. If fs is set, src_fs should also be set.

TODO

Consider vectorized scipy.signal.resample()?

forward(sig: Tensor) Tensor[source]

Apply the resampling to the signal tensor.

Parameters:

sig (torch.Tensor) – The signal tensor to be resampled, of shape (..., n_leads, siglen).

Returns:

The resampled signal tensor, of shape (..., n_leads, siglen).

Return type:

torch.Tensor