ALADIN is a neuro-symbolic AI model that preprocesses, segments, and diagnoses single- and multi-lead ECG signals. It has been validated extensively on three diverse patient cohorts with a combined size of 13,000 patients. ALADIN can handle any ECG recording from clinical MUSE recordings to handheld KardiaMobile measurements ranging from 6 seconds to 24 hours.
pip install aladin-ecg
Changelog:
💡Version 1.1.2 08/08/2026:
- Added PyPi support
💡Version 1.1.1 15/07/2026:
- Added Github Actions to verify cross-platform compatibality
- Added unit tests
- Downloads missing model weights automatically from Hugging Face (access required)
💡Version 1.1.0 16/03/2026:
- Added ability to handle 1, 3, and 12-lead ECG
- Added median beat extraction and corresponding beat median segmentations based on segmentation and QRS clusters
System requirements:
- Linux Ubuntu >= 20.04 or MacOSX 13.6.x or Microsoft Windows >=10
- Python >3.10
- 20Gb free diskspace
- Modern GPU with >12Gb VRAM is recommended for training and inference
Tested on Linux Ubuntu 20.04, MacOSX 13.6.x, and Microsoft Windows 10 and 11 Home. CPU-only support is available, but a modern GPU is required for training and will speed up inference substantially. Tested on NVidia GeForce 3090.
Installation
When on MacOS, a homebrew install of OpenMP is required:
brew install libomp
Next, clone and install ALADIN:
git clone https://github.com/fastlib/ALADIN.git
cd ALADIN
python -m venv VENV #create virtual environment
source VENV/bin/activate #activate environment
pip install scikit-build-core pybind11 ninja cmake #build tooling, must be installed before building aladin
pip install torch #must be installed before building aladin's C++ extension
pip install ./nnUNet
pip install ./aladin --no-build-isolation
mkdir models
Example usage
import numpy as np
from aladin import ALADIN
from aladin.core import Record
#ecg should be a dictionary with the keys being lead names
fs = 250 #hz
ecg = {"II": np.random.rand(fs*10)}
#create record object
record = Record(ecg, fs)
#create ALADIN object
#modelpaths="auto" picks between the pretrained 1-lead and 3-lead models based on which leads
#the record has available (lead II must always be present; the 3-lead model is only used if
#leads II, V1 and V6 are all present, otherwise ALADIN falls back to the 1-lead model)
aladin = ALADIN(modelpaths="auto")
#perform segmentation
aladin.segment(record)
#perform diagnosis
aladin.analyse(record)
#perform median beat extraction
aladin.extract_median_beat(record)
median_beat = record.median_beat.ecg
Example code
python demo.py --case=[recording]
Where [recording] can be one of (STANFORD1, STANFORD2, A01986, A08391).
Reproduce benchmark
See Benchmark.md for details on benchmark reproduction.
macOS build notes
ALADIN's C++ extension (aladin._main) uses OpenMP for native multithreading.
On macOS, Apple Clang doesn't ship OpenMP itself, so the extension is built
using Homebrew's libomp for headers — but it links against PyTorch's own
bundled libomp.dylib at runtime rather than Homebrew's copy. This is
necessary because loading two independent OpenMP runtimes into the same
Python process (one from Homebrew via this extension, one bundled with
PyTorch) causes macOS to crash under concurrent load, with segfaults inside
libomp's __kmp_suspend_64. Sharing a single runtime with PyTorch avoids
that.
This has two consequences for how you install/rebuild ALADIN on macOS:
torchmust already be installed before buildingaladin. The build step needs toimport torchto locate its bundledlibomp.dylib. If torch isn't importable at build time, the build falls back to Homebrew'slibompwith aWARNING, which reintroduces the crash risk above.- Always pass
--no-build-isolationwhen installing/rebuildingaladin. By default,pip installbuilds packages inside a temporary, isolated environment that can't seetorch(or anything else) installed in your venv, even though it reuses the same Python interpreter — which defeats the point above.--no-build-isolationbuilds directly against your venv instead, so make surescikit-build-core,pybind11,ninja,cmake, andtorchare installed in the venv first (as in the install steps above). This applies every time you rebuild the extension, e.g. afterpip install -e ./aladinfor development.
ALADIN will automatically download the model weights from the public Hugging Face repo fastlib/ALADIN
into huggingface_hub's default cache (~/.cache/huggingface/hub, or wherever HF_HOME/HF_HUB_CACHE
point) the first time they're needed. No Hugging Face account or login is required -- the download is
anonymous. Alternatively, set the aladin_models environment variable to a local folder that already
contains the weights, to skip the Hugging Face download entirely.
Metadata
Release files for aladin-ecg 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aladin_ecg-1.0.1.tar.gz | 791.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aladin_ecg-1.0.1-cp314-cp314-macosx_14_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 14.0+ ARM64 | Details |
Total release size: 1.5 MB
Release files / aladin_ecg-1.0.1.tar.gz
| Download URL | aladin_ecg-1.0.1.tar.gz |
|---|---|
| Size | 791.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bbc020fa37a6f19c3e5f2353273b5bec493eef58d38e7f38f51dbfca64aefb8
|
|
BLAKE2b-256 checksum How to use checksums |
d3ea32e86e1008c93d315665578aa389875529b001a4801464b74540f57811c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency logRelease files / aladin_ecg-1.0.1-cp314-cp314-macosx_14_0_arm64.whl
| Download URL | aladin_ecg-1.0.1-cp314-cp314-macosx_14_0_arm64.whl |
|---|---|
| Size | 729.2 kB |
| Tags | CPython 3.14 macOS 14.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3050a7f4b50e387da576b61e3ea1302e95f17071e9aa4bde9b71123a6f4dbb64
|
|
BLAKE2b-256 checksum How to use checksums |
e859b9bd9469746b3f68e1d90566ecd6ee7a3332d0f5a835b7e51c1e976ee1b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 16, 2026.
Transparency log