Function Reference

Processing Functions

ECG Cleaning

ecgdatakit.processing.clean_ecg(lead, method='default', *, fs=None, **kwargs)[source]

Clean an ECG lead signal.

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

  • method (str) – Cleaning method: "default", "biosppy", "neurokit2", "combined", or "deepfade".

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

  • **kwargs

    Extra arguments forwarded to the selected backend:

    • device (str): PyTorch device for "deepfade" (default "cpu").

    • weights_path (str | Path): Override the bundled DeepFADE weights.

    • batch_size (int): Inference batch size for "deepfade" (default 32).

Returns:

Cleaned lead (new object, original unchanged).

Return type:

Lead

Filters

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

Resampling

ecgdatakit.processing.resample(lead, target_rate, *, fs=None)[source]

Resample a lead to a different sample rate.

Uses polyphase rational resampling (scipy.signal.resample_poly) which preserves signal content up to the Nyquist frequency of the lower sample rate.

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

  • target_rate (int) – Desired output sample rate in Hz.

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

Return type:

Lead

Normalization

ecgdatakit.processing.normalize_minmax(data)[source]
Overloads:
  • data (Lead) → Lead

  • data (list[Lead]) → list[Lead]

  • data (ECGRecord) → ECGRecord

  • data (list[ECGRecord]) → list[ECGRecord]

  • data (NDArray[np.float64]) → NDArray[np.float64]

Parameters:

data (Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, ...], dtype[float64]])

Return type:

Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, …], dtype[float64]]

Scale signal to the [-1, 1] range.

Normalization is applied per lead, per ECG.

Accepted inputs:

  • Lead — single lead.

  • list[Lead] — multiple leads (e.g. a 12-lead ECG).

  • ECGRecord — all leads and median beats in the record.

  • list[ECGRecord] — multiple records.

  • 3-D numpy array (n_ecgs, n_leads, n_samples) — raw multi-ECG data.

Returns the same type as the input.

ecgdatakit.processing.normalize_zscore(data)[source]
Overloads:
  • data (Lead) → Lead

  • data (list[Lead]) → list[Lead]

  • data (ECGRecord) → ECGRecord

  • data (list[ECGRecord]) → list[ECGRecord]

  • data (NDArray[np.float64]) → NDArray[np.float64]

Parameters:

data (Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, ...], dtype[float64]])

Return type:

Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, …], dtype[float64]]

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

Normalization is applied per lead, per ECG.

Accepted inputs:

  • Lead — single lead.

  • list[Lead] — multiple leads (e.g. a 12-lead ECG).

  • ECGRecord — all leads and median beats in the record.

  • list[ECGRecord] — multiple records.

  • 3-D numpy array (n_ecgs, n_leads, n_samples) — raw multi-ECG data.

Returns the same type as the input.

ecgdatakit.processing.normalize_amplitude(data, target_mv=1.0)[source]
Overloads:
  • data (Lead), target_mv (float) → Lead

  • data (list[Lead]), target_mv (float) → list[Lead]

  • data (ECGRecord), target_mv (float) → ECGRecord

  • data (list[ECGRecord]), target_mv (float) → list[ECGRecord]

  • data (NDArray[np.float64]), target_mv (float) → NDArray[np.float64]

Parameters:
Return type:

Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, …], dtype[float64]]

Scale signal so that its maximum absolute amplitude equals target_mv.

Normalization is applied per lead, per ECG.

Accepted inputs:

  • Lead — single lead.

  • list[Lead] — multiple leads (e.g. a 12-lead ECG).

  • ECGRecord — all leads and median beats in the record.

  • list[ECGRecord] — multiple records.

  • 3-D numpy array (n_ecgs, n_leads, n_samples) — raw multi-ECG data.

Returns the same type as the input.

Parameters:
Return type:

Lead | list[Lead] | ECGRecord | list[ECGRecord] | ndarray[tuple[Any, …], dtype[float64]]

R-Peak Detection

ecgdatakit.processing.detect_r_peaks(lead, method='pan_tompkins', *, fs=None)[source]

Detect R-peak locations in an ECG lead.

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

  • method (str) – Detection algorithm: "pan_tompkins" or "shannon_energy".

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

Returns:

Array of sample indices where R-peaks were detected.

Return type:

ndarray[tuple[Any, ...], dtype[int_]]

ecgdatakit.processing.heart_rate(lead, peaks=None, *, fs=None)[source]

Compute average heart rate in beats per minute.

Parameters:
Return type:

float

ecgdatakit.processing.rr_intervals(lead, peaks=None, *, fs=None)[source]

Compute RR intervals in milliseconds.

Parameters:
Return type:

ndarray[tuple[Any, ...], dtype[double]]

ecgdatakit.processing.instantaneous_heart_rate(lead, peaks=None, *, fs=None)[source]

Compute instantaneous heart rate at each beat in bpm.

Parameters:
Return type:

ndarray[tuple[Any, ...], dtype[double]]

Heart Rate Variability

ecgdatakit.processing.time_domain(rr_ms)[source]

Compute time-domain HRV metrics from RR intervals.

Parameters:

rr_ms (ndarray[tuple[Any, ...], dtype[double]]) – RR intervals in milliseconds.

Returns:

Keys: mean_rr, sdnn, rmssd, sdsd, nn50_count, pnn50, nn20_count, pnn20, hr_mean, hr_std.

Return type:

dict

ecgdatakit.processing.frequency_domain(rr_ms, method='welch', interp_fs=4.0)[source]

Compute frequency-domain HRV metrics from RR intervals.

RR intervals are interpolated to a uniform time series at interp_fs Hz, then the power spectral density is estimated.

Parameters:
  • rr_ms (ndarray[tuple[Any, ...], dtype[double]]) – RR intervals in milliseconds.

  • method (str) – PSD method ("welch").

  • interp_fs (float) – Interpolation sampling rate in Hz (default 4.0).

Returns:

Keys: vlf_power, lf_power, hf_power, lf_hf_ratio, total_power.

Return type:

dict

ecgdatakit.processing.poincare(rr_ms)[source]

Compute Poincaré plot descriptors (SD1, SD2).

Parameters:

rr_ms (ndarray[tuple[Any, ...], dtype[double]]) – RR intervals in milliseconds.

Returns:

Keys: sd1, sd2, sd1_sd2_ratio.

Return type:

dict

Transforms & Segmentation

ecgdatakit.processing.power_spectrum(lead, method='welch', nperseg=None, *, fs=None)[source]

Compute the power spectral density of an ECG lead.

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

  • method (str) – "welch" (default) for Welch’s method.

  • nperseg (int | None) – Segment length for Welch’s method. Defaults to min(256, len(samples)).

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

Returns:

(frequencies, power) arrays.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[double]], ndarray[tuple[Any, ...], dtype[double]]]

ecgdatakit.processing.fft(lead, *, fs=None)[source]

Compute the single-sided FFT magnitude spectrum.

Parameters:
Returns:

(frequencies, magnitudes) arrays (positive frequencies only).

Return type:

tuple[ndarray[tuple[Any, ...], dtype[double]], ndarray[tuple[Any, ...], dtype[double]]]

ecgdatakit.processing.segment_beats(lead, peaks=None, before=0.2, after=0.4, *, fs=None)[source]

Segment individual heartbeats around R-peaks.

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

  • peaks (ndarray[tuple[Any, ...], dtype[int_]] | None) – R-peak indices. Detected automatically if None.

  • before (float) – Seconds before R-peak to include (default 0.2).

  • after (float) – Seconds after R-peak to include (default 0.4).

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

Returns:

One Lead per beat, labelled "{label}_beat_{i}".

Return type:

list[Lead]

ecgdatakit.processing.average_beat(lead, peaks=None, before=0.2, after=0.4, *, fs=None)[source]

Compute the ensemble-averaged heartbeat (template).

Parameters:
Returns:

Averaged beat labelled "{label}_avg".

Return type:

Lead

Signal Quality

ecgdatakit.processing.signal_quality_index(lead, *, fs=None)[source]

Compute a composite signal quality index (SQI) in the range [0, 1].

Combines four sub-metrics: kurtosis SQI, power-ratio SQI, R-peak regularity SQI, and baseline stability SQI.

Parameters:
Returns:

Score between 0.0 (unusable) and 1.0 (excellent).

Return type:

float

ecgdatakit.processing.classify_quality(lead, *, fs=None)[source]

Classify signal quality as a human-readable category.

Parameters:
Returns:

"excellent" (SQI > 0.8), "acceptable" (0.5–0.8), or "unacceptable" (< 0.5).

Return type:

str

ecgdatakit.processing.snr_estimate(lead, *, fs=None)[source]

Estimate signal-to-noise ratio in dB.

Uses a frequency-domain approach: signal power in 1–40 Hz vs noise power above 100 Hz (up to Nyquist).

Parameters:
Returns:

Estimated SNR in decibels.

Return type:

float

Lead Derivation

ecgdatakit.processing.derive_lead_iii(lead_i, lead_ii, *, fs=None)[source]

Derive Lead III from Leads I and II (Einthoven’s law: III = II - I).

Parameters:
Return type:

Lead

ecgdatakit.processing.derive_augmented(lead_i, lead_ii, *, fs=None)[source]

Derive augmented limb leads aVR, aVL, aVF from Leads I and II.

Parameters:
Returns:

[aVR, aVL, aVF] in that order.

Return type:

list[Lead]

ecgdatakit.processing.derive_standard_12(lead_i, lead_ii, v1, v2, v3, v4, v5, v6, *, fs=None)[source]

Assemble a full 12-lead ECG, deriving III, aVR, aVL, aVF.

Parameters:
Returns:

12 leads in standard order: I, II, III, aVR, aVL, aVF, V1–V6.

Return type:

list[Lead]

ecgdatakit.processing.find_lead(leads, label)[source]

Find a lead by label (case-insensitive).

Parameters:
  • leads (list[Lead]) – List of leads to search.

  • label (str) – Lead label to find (e.g., “II”, “avl”, “V1”).

Return type:

Lead | None

Plotting Functions

Static Plots (matplotlib)

ecgdatakit.plotting.plot_lead(lead, peaks=None, title=None, show_grid=False, figsize=(12, 3), ax=None, *, fs=None, show=True, x_axis='time')[source]

Plot a single ECG lead waveform.

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

  • peaks (ndarray[tuple[Any, ...], dtype[int_]] | None) – Optional R-peak indices to mark.

  • title (str | None) – Figure title. Defaults to the lead label.

  • show_grid (bool) – Draw ECG paper-style grid (default True).

  • figsize (tuple[float, float]) – Figure size in inches (default (12, 3)).

  • ax (Axes | None) – Existing axes to draw on. A new figure is created if None.

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

  • show (bool) – Display the plot immediately (default True). Set to False to return the figure without displaying.

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices (1, 2, …, N).

Return type:

Figure

ecgdatakit.plotting.plot_leads(leads, peaks_dict=None, title=None, show_grid=False, figsize=(12, None), share_x=True, *, fs=None, show=True, x_axis='time', rows=None, cols=None)[source]

Plot multiple leads in a grid layout (vertical stack by default).

Parameters:
  • leads (list[Lead] | ECGRecord | ndarray[tuple[Any, ...], dtype[double]] | list[ndarray[tuple[Any, ...], dtype[double]]]) – Leads to plot. Also accepts a 2-D numpy array (n_leads × n_samples) or a list of 1-D numpy arrays.

  • peaks_dict (dict[str, ndarray[tuple[Any, ...], dtype[int_]]] | None) – {label: peaks_array} for per-lead R-peak markers.

  • title (str | None) – Overall figure title.

  • show_grid (bool) – Draw ECG paper-style grid.

  • figsize (tuple[float, float | None]) – Width is fixed; height is auto-calculated (2 in per row) when None.

  • share_x (bool) – Share the x-axis across all subplots (default True).

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • rows (int | None) – Number of rows in the subplot grid. Derived from cols or defaults to one row per lead when neither is given.

  • cols (int | None) – Number of columns in the subplot grid (default 1).

Return type:

Figure

ecgdatakit.plotting.plot_12lead(leads, record=None, title=None, show_grid=False, figsize=(12, None), share_x=True, *, fs=None, show=True, x_axis='time', rows=None, cols=None)[source]

Plot 12 leads with standard lead names (I, II, III, aVR, …, V6).

Unlike plot_leads(), this function assigns the standard 12-lead names when the input contains unnamed leads (e.g. a raw numpy array). The full signal is plotted without cropping.

Parameters:
  • leads (list[Lead] | ECGRecord | ndarray[tuple[Any, ...], dtype[double]] | list[ndarray[tuple[Any, ...], dtype[double]]]) – Leads (or full record) to plot. Also accepts a 2-D numpy array (n_leads × n_samples) or a list of 1-D numpy arrays.

  • record (ECGRecord | None) – If provided, a header with patient/device/measurement info is shown.

  • title (str | None) – Overall figure title.

  • show_grid (bool) – Draw ECG paper-style grid (default True).

  • figsize (tuple[float, float | None]) – Width is fixed; height is auto-calculated (2 in per row) when None.

  • share_x (bool) – Share the x-axis across all subplots (default True).

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • rows (int | None) – Number of rows in the subplot grid. Derived from cols or defaults to one row per lead when neither is given.

  • cols (int | None) – Number of columns in the subplot grid (default 1).

Return type:

Figure

ecgdatakit.plotting.plot_peaks(lead, peaks=None, title=None, figsize=(12, 3), ax=None, *, fs=None, show=True, x_axis='time')[source]

Plot lead with R-peak markers and RR interval annotations.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_beats(lead, beats=None, peaks=None, overlay=True, figsize=(8, 5), ax=None, *, fs=None, show=True)[source]

Plot segmented heartbeats.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_average_beat(lead, peaks=None, before=0.2, after=0.4, figsize=(6, 4), ax=None, *, fs=None, show=True)[source]

Plot ensemble-averaged beat with ±1 SD shading.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_spectrum(lead, method='welch', figsize=(10, 4), ax=None, *, fs=None, show=True)[source]

Plot power spectral density or FFT magnitude spectrum.

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

  • method (str) – "welch" for PSD or "fft" for magnitude spectrum.

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

  • show (bool) – Display the plot immediately (default True).

  • figsize (tuple[float, float])

  • ax (Axes | None)

Return type:

Figure

ecgdatakit.plotting.plot_spectrogram(lead, nperseg=256, figsize=(12, 4), ax=None, *, fs=None, show=True)[source]

Plot time-frequency spectrogram (STFT).

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

  • nperseg (int) – Segment length for STFT.

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

  • show (bool) – Display the plot immediately (default True).

  • figsize (tuple[float, float])

  • ax (Axes | None)

Return type:

Figure

ecgdatakit.plotting.plot_rr_tachogram(rr_ms, figsize=(10, 3), ax=None, *, show=True)[source]

Plot RR interval tachogram.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_poincare(rr_ms, figsize=(6, 6), ax=None, *, show=True)[source]

Poincaré plot: RR(n) vs RR(n+1) with SD1/SD2 ellipse.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_hrv_summary(rr_ms, figsize=(14, 8), *, show=True)[source]

Combined HRV dashboard: tachogram, Poincaré, frequency bands, metrics.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_quality(leads, figsize=(10, 5), *, fs=None, show=True)[source]

Signal quality dashboard: SQI bar chart per lead.

Parameters:
Return type:

Figure

ecgdatakit.plotting.plot_report(record, figsize=(16, 20), *, show=True)[source]

Comprehensive ECG report page.

Includes header with patient/device info, 12-lead grid, rhythm strip, and quality indicators.

Parameters:
Return type:

Figure

Interactive Plots (plotly)

ecgdatakit.plotting.iplot_lead(lead, peaks=None, title=None, height=300, *, fs=None, show=True, x_axis='time')[source]

Interactive single lead with hover showing time/amplitude.

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

  • peaks (ndarray[tuple[Any, ...], dtype[int_]] | None) – Optional R-peak indices to mark.

  • title (str | None) – Figure title.

  • height (int) – Figure height in pixels.

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

Return type:

Figure

ecgdatakit.plotting.iplot_leads(leads, peaks_dict=None, title=None, height=None, *, fs=None, show=True, x_axis='time', rows=None, cols=None)[source]

Interactive leads in a grid layout (vertical stack by default).

Parameters:
  • leads (list[Lead] | ECGRecord | ndarray[tuple[Any, ...], dtype[double]] | list[ndarray[tuple[Any, ...], dtype[double]]]) – Leads to plot. Also accepts a 2-D numpy array (n_leads × n_samples) or a list of 1-D numpy arrays.

  • peaks_dict (dict[str, ndarray[tuple[Any, ...], dtype[int_]]] | None) – {label: peaks_array} for per-lead peak markers.

  • title (str | None) – Overall title.

  • height (int | None) – Figure height (auto-calculated if None).

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • rows (int | None) – Number of rows in the subplot grid. Derived from cols or defaults to one row per lead when neither is given.

  • cols (int | None) – Number of columns in the subplot grid (default 1).

Return type:

Figure

ecgdatakit.plotting.iplot_12lead(leads, record=None, title=None, height=None, *, fs=None, show=True, x_axis='time', rows=None, cols=None)[source]

Interactive 12-lead plot with standard lead names.

Unlike iplot_leads(), this function assigns the standard 12-lead names (I, II, III, aVR, …, V6) when the input contains unnamed leads. The full signal is plotted without cropping.

Parameters:
  • leads (list[Lead] | ECGRecord | ndarray[tuple[Any, ...], dtype[double]] | list[ndarray[tuple[Any, ...], dtype[double]]]) – Leads (or record) to plot. Also accepts a 2-D numpy array (n_leads × n_samples) or a list of 1-D numpy arrays.

  • record (ECGRecord | None) – Optional record for header annotations.

  • title (str | None) – Overall figure title.

  • height (int | None) – Figure height in pixels (auto-calculated if None).

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • rows (int | None) – Number of rows in the subplot grid. Derived from cols or defaults to one row per lead when neither is given.

  • cols (int | None) – Number of columns in the subplot grid (default 1).

Return type:

Figure

ecgdatakit.plotting.iplot_peaks(lead, peaks=None, title=None, height=350, *, fs=None, show=True, x_axis='time')[source]

Interactive lead with R-peak markers.

Hover on peaks shows peak index, RR interval, and instantaneous HR.

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

  • peaks (ndarray[tuple[Any, ...], dtype[int_]] | None) – R-peak indices. Auto-detected if None.

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

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • title (str | None)

  • height (int)

Return type:

Figure

ecgdatakit.plotting.iplot_spectrum(lead, method='welch', height=400, *, fs=None, show=True)[source]

Interactive spectrum with frequency band highlighting.

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

  • method (str) – "welch" for PSD or "fft" for magnitude spectrum.

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

  • show (bool) – Display the plot immediately (default True).

  • height (int)

Return type:

Figure

ecgdatakit.plotting.iplot_rr_tachogram(rr_ms, height=300, *, show=True)[source]

Interactive RR interval tachogram.

Parameters:
Return type:

Figure

ecgdatakit.plotting.iplot_poincare(rr_ms, height=500, *, show=True)[source]

Interactive Poincaré plot with SD1/SD2 ellipse.

Parameters:
Return type:

Figure

ecgdatakit.plotting.iplot_report(record, height=1200, *, show=True, x_axis='time')[source]

Interactive full ECG report.

Parameters:
  • record (ECGRecord) – Full ECG record.

  • show (bool) – Display the plot immediately (default True).

  • x_axis (str) – "time" for seconds (default) or "samples" for sample indices.

  • height (int)

Return type:

Figure