Cross-dataset ECG classification using deep metric learning with an extended ECG context window

European Heart Journal - Digital Health

12 January 2026
Organised by: Logo
ESC Journals

Abstract

AbstractIntroduction

The emergence of wearable Electrocardiogram (ECG) recorders enables real-time analysis and detection of arrhythmias. Deep Learning (DL) techniques can be used to analyze the large volumes of ECG data produced by wearable devices. However, the application of DL techniques in real-world clinical environments is challenging due to limited access to raw ECG data and the rapid change in wearable hardware. DL techniques require annotated training data on the new hardware to maintain performance, which is costly to obtain. To address these challenges, we propose a visual algorithm for cross-dataset ECG classification using metric learning techniques and an extended ECG context window to improve performance without the need for signal filtering.

Methods

A combination of three public datasets is utilized for training, which are MIT-BIH Arrhythmia, MIT-BIH Atrial Fibrillation, and A Large-scale 12-lead arrhythmia database, producing a training dataset containing 124,080 ECG segments. The segments are 10-seconds in duration and comprise four arrhythmia categories: Normal, Supraventricular, Ventricular and Atrial Fibrillation. The training data is denoised using signal filtering and horizontal flipping is introduced to improve the model's generalizability. The model is tested using the Long-term Atrial Fibrillation Database, without signal filtering to reflect real-world conditions. A two-stage metric learning algorithm is proposed whereby ECG features are extracted using a residual Siamese network and the extended context window classification algorithm with a 30-second ECG data window is used to classify the ECG segments.

Results

The proposed extended context window algorithm with horizontal flipping augmentation achieved an accuracy of 88.28% and a Macro-F1 score of 78.30%. Compared to the baseline model that achieved an accuracy of 85.70% and a Macro-F1 score of 71.97%, the proposed extended context algorithm yields superior performance and serves as a replacement for signal denoising.

Conclusion

The proposed algorithm for extending the ECG context window proves to be an effective solution for improving DL algorithm performance in the absence of signal filtering, a common occurrence in real-world clinical environments such as the analysis of document-based ECG reports.

Overview of the training approach

Architecture of the proposed algorithm

Contributors

J T Chew
J T Chew

Author

Swinburne University of Technology Sarawak Campus Kuching , Malaysia

V Raman
V Raman

Author

P H H Then
P H H Then

Author

Sarawak Artificial Intelligence Centre Kuching , Malaysia

ESC 365 is supported by