Manuscript Offprint

arXiv:2610.35378

TransECG-SSL: Hybrid Self-Supervised Representation Learning for ECG Arrhythmia Classification

Ahtisham Ayyub, Fasih Haider, Muhammad Rehan Usman, Saturnino Luz, Christos Politis, Muhammad Arslan Usman

Ahtisham Ayyub, Student Member, IEEE, Fasih Haider, Senior Member, IEEE, Muhammad Rehan Usman, Member, IEEE, Saturnino Luz, Member, IEEE, Christos Politis, Senior Member, IEEE, and Muhammad Arslan Usman, Member, IEEE

Abstract—Cross-dataset generalisation remains a major challenge for automated electrocardiogram (ECG) arrhythmia classification because of differences in patient populations, acquisition protocols, annotation practices, and class distributions. Learning representations that remain informative across independent datasets could reduce reliance on dataset-specific labelled data. We propose TransECG-SSL, a self-supervised framework for transferable heartbeat representation learning from unlabelled ECG data. A Transformer encoder is pretrained using a hybrid objective combining masked signal reconstruction and contrastive learning, then frozen and evaluated by linear probing under patient-disjoint evaluation. Experiments across three public ECG databases and seven source-target settings show that Hybrid SSL consistently outperforms randomly initialised Transformers and achieves higher balanced accuracy than architecture-matched source-supervised pretraining. Reconstruction-only SSL remains competitive with Hybrid SSL, whereas contrastive-only pretraining performs substantially worse, highlighting the importance of masked reconstruction for transferability. Cross-dataset transfer nevertheless reduces balanced accuracy relative to target-specific self-supervised pretraining, while minority arrhythmia classes remain challenging under severe class imbalance. These findings demonstrate the potential of label-efficient self-supervised learning for cross-dataset ECG representation transfer while highlighting persistent limitations from domain shift and class imbalance.

Index Terms—Arrhythmia classification, Cross-dataset generalisation, Electrocardiogram (ECG), Self-supervised learning, Transfer learning, Transformer, Representation learning, Domain shift

I. INTRODUCTION

ELECTROCARDIOGRAPHY (ECG) is widely used to assess cardiac rhythm, and the increasing volume of ECG data generated in clinical, ambulatory and wearable-monitoring settings has motivated substantial research on automated arrhythmia classification. Although Deep-learning (DL) methods can learn discriminative representations directly from ECG signals; reported performance remains difficult to compare because studies vary substantially in datasets, preprocessing, architectures, evaluation protocols, and metrics [1], [2]. Reviews also report a high dependency on MIT-BIH, a greater use of intra-patient rather than inter-patient evaluation, and less favourable class-sensitive metrics than headline accuracy [3]. These concerns reinforce the need for patient-independent evaluation and careful interpretation of high reported performance [4].

Heartbeat-level evaluation is significantly affected by patient overlap because individual patients contribute many correlated beats; patient-disjoint partitioning therefore provides a stricter test of generalisation. Severe class imbalance adds a second difficulty, since normal beats dominate many arrhythmia datasets and minority classes may be poorly recognised even when overall accuracy is high [5].

Another challenge is the dependence of supervised ECG models on time-consuming and expensive expert-labelled data. Self-supervised learning (SSL) offers a way to exploit unlabelled ECG signals for representation learning. ECG SSL has been investigated through contrastive approaches [6], broader self-supervised representation learning [7], masked reconstruction [8], out-of-distribution evaluation [9], and larger hybrid or foundation-model frameworks [10]. These strands motivate a controlled comparison of reconstructive and contrastive objectives for transferable heartbeat representations.

Transfer learning can reduce dependence on target-domain labels [11], [12], but transfer across independent ECG databases is complicated by differences in patient populations, acquisition conditions, annotation practices, and class distributions; reported performance can also depend materially on partitioning choices [13]. Recent approaches address such shifts through domain adaptation [14], domain generalisation [15], and domain-invariant or multi-dataset learning [16], [17]. However, these approaches differ in the information available during

Manuscript submitted for review on August 28, 2026. This work has been submitted to the IEEE for possible publication. Copyright may be transferred without notice, after which this version may no longer be accessible.

Ahtisham Ayyub, Muhammad Rehan Usman, Christos Politis, and Muhammad Arslan Usman are with the School of Computer Science and Mathematics, Kingston University, London, United Kingdom (e-mail: {a.ayyub, r.usman, c.politis, m.usman}@kingston.ac.uk).

Fasih Haider and Saturnino Luz are with the Usher Institute, University of Edinburgh, Edinburgh, United Kingdom (e-mail: {fasih.haider, s.luz}@ed.ac.uk). FH and SL would like to acknowledge UKRI under grant number 10102226.

IEEE TRANSACTIONS AND JOURNALS

training, for instance transfer learning typically uses labelled target samples for fine-tuning, domain adaptation exploits unlabelled target data to align source and target representations, whereas domain generalisation and domain-invariant learning aim to learn representations that remain robust to unseen target distributions without target-specific adaptation. These observations motivate a narrower representation-transfer question: whether an ECG encoder pretrained on one arrhythmia database can remain fixed and provide useful heartbeat representations on an independent target database when only a lightweight target classifier is fitted. Such an evaluation differs from target-domain adaptation because the source-pretrained encoder is not updated using target data, and it differs from conventional transfer learning in which the pretrained encoder is fine-tuned on the target task. It also requires architecture-matched comparisons between self-supervised objectives so that any apparent advantage is not attributable simply to differences in encoder capacity or downstream evaluation. To investigate this question, this study proposes TransECG-SSL, a hybrid self-supervised framework for ECG heartbeat representation learning.

The main contributions of this study are: (i) TransECG-SSL, a Transformer-based framework combining masked reconstruction and contrastive learning to learn transferable heartbeat representations from unlabelled ECG data; (ii) systematic evaluation of frozen representation transfer across seven within- and cross-dataset settings spanning MIT-BIH, INCART, and SVDB under patient-disjoint evaluation; (iii) architecture-matched comparison with reconstruction-only, contrastive-only, source-supervised, and random-encoder baselines under a common linear-probing protocol; and (iv) analysis of cross-dataset generalisation and class-specific performance, demonstrating transferable self-supervised representations while identifying domain shift and minority-class recognition as persistent limitations.

References (46)