Filters

All filters use SOS (second-order sections) + zero-phase sosfiltfilt to preserve ECG morphology.

lowpass()

Apply a Butterworth low-pass filter

highpass()

Apply a Butterworth high-pass filter

bandpass()

Apply a Butterworth band-pass filter

notch()

Apply an IIR notch (band-stop) filter

remove_baseline()

Remove baseline wander using a high-pass filter

diagnostic_filter()

Apply AHA diagnostic-grade filtering: 0.05–150 Hz bandpass + notch

monitoring_filter()

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.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • cutoff (float) – Cutoff frequency in Hz.

  • order (int) – Filter order (default 4).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

ecgdatakit.processing.highpass(lead, cutoff, order=4, *, fs=None)[source]

Apply a Butterworth high-pass filter.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • cutoff (float) – Cutoff frequency in Hz.

  • order (int) – Filter order (default 4).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

ecgdatakit.processing.bandpass(lead, low, high, order=4, *, fs=None)[source]

Apply a Butterworth band-pass filter.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • low (float) – Lower cutoff frequency in Hz.

  • high (float) – Upper cutoff frequency in Hz.

  • order (int) – Filter order (default 4).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

ecgdatakit.processing.notch(lead, freq=50.0, quality=30.0, *, fs=None)[source]

Apply an IIR notch (band-stop) filter.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • freq (float) – Center frequency to remove (default 50 Hz for mains hum).

  • quality (float) – Quality factor — higher means narrower notch (default 30).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

ecgdatakit.processing.remove_baseline(lead, cutoff=0.5, order=2, *, fs=None)[source]

Remove baseline wander using a high-pass filter.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • cutoff (float) – Cutoff frequency in Hz (default 0.5 Hz).

  • order (int) – Filter order (default 2).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

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.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • notch_freq (float) – Power-line frequency to notch out (50 or 60 Hz).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead

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.

Parameters:
  • lead (Lead | ndarray[tuple[Any, ...], dtype[double]]) – Input ECG lead or raw signal array.

  • notch_freq (float) – Power-line frequency to notch out (50 or 60 Hz).

  • fs (int | None) – Sample rate in Hz. Required when lead is a numpy array.

Return type:

Lead