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:
ModuleResample the signal into fixed sampling frequency or length.
- Parameters:
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: ndarray | Tensor) ndarray | Tensor[source]#
Apply the resampling to the signal.
- Parameters:
sig (numpy.ndarray or torch.Tensor) – The signal to be resampled, of shape
(..., n_leads, siglen).- Returns:
The resampled signal.
If sig is a
torch.Tensor, the output is a tensor.If sig is a
numpy.ndarray, the output is a NumPy array with floating dtype. When the input dtype is floating, the same floating dtype is preserved; otherwise,float32is used.
- Return type: