TransECG-SSL: Hybrid Self-Supervised Representation Learning for ECG Arrhythmia Classification
Organizations: School of Computer Science and Mathematics, Kingston University, London, United Kingdom · Usher Institute, University of Edinburgh, Edinburgh, United Kingdom
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.
Figures & tables
| Component | Setting |
| Input source | WFDB ECG records and reference beat annotations. |
| ECG lead | First available ECG lead was used consistently across datasets. |
| Bandpass filtering | Fourth-order Butterworth bandpass filter from 0.5–40 Hz using zero-phase second-order-section filtering. |
| Resampling | Continuous ECG signals were resampled to 256 Hz before beat extraction. R-peak locations were mapped to the resampled signal index space. |
| Beat alignment | Beats were centred on the annotated R-peak. |
| Window length | 256 samples per beat. |
| Dataset | Split | Pts. | Recs. | N | S | V | F | Q | Total |
| MIT | Train | 31 | 31 | 56,914 | 1,861 | 4,802 | 435 | 6,038 | 70,050 |
| Test | 16 | 17 | 33,668 | 920 | 2,433 | 367 | 2,132 | 39,520 | |
| INC | Train | 21 | 51 | 104,015 | 1,333 | 14,351 | 147 | 4 | 119,850 |
| Test | 11 | 24 | 49,581 | 625 | 5,655 | 72 | 2 | 55,935 | |
| SVDB | Train | 52 | 52 | 108,676 | 8,167 | 6,656 | – | – | 123,499 |
| Test | 26 | 26 | 53,575 | 4,028 | 3,282 | – | – | 60,885 |
| Experiment | SSL pretraining source | Frozen embedding extraction | Evaluated classes | Purpose |
| MIT-BIH MIT-BIH | MIT-BIH training partition | MIT-BIH patient-disjoint training and test partitions | N/S/V/F/Q | Target-matched reference for MIT-BIH. |
| INCART INCART | INCART training partition | INCART patient-disjoint training and test partitions | N/S/V/F/Q | Target-matched reference for INCART. |
| SVDB SVDB | SVDB training partition | SVDB patient-disjoint training and test partitions | N/S/V | Target-matched reference for SVDB. |
| MIT-BIH INCART | MIT-BIH training partition | INCART patient-disjoint training and test partitions | N/S/V/F/Q | Cross-dataset transfer from MIT-BIH to INCART. |
| INCART MIT-BIH | INCART training partition | MIT-BIH patient-disjoint training and test partitions | N/S/V/F/Q | Cross-dataset transfer from INCART to MIT-BIH. |
| MIT-BIH SVDB | MIT-BIH training partition | SVDB patient-disjoint training and test partitions | N/S/V | Cross-dataset transfer from MIT-BIH to SVDB. |
| Experiment | Acc. | BA | A–BA gap | F1 | AUROC | AUPRC | MCC | |
| MIT MIT | ||||||||
| INC INC | ||||||||
| SVDB SVDB | ||||||||
| MIT INC | ||||||||
| INC MIT | ||||||||
| MIT SVDB |
| Train Test | Hyb. | Rec. | Con. | Src. | Rand. |
| Balanced accuracy | |||||
| MIT MIT | |||||
| INC INC | |||||
| SVDB SVDB | |||||
| MIT INC | |||||
| INC MIT | |||||
| Metric | MIT-BIH | INCART | SVDB |
| Accuracy | |||
| Balanced Accuracy | |||
| Macro-F1 | |||
| Macro-AUROC | |||
| Macro-AUPRC | |||
| MCC |
| Condition | Trainable parameters |
| Hybrid SSL | 3,482,176 |
| Reconstruction-only SSL | 3,457,408 |
| Contrastive-only SSL | 3,383,360 |
| Source-supervised (5-class) | 3,359,237 |
| Source-supervised (3-class) | 3,358,979 |
| Target-supervised (5-class) | 3,359,237 |
| Transfer | Hyb. BA ( BA) | Rec. BA ( BA) | Src. BA ( BA) |
| MIT INC | |||
| INC MIT | |||
| MIT SVDB | |||
| INC SVDB |
| Experiment | Classes | BA | Macro-F1 |
| INCART INCART | 5-class | ||
| Excl. Q | |||
| MIT-BIH INCART | 5-class | ||
| Excl. Q |
| Exp. | C | Sup. | Rec. | PPV | F1 | AUROC | AUPRC |
| INC INC | N | 49,581 | |||||
| S | 625 | ||||||
| V | 5,655 | ||||||
| F | 72 | ||||||
| Q | 2 | ||||||
| MIT INC | N | 49,581 |
| Comparison | Outcome | Evidence |
| Hybrid SSL vs. Random Transformer | Hybrid SSL | Higher balanced accuracy and macro-F1 in all seven source–target evaluation routes. |
| Hybrid SSL vs. Source-supervised Transformer | Hybrid SSL for BA | Higher balanced accuracy in all seven routes. Macro-F1 was higher for Hybrid SSL in 4/7 routes and for the source-supervised Transformer in 3/7 routes. |
| Hybrid SSL vs. Reconstruction-only SSL | Mixed | Hybrid SSL achieved higher balanced accuracy in 4/7 routes and higher macro-F1 in 5/7 routes, confirming that the incremental effect of the contrastive objective was route- and metric-dependent. |
| Hybrid SSL vs. Contrastive-only SSL | Hybrid SSL | Contrastive-only SSL produced substantially lower balanced accuracy and macro-F1 across all seven evaluation routes. |
| Cross-dataset generalisation | Hybrid SSL in 3/4 routes | Hybrid SSL achieved the highest cross-dataset balanced accuracy and macro-F1 in three of four transfer routes; reconstruction-only SSL was highest for MIT-BIH INCART. Target-normalised degradation remained method and route-dependent. |
| Minority-class recognition | Unresolved | Near-zero fusion-beat (F) recall and consistently low supraventricular ectopic-beat (S) recall in several five-class evaluations. |