BandPass#
- class torch_ecg._preprocessors.BandPass(lowcut: int | float | None = 0.5, highcut: int | float | None = 45, filter_type: Literal['butter', 'fir'] = 'butter', filter_order: int | None = None, **kwargs: Any)[source]#
Bases:
PreProcessorBandpass filtering preprocessor.
- Parameters:
filter_type ({"butter", "fir"}, , default "butter") – Type of the bandpass filter.
filter_order (int, optional) – Order of the bandpass filter.
**kwargs (dict, optional) – Other arguments for
PreProcessor.
Examples
from torch_ecg.cfg import DEFAULTS sig = DEFAULTS.RNG.randn(1000) pp = BandPass(lowcut=0.5, highcut=45, filter_type="butter", filter_order=4) sig, _ = pp(sig, 500)
- apply(sig: ndarray[tuple[Any, ...], dtype[_ScalarT]], fs: int | float) Tuple[ndarray[tuple[Any, ...], dtype[_ScalarT]], int | float][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).
- Returns:
filtered_sig (
numpy.ndarray) – Bandpass filtered ECG signal.fs (
int) – Sampling frequency of the filtered ECG signal.