ECGFounder ONNX Models

ONNX-converted ECGFounder foundation models for real-time 12-lead ECG interpretation on edge hardware. Optimized for deployment on ARM processors (Raspberry Pi 4) and x86-64 systems.

Performance: Macro AUROC 0.909 (PTB-XL test set, n=2,163) | Latency 115 ms (Raspberry Pi 4)

πŸš€ Quick Start

import onnxruntime as ort
import numpy as np

# Load model
session = ort.InferenceSession("ecg_founder_all71.onnx")

# Prepare input: 12 leads Γ— 5000 samples (10 seconds @ 500 Hz)
ecg_signal = np.random.randn(1, 12, 5000).astype(np.float32)

# Inference
logits = session.run(None, {"input": ecg_signal})[0]

# Convert to probabilities
probabilities = 1 / (1 + np.exp(-logits))  # Sigmoid

# Get top 5 predictions
top5_indices = np.argsort(probabilities[0])[-5:][::-1]
print("Top 5 diagnoses:", top5_indices)

πŸ“¦ Available Models

1. ecg_founder_all71.onnx

  • Classes: 71 cardiac diagnoses (PTB-XL-aligned)
  • Validation: Fully validated on PTB-XL fold 10 (AUROC 0.909, n=2,163)
  • Use case: Research benchmarking, algorithm validation
  • Size: ~112 MB
  • Labels: labels_all71.json

2. ecg_founder_12lead.onnx

  • Classes: 150 cardiac diagnoses (SNOMED-CT)
  • Validation: Partial (71 of 150 classes validated on PTB-XL)
  • Use case: Clinical deployment (broader diagnostic coverage)
  • Size: ~112 MB
  • Note: Requires custom label mapping for 150 classes from ECG FOUNDER: https://github.com/NickLJLee/ECGFounder?tab=readme-ov-file

πŸ“‹ Input Specifications

Parameter Value
Format Float32 numpy array
Shape (batch_size, 12, 5000)
Leads I, II, III, aVR, aVL, aVF, V1, V2, V3, V4, V5, V6
Sampling rate 500 Hz (required)
Duration 10 seconds (5,000 samples)
Preprocessing Bandpass filter (0.5-50 Hz) + Z-score normalization
Important Raw digital ECG signals only (not scanned paper ECG images)

⚑ Performance Metrics

Platform CPU Latency Validated AUROC
Raspberry Pi 4 ARM Cortex-A72 @ 1.5 GHz 115 ms 0.909 (95% CI: 0.906-0.912)
x86-64 Desktop Intel Core i7-10700K @ 3.8 GHz 57 ms 0.909 (95% CI: 0.906-0.912)

πŸ› οΈ Complete Documentation

GitHub Repository: https://github.com/GhIrani33/ecgfounder-edge-cds

The repository includes:

  • Preprocessing pipeline (bandpass filter, adaptive notch, quality control)
  • ONNX conversion scripts (PyTorch β†’ ONNX with numerical validation)
  • Validation scripts (PTB-XL benchmark evaluation)
  • Explainability analysis (Integrated Gradients attribution)
  • Hardware deployment guide (Raspberry Pi 4, ARM optimization)
  • Performance benchmarking tools

πŸ“₯ Download Models

Using Hugging Face Hub (Python)

from huggingface_hub import hf_hub_download

# Download 71-class model
model_path = hf_hub_download(
    repo_id="ghirani33/ecgfounder-onnx",
    filename="ecg_founder_all71.onnx"
)

# Download labels
labels_path = hf_hub_download(
    repo_id="ghirani33/ecgfounder-onnx",
    filename="labels_all71.json"
)

Manual Download

Download files directly from the "Files and versions" tab above.

πŸ”¬ Validation Results

Dataset: PTB-XL fold 10 (n=2,163 independent test samples)
Metric: Macro-averaged AUROC across 71 diagnostic classes
Result: 0.909 (95% CI: [0.906, 0.912])

Per-class performance (selected examples):

  • NORM (Normal): AUROC 0.956
  • AFIB (Atrial Fibrillation): AUROC 0.931
  • LBBB (Left Bundle Branch Block): AUROC 0.889
  • AMI (Anterior MI): AUROC 0.876

Noise robustness:

  • Clean: AUROC 0.909
  • Noisy (50 Hz powerline + baseline wander): AUROC 0.545
  • After preprocessing: AUROC 0.891 (95% recovery)

See GitHub repository for complete validation metrics and methodology.

πŸ“š Citation

If you use these models in your research, please cite:

@software{ecgfounder_onnx_2025,
  title={ECGFounder ONNX Models for Edge-Based Clinical Decision Support},
  author={Dolatkhah Laein, Ghasem},
  year={2025},
  url={https://huggingface.co/ghirani33/ecgfounder-onnx},
  note={ONNX deployment of ECGFounder foundation model}
}

Original ECGFounder paper:

@article{li2024ecgfounder,
  title={An Electrocardiogram Foundation Model Built on over 10 Million Recordings with External Evaluation across Multiple Domains},
  author={Li, Qihan and others},
  journal={NEJM AI},
  volume={1},
  number={7},
  year={2024}
}

PTB-XL dataset:

@article{wagner2020ptbxl,
  title={PTB-XL, a large publicly available electrocardiography dataset},
  author={Wagner, Patrick and others},
  journal={Scientific Data},
  volume={7},
  number={1},
  pages={154},
  year={2020}
}

⚠️ Disclaimer

Research prototype. These models have been validated on benchmark datasets (PTB-XL) but are NOT FDA/CE approved and must NOT be used for primary clinical diagnosis without:

  • Institutional Review Board (IRB) approval
  • Physician supervision and oversight
  • Prospective clinical validation

Intended use: Research, algorithm development, and proof-of-concept demonstrations for clinical decision support systems.

πŸ“„ License

MIT License. See LICENSE file for details.

Note: ECGFounder original model weights are subject to their original license terms. This repository provides ONNX-converted models for deployment research.

πŸ™ Acknowledgments

  • ECGFounder Team: For developing and sharing the foundation model
  • PTB-XL Contributors: For providing the benchmark dataset
  • ONNX Runtime: For enabling cross-platform inference

πŸ“§ Contact

Maintainer: Ghasem Dolatkhah Laein
Email: [email protected]
GitHub: GhIrani33/ecgfounder-edge-cds

For questions about the original ECGFounder model, please contact the original authors.

Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support