torch_ecg._preprocessors.preprocess_single_lead_signal¶
- torch_ecg._preprocessors.preprocess_single_lead_signal(raw_sig: ndarray, fs: Real, bl_win: List[Real] | None = None, band_fs: List[Real] | None = None, filter_type: str = 'butter', filter_order: int | None = None) ndarray [source]¶
Perform preprocessing for single lead ECG signal (with units in mV).
Preprocessing may include median filter, bandpass filter, and rpeaks detection, etc.
- Parameters:
raw_sig (numpy.ndarray) – Raw ECG signal, with units in mV.
fs (numbers.Real) – Sampling frequency of raw_sig.
bl_win (list (of 2 numbers.Real), optional) – Window (units in second) of baseline removal using
median_filter()
, the first is the shorter one, the second the longer one, a typical pair is[0.2, 0.6]
. If is None or empty, baseline removal will not be performed.band_fs (list of numbers.Real, optional) – Frequency band of the bandpass filter, a typical pair is
[0.5, 45]
. Be careful when detecting paced rhythm. If is None or empty, bandpass filtering will not be performed.filter_type ({"butter", "fir"}, optional) – Type of the bandpass filter, default “butter”.
filter_order (int, optional,) – Order of the bandpass filter.
- Returns:
filtered_ecg – The array of the processed ECG signal.
- Return type:
Note
Bandpass filter uses FIR filters, an alternative can be Butterworth filter, e.g.
butter_bandpass_filter()
.