Learning Sex-specific Latent Factors from Single-Lead ECG Signals Using a Variational Autoencoder

Angela Hernandez Mendoza1, Josseline Nicole Madrid1, Carlos Sánchez2, Patricia Munroe3, Alejandro Sanz4, Julia Ramírez1, Ana Mincholé1
1University of Zaragoza, 2Centro Universitario de la Defensa de Zaragoza, 3QMUL, 4Endocrinology service, Miguel Servet University Hospital


Abstract

Background: Sex-related differences in electrocardiographic signals reflect underlying variation in cardiac electrophysiology and ECG morphology. Accounting for this variability is important for accurate interpretation and risk stratification. Variational autoencoders (VAEs) offer a powerful framework for ECG representation learning, yet entanglement limits the isolation of sex-related variability, which we address in this work through disentangled representation learning.

Methods: We developed a 1D convolutional FactorVAE using aligned median single-lead ECG beats (lead I, N = 54,773) from the UK-Biobank cohort as an input. Continuous variables (age, body mass index, systolic and diastolic blood pressure) were provided to the decoder as conditioning inputs, while sex was excluded from training. The encoder mapped ECG signals to a 32 latent dimensions (LD) space. The model was trained with a variational objective using a Gaussian prior p(z) = N (0, I), combining reconstruction loss and KL divergence (β = 1), while a discriminator enforced independence across latent dimensions via a total correlation penalty (γ = 3). Interpretability was explored using per-dimension KL to identify active latent dimensions (KLi > 0.1), latent traversals, and correlation analyses to assess associations.

Results: The model accurately reconstructed ECG signals (MAE = 0.037 mV) while maintaining partial disentanglement (KL loss = 25 nats), with 11 active LD. Specifically, LD number 14 exhibited the strongest correlation coefficient with sex (|r| = 0.29). Latent traversal along this LD induced changes in ST segment and T-wave amplitudes (|r| = 0.60 and 0.78, respectively), consistent with the literature, suggesting that the model captured sex-specific electrophysiological characteristics. These findings indicate that sex-related variability is a dominant and learnable factor in ECG signals, which can be isolated without explicit supervision.

Conclusions: FactorVAE can uncover sex-specific latent structure in ECG data, highlighting its potential to capture relevant female-specific factors, such as menopausal status.