Atrial Fibrillation Detection with Arbitrary Leads via a Codebook-Based Reconstruction-Classification Framework
Organizations: Information Center, The People’s Hospital of Baoan Shenzhen, Shenzhen, 518101, Guangdong, China · School of Computer Science and Engineering, South China University of Technology, Guangzhou, 510006, Guangdong, China · Department of Cardiology, The People’s Hospital of Baoan Shenzhen, Shenzhen, 518101, Guangdong, China · Institute for Advanced Study, Shenzhen University, Shenzhen, 518060, Guangdong, China
Abstract
Background and Objective: Reliable atrial fibrillation (AF) detection from electrocardiogram (ECG) signals remains challenging in real-world clinical settings due to variable lead configurations, cross-dataset domain shifts, and pervasive physiological and technical artifacts. So we develop a robust and generalizable deep learning model for accurate AF detection.\ Methods: We propose the Dual-Codebook Graph Collaborative Network (DCGCNet), a novel end-to-end vector-quantized variational autoencoder that jointly performs AF classification and ECG reconstruction. DCGCNet introduces two key components: (1) a Local-Global Contrastive Module for learning noise-invariant representations, and (2) an Adaptive Codebook Vector Quantizer that dynamically refines codebook prototypes to better align with input data distributions, thereby preventing codebook collapse and enhancing generalization.\ Results: DCGCNet achieves state-of-the-art performance in standard intra-dataset 12-lead evaluation and demonstrates exceptional cross-dataset generalization across seven diverse settings, consistently attaining AUC > 0.98 in all cases. Furthermore, it maintains high diagnostic accuracy under realistic noisy conditions, including baseline wander, powerline interference, and EMG artifacts.\ Conclusions: DCGCNet establishes a new benchmark for robust, generalizable, and noise-resilient AF detection, showing strong potential for deployment in real-world clinical environments.
Figures & tables
| Dataset | Normal | AF | Hz | Country | Leads |
| Chapman (Train) | 6508 | 1416 | 500 | China | 12 |
| CPSC2018 (Train) | 1710 | 2215 | 500 | China | 12 |
| Chapman (Test) | 1617 | 364 | 500 | China | 12 |
| CPSC2018 (Test) | 423 | 531 | 500 | China | 12 |
| AFDB | 36718 | 22053 | 250 | America | 2 |
| LTAF | 187470 | 154590 | 128 | America | 2 |
| Model | Chapman Lead I | Chapman Lead I+II+V1 | CPSC2018 Lead I | CPSC2018 Lead I+II+V1 | ||||||||||||
| PCC | R 2 | RMSE | MAE | PCC | R 2 | RMSE | MAE | PCC | R 2 | RMSE | MAE | PCC | R 2 | RMSE | MAE | |
| ResCNN [ 34 ] | 0.7828 (0.0012) | 0.6424 (0.0016) | 0.5983 (0.0014) | 0.3173 (0.0012) | 0.9349 (0.0006) | 0.8881 (0.0012) | 0.3402 (0.0020) | 0.1643 (0.0016) | 0.7519 (0.0013) | 0.5933 (0.0053) | 0.6406 (0.0042) | 0.3387 (0.0016) | 0.9132 (0.0011) | 0.8537 (0.0021) | 0.3853 (0.0029) | 0.1800 (0.0022) |
| GRU [ 21 ] | 0.7770 (0.0010) | 0.6328 (0.0018) | 0.6064 (0.0015) | 0.3257 (0.0023) | 0.9336 (0.0011) | 0.8844 (0.0021) | 0.3460 (0.0033) | 0.1768 (0.0021) | 0.7541 (0.0047) | 0.6025 (0.0048) | 0.6332 (0.0038) | 0.3397 (0.0025) | 0.9115 (0.0006) | 0.8521 (0.0014) | 0.3875 (0.0019) | 0.1910 (0.0082) |
| EKGAN [ 20 ] | 0.7272 (0.0011) | 0.5342 (0.0122) | 0.6801 (0.0089) | 0.3714 (0.0043) | 0.9139 (0.0016) | 0.8320 (0.0042) | 0.4084 (0.0050) | 0.1983 (0.0047) | 0.7309 (0.0025) | 0.5177 (0.0202) | 0.6941 (0.0144) | 0.3652 (0.0048) | 0.9190 (0.0026) | 0.8441 (0.0046) | 0.3947 (0.0058) | 0.1826 (0.0043) |
| ESN [ 18 ] | 0.6977 (0.0003) | 0.5276 (0.0014) | 0.6849 (0.0010) | 0.3624 (0.0002) | 0.9099 (0.0002) | 0.8261 (0.0003) | 0.4156 (0.0004) | 0.1921 (0.0003) | 0.6617 (0.0012) | 0.4825 (0.0010) | 0.7191 (0.0007) | 0.3754 (0.0006) | 0.8893 (0.0004) | 0.7997 (0.0014) | 0.4474 (0.0015) | 0.1988 (0.0010) |
| DCGCNet(Ours) | 0.7865 (0.0015) | 0.6407 (0.0025) | 0.5974 (0.0021) | 0.3086 (0.0009) | 0.9376 (0.0009) | 0.8811 (0.0019) | 0.3437 (0.0027) | 0.1530 (0.0018) | 0.7583 (0.0015) | 0.6012 (0.0058) | 0.6313 (0.0046) | 0.3259 (0.0014) | 0.9158 (0.0010) | 0.8448 (0.0021) | 0.3938 (0.0027) | 0.1714 (0.0011) |
| Model | Chapman Dataset | CPSC2018 Dataset | ||||||||
| AUC | ACC | F1 | Pre | Recall | AUC | ACC | F1 | Pre | Recall | |
| DNN [ 46 ] | 0.9790 (0.0027) | 0.9332 (0.0033) | 0.8840 (0.0053) | 0.9016 (0.0097) | 0.8692 (0.0080) | 0.9841 (0.0019) | 0.9306 (0.0099) | 0.9301 (0.0097) | 0.9293 (0.0090) | 0.9330 (0.0082) |
| DenseRNN [ 24 ] | 0.9974 (0.0003) | 0.9694 (0.0047) | 0.9459 (0.0089) | 0.9759 (0.0034) | 0.9217 (0.0137) | 0.9965 (0.0005) | 0.9157 (0.0201) | 0.9156 (0.0201) | 0.9198 (0.0158) | 0.9238 (0.0181) |
| ConvRGNN [ 42 ] | 0.9627 (0.0048) | 0.9318 (0.0040) | 0.8832 (0.0095) | 0.8948 (0.0086) | 0.8739 (0.0201) | 0.9545 (0.0091) | 0.8889 (0.0109) | 0.8875 (0.0112) | 0.8878 (0.0113) | 0.8881 (0.0120) |
| MSGformer [ 19 ] | 0.9863 (0.0033) | 0.9556 (0.0052) | 0.9246 (0.0102) | 0.9322 (0.0077) | 0.9183 (0.0194) | 0.9962 (0.0004) | 0.9730 (0.0044) | 0.9727 (0.0043) | 0.9721 (0.0049) | 0.9735 (0.0036) |
| ECGMamba [ 43 ] | 0.9910 (0.0012) | 0.9637 (0.0018) | 0.9385 (0.0034) | 0.9458 (0.0055) | 0.9317 (0.0076) | 0.9931 (0.0014) | 0.9602 (0.0036) | 0.9597 (0.0036) | 0.9595 (0.0041) | 0.9607 (0.0039) |
| Setting | Rec. (PCC) | Cls. (AUC) | ||
| Chapman | CPSC2018 | Chapman | CPSC2018 | |
| DCGCNet | 0.7865 | 0.7583 | 0.9998 | 0.9991 |
| w/o rec | - | - | 0.9883 | 0.9749 |
| w/o cls | 0.7751 | 0.7553 | - | - |
| w/o rhythm | 0.7812 | 0.7521 | 0.9823 | 0.9754 |
| w/o morph | 0.7205 | 0.6957 | 0.9986 | 0.9972 |
| Setting | CPSC2018(12 Leads) | AFDB(2 Leads) | SPHDB(1 Lead) |
| DCGCNet | 0.9967 | 0.9951 | 0.9947 |
| w/o AC | 0.9792 | 0.9715 | 0.9624 |
| w/o ACVQ | 0.9658 | 0.9543 | 0.9431 |
| Chapman | CPSC2018 | |||||
| Setting | BLW | PLI | EMG | BLW | PLI | EMG |
| DCGCNet | 0.9941 | 0.9952 | 0.9889 | 0.9863 | 0.9914 | 0.9807 |
| w/o ACVQ | 0.9624 | 0.9681 | 0.9432 | 0.9415 | 0.9523 | 0.9218 |
| w/o LGCM_L | 0.9832 | 0.9847 | 0.9603 | 0.9684 | 0.9721 | 0.9456 |
| w/o LGCM_G | 0.9756 | 0.9802 | 0.9714 | 0.9592 | 0.9667 | 0.9523 |
| w/o LGCM | 0.9518 | 0.9584 | 0.9276 | 0.9237 | 0.9341 | 0.9024 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Train | Test | Input | AUC | ACC | F1 | Precision | Recall | Method | Other |
| AFDB | AFDB | 30s | 99.50 | 97.10 | – | – | 97.00 | Wavelet + SVM [ 2 ] | 2-fold CV |
| AFDB | AFDB | 30 beats | – | 97.60 | 97.10 | – | 98.00 | Peak + RF [ 17 ] | 4-fold CV |
| AFDB | AFDB | 1.2s | – | 99.23 | – | – | 99.41 | Wavelet + CNN [ 15 ] | 4:1 split |
| AFDB | AFDB | 30s | – | 97.80 | – | – | 98.98 | CNN + LSTM [ 1 ] | 5-fold CV |
| AFDB | AFDB | 30s | – | 93.00 | 92.64 | – | 89.83 | Siamese + Few-shot TL [ 39 ] | 5-fold CV |
| AFDB | AFDB | 15s | – | 99.11 | 97.00 | 99.46 | 95.40 | Spatio-temporal Siamese [ 28 ] | 8:1:1 split |
| Setting | Chapman AUC | Chapman ACC | CPSC2018 AUC | CPSC2018 ACC | |||
| Default | 0.2 | 0.5 | 0.1 | 99.98 | 99.66 | 99.91 | 99.37 |
| Weaker global | 0.2 | 0.1 | 0.1 | 99.74 | 98.83 | 99.48 | 98.26 |
| Stronger global | 0.2 | 1.0 | 0.1 | 99.80 | 99.03 | 99.62 | 98.63 |
| Excessive global | 0.2 | 3.0 | 0.1 | 99.22 | 97.59 | 98.51 | 96.54 |
| Weaker local | 0.2 | 0.5 | 0.02 | 99.66 | 98.54 | 99.35 | 98.07 |
| Stronger local | 0.2 | 0.5 | 0.20 | 99.70 | 98.75 | 99.54 | 98.42 |