CardioPatternFormer: Pattern-Guided Attention for Interpretable ECG Classification with Transformer Architecture

Uğraş, Berat Kutay, Gerek, Ömer Nezih, Saygı, İbrahim Talha

arXiv.org Artificial Intelligence 

--Electrocardiogram (ECG) interpretation is fundamental to cardiac diagnosis, but deep learning models often lack transparency, hindering clinical trust. We introduce Car-dioPatternFormer, a novel transformer-based architecture that reframes ECG interpretation through the lens of pattern recognition, treating cardiac patterns as a vocabulary learned from data. CardioPatternFormer integrates several innovations: (1) a Cardiac Pattern T okenizer that decomposes ECG signals into learned, multi-scale patterns; (2) Physiologically Guided Attention mechanisms incorporating adaptable, domain-specific constraints based on cardiac electrophysiology; (3) Multi-Resolution T emporal Encoding to capture diverse temporal dynamics; and (4) specialized classification heads providing class-specific attention visualizations for detailed diagnostic explanations. Evaluated on the Chapman-Shaoxing dataset across major diagnostic categories, CardioPatternFormer demonstrates strong classification performance, particularly for rhythm disorders, with results aligning with clinical experience regarding diagnostic difficulty gradients. More significantly, CardioPatternFormer enhances in-terpretability by visualizing physiologically relevant ECG regions influencing each diagnosis, bridging automated analysis and clinical reasoning. This pattern-centric approach advances ECG classification and establishes a foundation for more transparent and clinically integrated cardiac signal analysis. I. INTRODUCTION The electrocardiogram (ECG) stands as a cornerstone of cardiovascular diagnostics, offering a non-invasive window into the heart's electrical activity. Annually, hundreds of millions of ECGs are performed worldwide, underscoring its fundamental role in identifying a wide spectrum of cardiac conditions [20]. Despite its ubiquity and the wealth of information it provides, accurate ECG interpretation demands considerable expertise, typically cultivated over years of rigorous training and clinical practice. Even amongst seasoned cardiologists, inter-reader variability remains a notable challenge, with studies reporting significant discrepancies in the identification of specific cardiac abnormalities. This variability highlights not only the inherent complexities of ECG analysis but also the persistent need for advanced computational tools that can deliver consistent, precise, and interpretable analyses.