Skip to content

Ecosystem Comparison & Integration

A central goal of the AI ECG SDK (ecg_sdk) is not to reinvent the wheel, but to unify, standardize, and elevate the fragmented Python biomedical ecosystem into a cohesive, production-grade SDK and academic benchmarking platform.


1. The Existing Python ECG Landscape

Historically, researchers and biomedical developers have relied on several specialized open-source tools:

Library Primary Focus Key Strengths Limitations in Modern AI & Clinical Workflows
wfdb-python (PhysioNet / MIT-LCP) Low-level file I/O for WFDB records (.hea, .dat, .atr). Direct access to PhysioNet databases and official C-library format compatibility. Low-level C-style dictionaries/structs; no multi-source dispatch; no dynamic 12-lead simulation; no clinical paper plotting; no ML benchmarking.
NeuroKit2 (Makowski et al.) Comprehensive psychophysiology & neurophysiology (ECG, PPG, EEG, EDA). Rich collection of classical algorithms (Pan-Tompkins, Elgendi, Martinez, HRV metrics). Primarily 1D/single-channel focus; lacks 12-lead anatomical abstraction (\(I, II, \dots V_6\)); no AAMI inter-patient split (DS1/DS2); no edge benchmarking.
BioSPPy (Carreiras et al.) Toolbox for biosignal processing (ECG, EMG, EDA, Resp). Modular filtering and feature extraction routines. Static output tuples; lacks modern multi-lead signal containers; development is largely stagnant.
HeartPy (van Gent et al.) Heart rate extraction for noisy wearable PPG and single-lead ECG. Dynamic thresholding optimized for consumer wearables. Single-channel 1D only; not intended for diagnostic 12-lead ECG analysis or clinical paper generation.
TorchECG (Deep learning) Deep learning architectures (1D-CNN, ResNet, Transformers) for ECG. GPU-accelerated neural networks for ECG classification. Heavy DL focus; steep learning curve; lacks clinical paper plotting and hardware-constrained edge profiling.

2. Feature Comparison Matrix

Capability / Dimension wfdb NeuroKit2 BioSPPy HeartPy ai-ecg-sdk (This Project)
Universal Ingestion Dispatcher (load_ecg) ⚠️ (Local/PN only) ✅ Yes (URIs, PhysioNet, Files, NumPy, DataFrames, Synth)
Multi-Lead Data Container (ECGSignal) ❌ (Raw dicts) ❌ (1D Series) ❌ (Tuples) ❌ (1D) ✅ Yes (Immutable \(N \times L\), lead names, metadata)
Ingestion Standardization & Scaled Annotations ✅ Yes (Standardizes \(f_s\) + scales \(r_i\) annotations)
12-Lead Dynamical Attractor Simulation (McSharry) ⚠️ (Simple 1D) ✅ Yes (3D VCG, Einthoven, \(a\text{VR}\), \(V_1 \to V_6\) progression)
Clinical Millimeter Paper Engine (1:1 & Digital) ❌ (Plain plots) ❌ (Basic plots) ❌ (Basic plots) ✅ Yes (\(25\text{ mm/s}, 10\text{ mm/mV}\), \(3\times4+1\) report, sparse ticks)
Arrhythmia & Artifact Synthesis ⚠️ (Limited) ✅ Yes (PVC, Brady, Tachy, Pause, Respiration, 50/60 Hz)
AAMI EC57 Inter-Patient Benchmarking (DS1/DS2) ✅ Yes (Strict inter-patient split to prevent data leakage)
Edge-Wearable Profiling Index (\(EWSI\)) ✅ Yes (Latency, RAM, FLOPs, ONNX Export)

3. How ai-ecg-sdk Integrates with the Ecosystem

Rather than discarding existing libraries, ai-ecg-sdk acts as an orchestration and enhancement layer:

flowchart TD
    subgraph Ingestion_Layer [1. Ingestion Layer]
        A1[PhysioNet Cloud] -->|wfdb-python| B[Universal Loader: load_ecg]
        A2[Local CSV / Parquet] --> B
        A3[McSharry 12-Lead Dynamical ODE] --> B
    end

    subgraph Core_Container [2. Core Container]
        B --> C[ECGSignal: Multi-Lead N x L]
        C -->|Resample + Scale Annotations| C
    end

    subgraph Processing_Layer [3. Processing & Analysis]
        C --> D1[Classical Delineation: Native + NeuroKit2 Engine]
        C --> D2[Signal Quality Index: SQI Pipeline]
        C --> D3[1:1 Clinical Millimeter Paper Plotter]
    end

    subgraph ML_Benchmarking [4. ML & Edge Benchmarking]
        C --> E1[AAMI EC57 DS1/DS2 Inter-Patient Split]
        E1 --> E2[1D-CNN / ResNet Arrhythmia Models]
        E2 --> E3[ONNX Runtime / Edge EWSI Profiling]
    end

Integration Details:

  1. wfdb-python Under the Hood:
  2. Used for low-level binary parsing of PhysioNet WFDB records and .atr annotations.
  3. ai-ecg-sdk abstracts away low-level format intricacies, adding local caching, cross-database URI routing ("physionet:mitdb/100", "pn:incartdb/I01"), and automatic sampling frequency harmonization with proportional beat annotation rescaling.
  4. NeuroKit2 as a Classical Algorithmic Backend:
  5. For classical delineation and HRV metrics, ecg_sdk provides clean object-oriented methods (sig.delineate(), sig.extract_hrv()) that can dispatch to NeuroKit2 or native vectorized routines interchangeably.
  6. PyTorch & ONNX Runtime for Production AI:
  7. Connects raw clinical recordings to neural network inputs, training pipelines with AAMI EC57 compliance, and edge quantization/export.