BixECG — Bi-mLSTM (2,522 parameters)

Model weights for the paper "A Compact, Uncertainty-Aware mLSTM Model for Real-Time ECG Delineation on Edge Devices" (Lung et al., 2026; manuscript under review).

BixECG performs per-sample ECG waveform delineation: it classifies every sample of a single-lead ECG as No-Wave (NW), P-wave, QRS-complex, or T-wave with a bidirectional matrix-memory LSTM (Bi-mLSTM), the mLSTM block of the xLSTM family. The model has 2,522 parameters (≈10 kB of float32 weights) and runs in real time on microcontroller-class hardware (Arduino Portenta H7, Cortex-M7).

Weight files

Both files contain a state_dict for the same architecture (bixecg.models.bixecg_net.BixECGNet).

File Status Training recipe Role
bixecg_mlstm_2522_detaug.pt Default (since v1.1.0) QTDB, detector-anchored windows (segmented Pan–Tompkins R peaks) + augmentation (anchor jitter σ 40 ms, ±10 % time-stretch, baseline wander, Gaussian noise) Final model reported in the paper
bixecg_mlstm_2522.pt Kept, not default QTDB, annotation-anchored windows, no augmentation (earlier training recipe; unchanged from v1.0.0) Weights deployed in the on-device pilot reported in the paper

Results of the final model (bixecg_mlstm_2522_detaug.pt)

Tolerance-aware evaluation with detector-anchored windows (each window is anchored on the R peak found by the same detector that runs on the device). Boundary tolerances: P ±52 ms, QRS ±48 ms, T ±124 ms.

External test set Macro-F1 Cohen's κ ECE
LUDB 0.921 0.894 0.054
LVAD-DB (pooled across two raters) 0.878 0.837 0.038

Protocol change in v1.1.0. The primary evaluation now uses detector-anchored windows, which match the deployment signal chain. The v1.0.0 card reported scores with annotation-anchored windows, which place each beat ideally and are therefore optimistic; those scores are not comparable to the table above.

Model details

Architecture Bidirectional mLSTM: 3 blocks, embedding dim 8, 1 head, causal conv kernel 11; one stack shared by the forward and time-reversed passes
Parameters 2,522
Input Single-lead ECG, 250 Hz, band-pass 0.5–40 Hz, 300-sample window (one beat, starting at the detector-derived QRS onset), per-window z-score
Output Per-sample logits over {NW, P, QRS, T}
Training data QTDB (PhysioNet)
License GPL-2.0-only (© Medical University of Vienna)

Usage

# pip install git+https://github.com/CellularSyntax/BixECG@v1.1.0   (Python >= 3.11)
import torch
from bixecg.pretrained import load_pretrained

model = load_pretrained()           # final weights (bixecg_mlstm_2522_detaug.pt), bundled with the package
pilot = load_pretrained("pilot")    # pilot-firmware weights (bixecg_mlstm_2522.pt)

x = torch.randn(1, 300, 1)          # (batch, 300, 1), preprocessed as described above
with torch.no_grad():
    probs = model(x).softmax(-1)    # (batch, 300, 4)
labels = probs.argmax(-1)

Loading a file downloaded from this repository directly:

import torch
from huggingface_hub import hf_hub_download
from bixecg.models.bixecg_net import BixECGNet, BIXECG_2522_KWARGS

path = hf_hub_download("maxhaberbusch/BixECG", "bixecg_mlstm_2522_detaug.pt")
model = BixECGNet(**BIXECG_2522_KWARGS)
model.load_state_dict(torch.load(path, map_location="cpu", weights_only=True), strict=True)
model.eval()

Firmware-format weights (C header, flat float32 binary and manifest) for the final model are in deployment/firmware/ of the code repository, together with the detector-anchored training/evaluation script (scripts/retrain_anchor_experiment.py).

Data availability

QTDB and LUDB are public (PhysioNet). The LVAD-DB and D-Heart pilot recordings are not distributed with this model; they are patient data protected under data-protection regulations and are available from the corresponding author on reasonable request.

Citation

Lung D, Heute P, Marx M, Schlöglhofer T, Abart T, Moscato F, Riebandt J, Zimpfer D, Haberbusch M. A Compact, Uncertainty-Aware mLSTM Model for Real-Time ECG Delineation on Edge Devices. 2026. Manuscript under review.

Software and weights archive: 10.5281/zenodo.23196330 (concept DOI, resolves to the latest version).

Downloads last month
22
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support