ecg-reconstruction-risk
A self-supervised masked autoencoder (ViT-Tiny) for 12-lead ECGs, pretrained on CODE-85% (~7.2 million ECGs). The model was trained only to reconstruct masked portions of the signal.
Reconstruction error (mean absolute error between input and reconstruction) is associated with all-cause mortality, and can be used as a continuous, label-free risk score. See the paper for validation across six cohorts.
Research use only. This is not a medical device and must not be used to guide clinical decisions.
Usage
git clone git@github.com:dlaskalab/ecg-reconstruction-risk.git
cd ecg-reconstruction-risk
uv run run_pretrained_model.py $DATA_DIR $OUTPUT_DIR
$DATA_DIR is a directory of ECGs in WFDB format (.hea and .dat files). Weights are downloaded from this repository automatically on first run. Full instructions, including survival analysis, are in the GitHub repository.
Files
| File | Description |
|---|---|
model.safetensors |
Model weights |
config.yaml |
Training configuration |
CODE15_mae_values.json |
Reference reconstruction-error statistics from CODE-15%, used for normalisation and thresholding |
Notes
- The published weights come from less than one epoch of training. This is deliberate. Further training weakens the mortality association rather than improving it.
- Scores depend on the preprocessing in
config.yaml(100 Hz resampling, lead-wise normalisation). Deviate from it and the CODE-15% reference statistics will not transfer. - Masking is random, so scores vary between runs.
run_pretrained_model.pyaverages over five repeats by default.
Limitations
Retrospective and observational, so all findings are associational. Only all-cause mortality has been assessed. See the paper for full details.
Citation
@article{nicolson2026ecg,
title = {Artificial intelligence-based ECG reconstruction error as a continuous predictor of all-cause mortality: a multi-cohort retrospective validation study},
author = {Nicolson, Angus and Pr{\"o}ll, Samuel and Lunelli, Riccardo and Blankenburg, Hagen and Pramstaller, Peter and Fuchsberger, Christian and Bauer, Axel and Dlaska, Clemens},
journal = {medRxiv},
year = {2026},
doi = {10.64898/2026.07.10.26357749}
}
- Downloads last month
- 8