Cardioformer: Advancing AI in ECG Analysis with Multi-Granularity Patching and ResNet

Md Kamrujjaman Mobin, Md Saiful Islam, Sadik Al Barid, Md Masum
5/8/2025
cs.LGcs.AIeess.SP

Official code: KMobin555/Cardioformer (11 stars, MIT, last commit 2025-06-08).

Abstract

Electrocardiogram (ECG) classification is crucial for automated cardiac disease diagnosis, yet existing methods often struggle to capture local morphological details and long-range temporal dependencies simultaneously. To address these challenges, we propose Cardioformer, a novel multi-granularity hybrid model that integrates cross-channel patching, hierarchical residual learning, and a two-stage self-attention mechanism. Cardioformer first encodes multi-scale token embeddings to capture fine-grained local features and global contextual information and then selectively fuses these representations through intra- and inter-granularity self-attention. Extensive evaluations on three benchmark ECG datasets under subject-independent settings demonstrate that model consistently outperforms four state-of-the-art baselines. Our Cardioformer model achieves the AUROC of 96.34$\pm$0.11, 89.99$\pm$0.12, and 95.59$\pm$1.66 in MIMIC-IV, PTB-XL and PTB dataset respectively outperforming PatchTST, Reformer, Transformer, and Medformer models. It also demonstrates strong cross-dataset generalization, achieving 49.18% AUROC on PTB and 68.41% on PTB-XL when trained on MIMIC-IV. These findings underscore the potential of Cardioformer to advance automated ECG analysis, paving the way for more accurate and robust cardiovascular disease diagnosis. We release the source code at https://github.com/KMobin555/Cardioformer.

View on arXivView PDF

Code Implementations(1)

MIT
110Python, Jupyter NotebookApr 25, 20251 years agoMIT

Similar Papers

Cite this paper

@article{mobin2025cardioformer,
  title  = {Cardioformer: Advancing AI in ECG Analysis with Multi-Granularity Patching and ResNet},
  author = {Md Kamrujjaman Mobin and Md Saiful Islam and Sadik Al Barid and Md Masum},
  year   = {2025},
  eprint = {2505.05538},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.05538v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.05538.svg)](https://codeofpaper.com/paper/2505.05538)

Discussion