Intelligent ECG Classification Based on Improved Swin Transformer Model

Authors

DOI:

https://doi.org/10.4108/eetpht.11.11675

Keywords:

ECG, Swim Transformer, FPN, Multi-scale Feature Fusion

Abstract

INTRODUCTION: Clinical 12-lead Electrocardiogram (ECG) image classification faces key limitations, including insufficient capture of fine-grained waveform details, compromised integration of local-global rhythmic contexts, and suboptimal modeling of multi-lead spatial relationships.

OBJECTIVES: This study aimed to propose Swin-LGF-FPN, an intelligent image classification model based on Swin Transformer architecture, to address these challenges and improve the accuracy of ECG image classification for early cardiovascular disease screening.

METHODS: The enhanced framework integrated multi-scale Feature Pyramid Network (FPN) modules with an improved Swin Transformer backbone to effectively fuse local and global features. Axial Temporal Attention was incorporated to strengthen temporal feature extraction across ECG waveforms. Gradient-weighted Class Activation Mapping (Grad-CAM) visualizations were used to demonstrate feature saliency. The model was validated on two publicly available datasets: the ECG Images dataset of Cardiac Patients and PTB-XL, with performance compared against baseline models including ResNet-34 and Vision Transformer (ViT).

RESULTS: The results indicated that Swin-LGF-FPN significantly outperformed baseline models in key metrics, including overall accuracy and F1-score. Grad-CAM visualizations showed significantly enhanced feature saliency in critical regions, as evidenced by heatmaps superimposed on original images.

CONCLUSION: The Swin-LGF-FPN model effectively classifies ECG images, showing robust performance and promising translational potential for early cardiovascular disease screening.

Downloads

Download data is not yet available.

References

[1] Viliani D, Cecconi A, López-Melgar B, Muñiz ÁM, Martínez-Vives P, Cuenca S, et al. Machine-learning computer-assisted ECG analysis to predict myocardial fibrosis in patients with hypertrophic cardiomyopathy. Journal of Electrocardiology 2025; Volume 90, 153892. https://doi.org/10.1016/j.jelectrocard.2025.153892.

[2] Swathy M, Saruladha K. A comparative study of classification and prediction of Cardio-Vascular Diseases (CVD) using Machine Learning and Deep Learning techniques. ICT Express 2022; Volume 8, Issue 1, Pages 109-116. https://doi.org/10.1016/j.icte.2021.08.021.

[3] Li X, Zhang D, Li X, Gao X, Liang Y, Tse G, et al. Exploring artificial intelligence methods for cardiac syncope diagnosis combined with electrocardiogram parameters and clinical characteristics. Journal of Electrocardiology 2025; Volume 91, 154018. https://doi.org/10.1016/j.jelectrocard.2025.154018.

[4] Palermi S, Vecchiato M, Ng F, Attia Z, Cho Y, Anselmino M, et al. Artificial intelligence and the electrocardiogram: A modern renaissance. European Journal of Internal Medicine 2025; https://doi.org/10.1016/j.ejim.2025. 04.036.

[5] Seoni S, Molinari F, Acharya U.R, Lih OS, Barua PD, García S, et al. Application of spatial uncertainty predictor in CNN-BiLSTM model using coronary artery disease ECG signals. Information Sciences 2024; Volume 665, 120383. https://doi.org/10.1016/ j.ins.2024.120383.

[6] Al-Zaiti S, Martin-Gill C, Zègre-Hemsey JK., Bouzid Z, Faramand Z, Alrawashdeh MO., et al. Machine learning for ECG diagnosis and risk stratification of occlusive myocardial infarction. Nature Medicine 2023; 29, 1804–1813. https://doi.org/10.1038/ s41591-023-02396-3.

[7] Xiao Q, Lee K, Mokhtar SA, Ismail I, Pauzi ALM, Zhang Q, et al. Deep Learning-Based ECG Arrhythmia Classification: A Systematic Review. Applied Sciences 2023; 13, no.8:4964. https://doi.org/10.3390/ app13084964.

[8] Hannun AY., Rajpurkar P, Haghpanahi M, Tison GH., Bourn C, Turakhia MP., et al. Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network. Nature Medicine 2019; 25 (1) 65-69. https://doi.org/10.1038/s41591-018-0268-3.

[9] Islam MS, Kalmady SV, Hindle A, Sandhu R, Sun W, Sepehrvand N, et al. Diagnostic and Prognostic Electrocardiogram-Based Models for Rapid Clinical Applications. Canadian Journal of Cardiology 2024; Volume 40, Issue 10, Pages 1788-1803. https://doi.org/ 10.1016/j.cjca.2024.07.003.

[10] Al-Zaiti S, Besomi L, Bouzid Z, Faramand Z, Frisch S, Martin-Gill C, et al. Machine learning-based prediction of acute coronary syndrome using only the pre-hospital 12-lead electrocardiogram. Nature Communications 2020; 11, 3966. https://doi.org/10.1038/s41467-020-17804-2.

[11] Kolliyil JJ, Brindise MC. Automated detection of arrhythmias using a novel interpretable feature set extracted from 12-lead electrocardiogram. Computers in Biology and Medicine 2025; Volume 189, 109957. https://doi.org/10.1016/j.compbiomed.2025.109957.

[12] Liu J, Liu Y, Jin Y, Li Z, Qin C, Chen X, et al. A novel diagnosis method combined dual-channel SE-ResNet with expert features for inter-patient heartbeat classification. Medical Engineering & Physics 2024; Volume 130, 104209. https://doi.org/10.1016/j.medengphy.2024. 104209.

[13] Kraft D, Bieber G, Jokisch P, Rumm P. End-to-End Premature Ventricular Contraction Detection Using Deep Neural Networks. Sensors 2023; 23, 8573. https://doi.org/ 10.3390/s23208573.

[14] Wu L, Xie X, Wang Y, ECG Enhancement and R-Peak Detection Based on Window Variability. Healthcare 9 2021; no. 2: 227. https://doi.org/10.3390/healthcare 9020227.

[15] Katamreddi H.K.P, Battula TK. A hybrid approach for machine learning based beat classification of ECG using different digital differentiators and DTCWT. Computers in Biology and Medicine 2025; Volume 194, 110426. https://doi.org/10.1016/j.compbiomed.2025.110426.

[16] Abdel-Rahman S, Antiperovitch P, Tang A, Daoud MI., Parsa V, Lacefield JC. Faster R-CNN approach for estimating global QRS duration in electrocardiograms with a limited quantity of annotated data. Computers in Biology and Medicine 2025; Volume 192, Part A, 110200. https://doi.org/10.1016/j.compbiomed. 2025.110200.

[17] Mantravadi A, Saini S, Teja R. SC, Mittal S, Shah S, Devi R. S, et al. CLINet: A novel deep learning network for ECG signal classification. Journal of Electrocardiology 2024; Volume 83, Pages 41-48. https://doi.org/10.1016/j.jelectrocard. 2024.01.004.

[18] Fan L, Chen B, Zeng X, Zhou J, Zhang X. Knowledge-enhanced meta-transfer learning for few-shot ECG signal classification. Expert Systems with Applications 2025; Volume 263, 125764. https://doi.org/10.1016/j.eswa.2024. 125764.

[19] Ahmad Z, Tabassum A, Guan L, Khan NM. ECG heartbeat classification using multimodal fusion. IEEE Access, 2021, 9: 100615-100626. https://doi.org/10.1109/ ACCESS.2021.3097614.

[20] Weimann K, Conrad TO.F.. Transfer learning for ECG classification. Sci Rep 2021; 11, 5251. https://doi.org/10.1038/ s41598-021-84374-8.

[21] Zhou F, Fang D. Classification of multi-lead ECG based on multiple scales and hierarchical feature convolutional neural networks. Sci Rep 2025; 15, 16418. https://doi.org/10.1038/ s41598-025-94127-6.

[22] Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng in Med and Biol 20(3): 45-50.

[23] Liu Z, Cao Q, Jin Q, Lin J, Lv G, Chen K. Accurate detection of arrhythmias on raw electrocardiogram images: An aggregation attention multi-label model for diagnostic assistance. Medical Engineering & Physics 2023; Volume 114, 103964, https://doi.org/10.1016/j.medengphy.2023. 103964.

[24] Jothiaruna N, Anny Leema A, SSDMNV2-FPN: A cardiac disorder classification from 12 lead ECG images using deep neural network. Microprocessors and Microsystems 2022; Volume 93,104627. https://doi.org/10.1016/j.micpro. 2022.104627.

[25] Demolder A, Kresnakova V, Hojcka M, Boza V, Iring A, Rafajdus A, et al. High precision ECG digitization using artificial intelligence[J], Journal of Electrocardiology, Volume 90, 2025, 153900. https://doi.org/10.1016/j. jelectrocard.2025.153900.

[26] Sadad T, Safran M, Khan I, Alfarhood S, Khan R, Ashraf I. Efficient Classification of ECG Images Using a Lightweight CNN with Attention Module and IoT. Sensors 2023; 23, no. 18: 7697. https://doi.org/10.3390/ s23187697.

[27] Hao P, Gao X, Li Z, Zhang J, Wu F, Bai C. Multi-branch fusion network for Myocardial infarction screening from 12-lead ECG images. Computer Methods and Programs in Biomedicine 2020; Volume 184, 105286. https://doi.org/ 10.1016/j.cmpb.2019.105286.

[28] Cao Q, Du N, Yu L, Zuo M, Lin J, Liu N, et al. Practical fine-grained learning based anomaly classification for ECG image. Artificial Intelligence in Medicine 2021; Volume 119, 102130. https://doi.org/10.1016/j.artmed. 2021.102130.

[29] Fatema K, Montaha S, Rony M. AH, Azam S, Hasan M. Z, Jonkman M. A Robust Framework Combining Image Processing and Deep Learning Hybrid Model to Classify Cardiovascular Diseases Using a Limited Number of Paper-Based Complex ECG Images. Biomedicines 2022; 10, 2835. https://doi.org/10.3390/biomedicines10112835.

[30] Khalid M, Pluempitiwiriyawej C, Abdulkadhem AA. , Afzal I, Truong T, ECGConVT: A Hybrid CNN and Vision Transformer Model for Enhanced 12-Lead ECG Images Classification. IEEE Access 2024; vol. 12, pp. 193043-193056. https://doi.org/10.1109/ACCESS.2024.3516495.

[31] Ma L, Zhang F. A Novel Real-Time Detection and Classification Method for ECG Signal Images Based on Deep Learning Sensors 2024; 24, no. 16: 5087. https://doi.org/10.3390/s24165087.

[32] Liu Z, Lin Y, Cao Y, Hu H, Wei Y, Zhang Z, Swin Transformer: Hierarchical Vision Transformer using Shifted Windows. 2021 IEEE/CVF International Conference on Computer Vision (ICCV) 2021; pp. 9992-10002. https://doi.org/10.1109/ICCV48922.2021.00986.

[33] Lin TY, Goyal P, Girshick R, He K, Dollar P. Focal Loss for dense object detection. Proceedings of the IEEE International Conference on Computer Vision (ICCV), 2017; pp. 2980-2988.

[34] AbuKaraki A, Alrawashdeh T, Abusaleh S, Alksasbeh MZ, Alqudah B, Alemerien K, et al. Pulmonary Edema and Pleural Effusion Detection Using EfficientNet-V1-B4 Architecture and AdamW Optimizer from Chest X-Rays Images. Computers, Materials and Continua 2024; Volume 80, Issue 1, Pages 1055-1073. https://doi.org/ 10.32604/cmc.2024.051420.

[35] Khan AH, Hussain M. ECG Images dataset of Cardiac Patients[dataset], Mendeley Data, V2, 2021. https://doi.org/10.17632/gwbz3fsgp8.2.

[36] Wagner P, Strodthoff N, Bousseljot RD, Kreiseler D, Lunze FI., Samek W, et al. Ptb-xl, a large publicly available electrocardiography dataset. Sci Data 2020; 7:154. https://doi.org/ 10.1038/s41597-020-0495-6.

[37] Shivashankara KK, Deepanshi, Shervedani AM, Reyna MA., Clifford GD., Sameni R. ECG-image-kit: a synthetic image generation toolbox to facilitate deep learning-based electrocardiogram digitization. In Physiological Measurement 2024; IOP Publishing. https://doi.org/ 10.1088/1361 -6579/ad4954.

[38] Bianco AM., Boente G. Addressing robust estimation in covariate-specific ROC curves, Econometrics and Statistics 2023; https://doi.org/10.1016/j.ecosta.2023. 04.001.

[39] Selvaraju RR., Cogswell M, Das A, Vedantam R, Parikh D, Batra D. Grad-CAM: Visual Explanations from Deep Networks via Gradient-Based Localization. Int J Comput Vis 2020; 128, 336-359. https://doi.org/10.1007/s11263- 019-01228-7.

Downloads

Published

02-02-2026

How to Cite

1.
Xu B, Yue Z, Ji S, Sun N, Zheng J. Intelligent ECG Classification Based on Improved Swin Transformer Model. EAI Endorsed Trans Perv Health Tech [Internet]. 2026 Feb. 2 [cited 2026 Feb. 15];11. Available from: https://publications.eai.eu/index.php/phat/article/view/11675