[Paper Review] MSW-Transformer: Multi-Scale Shifted Windows Transformer Networks for 12-Lead ECG Classification
This paper proposes MSW-Transformer, a lightweight, single-layer Transformer architecture using multi-scale shifted windows with learnable feature fusion to improve 12-lead ECG classification. It achieves state-of-the-art performance on the PTBXL-2020 dataset, with macro-F1 scores up to 77.85% for superclasses and 81.26% for samples, while enhancing interpretability through attention visualization.
Automatic classification of electrocardiogram (ECG) signals plays a crucial role in the early prevention and diagnosis of cardiovascular diseases. While ECG signals can be used for the diagnosis of various diseases, their pathological characteristics exhibit minimal variations, posing a challenge to automatic classification models. Existing methods primarily utilize convolutional neural networks to extract ECG signal features for classification, which may not fully capture the pathological feature differences of different diseases. Transformer networks have advantages in feature extraction for sequence data, but the complete network is complex and relies on large-scale datasets. To address these challenges, we propose a single-layer Transformer network called Multi-Scale Shifted Windows Transformer Networks (MSW-Transformer), which uses a multi-window sliding attention mechanism at different scales to capture features in different dimensions. The self-attention is restricted to non-overlapping local windows via shifted windows, and different window scales have different receptive fields. A learnable feature fusion method is then proposed to integrate features from different windows to further enhance model performance. Furthermore, we visualize the attention mechanism of the multi-window shifted mechanism to achieve better clinical interpretation in the ECG classification task. The proposed model achieves state-of-the-art performance on five classification tasks of the PTBXL-2020 12-lead ECG dataset, which includes 5 diagnostic superclasses, 23 diagnostic subclasses, 12 rhythm classes, 17 morphology classes, and 44 diagnosis classes, with average macro-F1 scores of 77.85%, 47.57%, 66.13%, 34.60%, and 34.29%, and average sample-F1 scores of 81.26%, 68.27%, 91.32%, 50.07%, and 63.19%, respectively.
Motivation & Objective
- Address the challenge of low-difference pathological features in ECG signals that hinder automatic classification.
- Overcome limitations of CNNs and standard Transformers in capturing subtle ECG variations and handling long sequences.
- Develop a lightweight, efficient Transformer model with reduced complexity and computational cost for clinical deployment.
- Improve model interpretability by visualizing attention mechanisms aligned with clinical diagnostic rules.
- Achieve state-of-the-art performance on multi-class 12-lead ECG classification tasks with minimal parameters.
Proposed method
- Proposes a multi-scale shifted window mechanism where self-attention is restricted to non-overlapping local windows at different scales to capture hierarchical features.
- Uses shifted windows to enable cross-window information flow while maintaining local attention efficiency and reducing computational cost.
- Introduces a learnable feature fusion module that combines attention outputs from multiple window scales to enhance representation learning.
- Employs a single-layer Transformer block with position encoding to model long-range dependencies in 12-lead ECG sequences.
- Visualizes attention scores across different window scales and correlates them with clinical diagnostic criteria for interpretability.
Experimental results
Research questions
- RQ1Can a single-layer Transformer with multi-scale shifted windows outperform deeper or more complex models in 12-lead ECG classification?
- RQ2How does the multi-scale window mechanism improve feature extraction for ECG signals with subtle pathological differences?
- RQ3To what extent does learnable feature fusion enhance model performance compared to fixed concatenation or averaging?
- RQ4Can the attention mechanism in MSW-Transformer be meaningfully interpreted in alignment with clinical diagnostic rules?
- RQ5How does the model perform on imbalanced ECG classification tasks, especially for rare or clinically similar arrhythmias?
Key findings
- MSW-Transformer achieves state-of-the-art macro-F1 scores of 77.85% on 5 diagnostic superclasses, 47.57% on 23 subclasses, 66.13% on 12 rhythm classes, 34.60% on 17 morphology classes, and 34.29% on 44 diagnosis classes in the PTBXL-2020 dataset.
- The model achieves sample-F1 scores of 81.26%, 68.27%, 91.32%, 50.07%, and 63.19% respectively, indicating strong performance on both balanced and imbalanced classes.
- The confusion matrix shows high accuracy for common classes such as Norm (89.13% macro-F1), CLBBB (90.00%), SR (95.96%), and STACH (92.62%), indicating low misclassification rates.
- Despite data imbalance, the model shows robustness in distinguishing common ECG patterns, though performance drops on rare labels like ISCA, NST, and LAFB/LPFB due to class similarity.
- Attention visualization confirms that the model focuses on clinically relevant ECG segments—such as ST segments and QRS complexes—aligning with expert diagnostic criteria, enhancing interpretability.
- The model has lower parameter count and faster inference speed than standard Transformers, making it suitable for real-world clinical deployment.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.