torch_ecg._preprocessors.preprocess_multi_lead_signal¶
- torch_ecg._preprocessors.preprocess_multi_lead_signal(raw_sig: ndarray, fs: Real, sig_fmt: str = 'channel_first', 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 multi-lead ECG signal (with units in mV).
preprocessing may include median filter, bandpass filter, and rpeaks detection, etc. Also works for single-lead ECG signal (setting
sig_fmt="channel_first"
).- Parameters:
raw_sig (numpy.ndarray) – The raw ECG signal, with units in mV.
fs (numbers.Real) – Sampling frequency of raw_sig.
sig_fmt (str, default "channel_first") – Format of the multi-lead ECG signal, “channel_last” (alias “lead_last”), or “channel_first” (alias “lead_first”).
bl_win (List[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[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. The format of the signal is kept the same with the original signal, i.e. sig_fmt.
- Return type: