Processing API Reference

Import: from ecgdatakit.processing import ...

Requires: pip install ecgdatakit[processing] (scipy ≥ 1.10)

All filter and transform functions accept a Lead and return a new Lead (immutable pattern via dataclasses.replace). The original lead is never modified.

Note

All processing functions accept both Lead objects and raw numpy arrays. When passing a numpy array, provide the sample rate via fs:

filtered = diagnostic_filter(my_array, fs=500)

See Data Models for details.

Filters

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()

AHA diagnostic: 0.05–150 Hz bandpass + notch

monitoring_filter()

Monitoring: 0.67–40 Hz bandpass + notch

Resampling

resample()

Resample a lead to a different sample rate

Normalization

All normalization functions accept a single lead or a list[Lead] for per-lead normalization.

normalize_minmax()

Scale signal to the [−1, 1] range

normalize_zscore()

Normalize to zero mean and unit variance (z-score)

normalize_amplitude()

Scale peak amplitude to a target value

R-Peak Detection

detect_r_peaks()

Detect R-peak locations in an ECG lead

heart_rate()

Compute average heart rate in beats per minute

rr_intervals()

Compute RR intervals in milliseconds

instantaneous_heart_rate()

Compute instantaneous heart rate at each beat

Heart Rate Variability

time_domain()

Compute time-domain HRV metrics from RR intervals

frequency_domain()

Compute frequency-domain HRV metrics from RR intervals

poincare()

Compute Poincaré plot descriptors (SD1, SD2)

Transforms & Segmentation

power_spectrum()

Compute the power spectral density of an ECG lead

fft()

Compute the single-sided FFT magnitude spectrum

segment_beats()

Segment individual heartbeats around R-peaks

average_beat()

Compute the ensemble-averaged heartbeat (template)

Signal Quality

signal_quality_index()

Composite signal quality index (SQI) in [0, 1]

classify_quality()

Classify signal quality as a human-readable category

snr_estimate()

Estimate signal-to-noise ratio in dB

Lead Derivation

derive_lead_iii()

Derive Lead III from Leads I and II (Einthoven’s law)

derive_augmented()

Derive augmented limb leads aVR, aVL, aVF

derive_standard_12()

Assemble a full 12-lead ECG

find_lead()

Find a lead by label (case-insensitive)

ECG Cleaning

clean_ecg()

Clean an ECG lead signal