Resample#
- class torch_ecg._preprocessors.Resample(fs: int | None = None, siglen: int | None = None, **kwargs: Any)[source]#
Bases:
PreProcessorResample the signal into fixed sampling frequency or length.
- Parameters:
Note
One and only one of fs and siglen should be set.
Examples
from torch_ecg.cfg import DEFAULTS sig = DEFAULTS.RNG.randn(1000) pp = Resample(fs=500) sig, _ = pp(sig, 250)
- 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:
rsmp_sig (
numpy.ndarray) – The resampled ECG signal.new_fs (
int,) – Sampling frequency of the resampled ECG signal.