arXiv:2609.05294cs.LGSep 2026

Manuscript Offprint

arXiv:2609.05294

Learning from VAE Errors to support ECG-based Differential Diagnosis of Myocardial Scar

Shayan Sharifi, Riccardo Treu, Ilaria Gandin, Federico Garoia, Marco Merlo, Giulia Cisotto

Shayan Sharifi¹, Riccardo Treu², Ilaria Gandin³, Federico Garoa², Marco Merlo², Giulia Cisotto¹

¹ Department of Mathematics, Informatics, and Geosciences, University of Trieste, Italy shayan.sharifi@phd.units.it, giulia.cisotto@units.it ² Centre of Diagnosis and Management of Cardiomyopathies; Azienda Sanitaria Universitaria Giuliano Isontina; University of Trieste, Italy; Member of Ern Guard-Heart riccardo.treu@studenti.units.it, federico.garoia@studenti.units.it marco.merlo@units.it ³ Department of Medical, Surgical and Health Sciences, University of Trieste, Italy ilaria.gandin@units.it

Abstract. Late Gadolinium Enhancement (LGE) on cardiac magnetic resonance is a key marker of myocardial scar, but its limited accessibility motivates routine ECG-based screening. We evaluated whether β\beta-variational autoencoder (VAE)-derived ECG representations can discriminate LGE+ from LGE- cardiomyopathic patients in a local cohort of 300 subjects. We compared 32-dimensional features from the foundation ECGx.AI model with those from a shallower β\beta-VAE trained on normal PTB-XL ECGs, evaluating downstream classification and Dynamic Time Warping (DTW)-based reconstruction errors. ECGx.AI reached an area under ROC of 0.686 with Random Forest, while the proposed β\beta-VAE reached 0.577 with sensitivity of 0.775 with Gradient Boosting. Notably, DTW-reconstruction errors significantly differed between classes in 10 out of 12 leads according to Mann-Whitney U test and help in classification, leading to an area under ROC of 0.643 with Logistic Regression, supporting their potential as markers of scar-related ECG alterations.

Keywords: ECG · cardiomyopathy · β\beta-VAE · DTW · machine learning.

1 Introduction and state of the art

Myocardial fibrosis and scar tissue, detectable as Late Gadolinium Enhancement (LGE) on cardiac magnetic resonance imaging (CMR), are key biomarkers for diagnosis and risk stratification in cardiomyopathies [1,3]. In dilated cardiomyopathy (DCM) and non-dilated left ventricular cardiomyopathy (NDLVC), LGE supports disease characterization and clinical decision-making, but CMR is costly, time-consuming, and not uniformly available [4]. This motivates electrocardiography (ECG)-based screening strategies to identify patients most likely to benefit from CMR evaluation [11]. Standard 12-lead ECG is inexpensive, routinely acquired, and reflects cardiac electrical activity. Structural alterations, including fibrosis and focal scar tissue, may perturb ventricular depolarization and repolarization, inducing subtle changes in QRS complexes, ST segments, and T waves [10]. Since these changes are weak and spatially distributed, LGE prediction from ECG is well suited to machine learning and representation-learning methods. Recent ECG-AI studies have shown that deep learning can infer imaging-defined cardiac phenotypes from ECG. A supervised model detected left ventricular systolic dysfunction with an Area Under the ROC Curve (AUROC) of 0.93 [2], but such methods require large disease-specific labelled datasets. To mitigate label scarcity, unsupervised and self-supervised approaches have been explored, including convolutional VAEs for ECG compression and clustering [6], deep feature extraction for genetic discovery [14], compact latent representations preserving ECG morphology [7], and ECGx.AI, a β\beta-VAE trained on approximately 1.1 million ECGs that detected reduced left ventricular ejection fraction (LVEF) with an AUROC of 0.89 [8]. Other recent works support ECG-based scar detection: In [5], the authors achieved an AUROC of 0.80 using fully supervised convolutional neural networks trained solely on raw ECGs to detect ischaemic myocardial scars (improving to 0.89 when clinical parameters were added), the XplainScar model [9] achieved an F1-score of 0.89 and sensitivity of 0.90 for left ventricular scar localization, ECGWiz [15] reached 0.74 accuracy using only 5 training ECGs, and in [19], the authors proposed a 34-layer neural network that achieved an AUROC of 0.80 for myocardial scar prediction from paired ECG/MRI data. Despite these advances, the use of unsupervised ECG representations for LGE prediction in DCM and NDLVC remains underexplored, especially in small local cohorts with limited CMR annotations. In this work, we assess whether the pretrained ECGx.AI encoder provides informative latent features for LGE+/LGE- classification, and compare it with those extracted by an alternative, shallower, β\beta-VAE trained on a reduced set of normal public ECGs. Furthermore, we quantify its reconstruction errors via DTW and propose a way to classify LGE+/LGE- based on their different statistical distributions, following prior works on EEG signals [18].

References (19)