Filters¶
All filters use SOS (second-order sections) + zero-phase sosfiltfilt to preserve ECG morphology.
Input must be a single finite lead (1-D). NaN or Inf samples raise
ValueError, since one NaN would spread over the whole filtered output. Signals shorter than the filter’s edge padding (27 samples for a 4th-order band-pass) also raiseValueError.Raw leads are filtered in ADC counts. Their
offsetis folded into the samples, soto_physical()after filtering gives the same result as filtering the physical signal.diagnostic_filterandmonitoring_filterlower their upper cutoff to0.45 * fswhen the sampling rate is too low (e.g. 81 Hz instead of 150 Hz at 180 Hz), and skip a notch that is not below Nyquist. Both cases emit a warning that points at your code.clean_ecg(method="default")applies the same rule to its 40 Hz cutoff (27 Hz at 60 Hz). Passnotch_freq=Noneto disable the notch, ornotch_freq=60for 60 Hz mains.
Apply a Butterworth low-pass filter |
|
Apply a Butterworth high-pass filter |
|
Apply a Butterworth band-pass filter |
|
Apply an IIR notch (band-stop) filter |
|
Remove baseline wander using a high-pass filter |
|
Apply AHA diagnostic-grade filtering: 0.05–150 Hz bandpass + notch |
|
Apply monitoring-grade filtering: 0.67–40 Hz bandpass + notch |
- ecgdatakit.processing.lowpass(lead, cutoff, order=4, *, fs=None)[source]¶
Apply a Butterworth low-pass filter.
- ecgdatakit.processing.highpass(lead, cutoff, order=4, *, fs=None)[source]¶
Apply a Butterworth high-pass filter.
- ecgdatakit.processing.bandpass(lead, low, high, order=4, *, fs=None)[source]¶
Apply a Butterworth band-pass filter.
- Parameters:
- Return type:
- ecgdatakit.processing.notch(lead, freq=50.0, quality=30.0, *, fs=None)[source]¶
Apply an IIR notch (band-stop) filter.
- Parameters:
- Return type:
- ecgdatakit.processing.remove_baseline(lead, cutoff=0.5, order=2, *, fs=None)[source]¶
Remove baseline wander using a high-pass filter.
- ecgdatakit.processing.diagnostic_filter(lead, notch_freq=50.0, *, fs=None)[source]¶
Apply AHA diagnostic-grade filtering: 0.05–150 Hz bandpass + notch.
Suitable for diagnostic ECG interpretation where full morphology (including ST segment) must be preserved.
The 150 Hz upper cutoff needs a sampling rate above 333 Hz. At lower rates (e.g. 180 or 250 Hz Holter recordings) it is lowered to
0.45 * fsand a warning is emitted. The notch is skipped with a warning when notch_freq is not below the Nyquist frequency.
- ecgdatakit.processing.monitoring_filter(lead, notch_freq=50.0, *, fs=None)[source]¶
Apply monitoring-grade filtering: 0.67–40 Hz bandpass + notch.
Suitable for arrhythmia monitoring where baseline stability is more important than preserving fine morphology. As in
diagnostic_filter(), the upper cutoff is lowered to0.45 * fsat low sampling rates and an impossible notch is skipped, both with a warning.