Accurate and Auditable ECG Classification via Visibility Graph Neural Networks
Authors: Artur Xavier, Guilherme Henrique Gomes Evangelista, Aitazaz Khan, Antonio Luiz Pinho Ribeiro, Mohammed J. Zaki, Srinivasan Parthasarathy, Wagner Meira
Organizations: Department of Computer Science, Universidade Federal de Minas Gerais, Belo Horizonte, Minas Gerais, Brazil. · Department of Computer Science, Rensselaer Polytechnic Institute, Troy, New York, USA. · Department of Internal Medicine, School of Medicine, Universidade Federal de Minas Gerais, Belo Horizonte, Minas Gerais, Brazil. · Department of Computer Science and Engineering, The Ohio State University, Columbus, Ohio, USA.
Physicians read electrocardiograms (ECGs) from waveform shape and timing, yet accurate deep-learning classifiers rarely show which waveform regions drive their predictions. We introduce LYNX-ECG, a graph neural network that represents each heartbeat as a sparse visibility graph of timestamped turning points. On CODE-Test, LYNX-ECG reaches a macro F1 score of 0.889, outperforming five baselines including the ECGFounder foundation model, while its graphs need about 14% of the storage of graphs built from every sample. Because each node maps to a specific ECG time, we can delete clinically defined waveform regions and alter beat timing to audit predictions. For conduction disorders, the clinically expected region was the strongest evidence in more than 90% of correct predictions. Bradycardia and tachycardia calls follow heart rate with conduction intervals held fixed, and atrial fibrillation calls vanish when beat-to-beat variation is removed. Sparse visibility graphs thus pair accurate ECG classification with clinically grounded, testable explanations.
Figures & tables
Figure 1: The LYNX-ECG pipeline. (a) LYNX-ECG keeps the timestamped turning points of each ECG beat and connects them with the natural visibility criterion. (b) A hierarchical GNN encodes each beat graph with an edge-aware Graph Isomorphism Network (GINE), combines the beats of each lead with a graph attention network (GATv2) and attention pooling, and pools the 12 lead embeddings into one exam embedding. A multilayer perceptron (MLP) head produces the six logits.
CODE-Test ( n=827 )
PTB-XL strict-SCP ( n=21,799$$ )
Model
Macro F1 ↑
AUROC ↑
Macro F1 ↑
AUROC ↑
LYNX-ECG
0.889±0.004
0.9984±0.0001
0.730±0.001
0.9815±0.0005
DNN [ 1 ]
0.849±0.023
0.9976±0.0002
0.718±0.003
0.9809±0.0008
ViT [ 6 ]
0.683±0.018
0.9814±0.0130
0.715±0.010
0.9791±0.0018
EfficientNet [ 7 ]
0.582±0.089
0.9744±0.0044
0.728±0.003
0.9790±0.0013
ECGFounder-Scratch [ 8 ]
0.863±0.004
0.9979±0.0003
0.730±0.013
0.9818±0.0007
Table 1: Six-label classification on CODE-Test and external PTB-XL. Macro F1 and AUROC average the six labels; F1 uses the fixed 0.5 threshold. PTB-XL labels come from exact SCP-ECG statement codes (strict-SCP; Methods). Values are mean ± sample SD across three training runs. Boldface marks the highest mean and underline marks the second-highest (ties within 0.001).
Representation
Nodes /beat
Nodes (B)
Edges (B)
HDF5 (GB)
Macro F1
AUROC
Recall
Turning points
34.46
9.83
29.27
164.6
0.889±0.004
0.9984±0.0001
0.914±0.016
Uniform k=30
30.00
8.56
28.47
121.7
0.878±0.009
0.9987±0.0002
0.887±0.004
All points
257.97
73.58
1180.74
1175.6
0.870±0.011
0.9985±0.0002
0.884±0.025
Table 2: Node selection, predictive performance, and graph size. Predictive values are CODE-Test means ± sample SD across three seeds. Graph counts and Hierarchical Data Format 5 (HDF5) storage cover the complete CODE100 dataset; B denotes billions, and all-points nodes are the resampled signal samples. LYNX-ECG uses turning points. All representations use the same model and effective batch size. Their node counts are not identical.
Figure 2: Four audits test the evidence behind each prediction. All audits keep the trained model unchanged. (a) Node attribution: Integrated Gradients (IG) scores each node, and the scores are summed within each region. (b) Structural deletion: PR, QRS, and T are removed in every combination, the gap is bridged, and the exam is rescored; exact Shapley values over the three regions give each region’s contribution. (c) Timing tests: the beats are replaced by a template, shuffled, equalized, or rebuilt at a new heart rate, and the exam is rescored. (d) Lead Shapley: every subset of the 12 leads is scored, and exact Shapley values split the credit among the leads.
Figure 3: Regional attribution and structural-deletion results. (a) Integrated Gradients (IG) lift of the expected region and of the comparison region under the zero and feature-median baselines. PR is the expected region for 1dAVb, and QRS is the expected region for RBBB and LBBB. Each point is the median over the label-positive CODE-Test exams for one trained seed, and a line joins the two baselines of the same seed. A lift of 1 (dashed line) means that a region receives attribution in proportion to its number of nodes. (b) Region with the largest Shapley contribution after structural deletion, for every label-positive exam (row) and trained seed (column). Dimmed cells are misclassified verdicts. The models classify 59 of 84 1dAVb, 96 of 102 RBBB, and 83 of 90 LBBB verdicts correctly. Across the three labels, the expected region leads in 220 of 238 correct verdicts (92.4%) and in all seeds for 74 of 92 exam–class pairs, which come from 85 distinct exams.
Figure 4: Rhythm calls follow heart rate, and conduction calls follow interval duration. Fraction of CODE-Test verdicts called positive as the imposed heart rate changes. Dashed lines scale the whole time axis of every beat, which also changes the PR, QRS, and QT durations. Solid lines change only the time before P onset and after T offset. They are drawn where at least a quarter of the cohort remains feasible, because faster rates exhaust the diastole. (a) Exams without any target label called SB, SB-positive exams called SB, and ST-positive exams called ST. (b) Conduction-positive exams called positive. Cohorts are the CODE-Test exams without any target label and the label-positive exams (SB n=16 , ST n=37 , 1dAVb n=28 , RBBB n=34 , LBBB n=30 ). Lines are means over three seeds, and bands span the seeds.
Extended Data Table 2: Graph topology and edge attributes on CODE-Test. Derived edge attributes encode the time and amplitude differences between connected nodes, (Δt,Δa) . Values are mean ± SD across three matched seeds; contrast rows report paired within-seed differences in percentage points. The interaction row is the visibility–chain contrast with the derived edge attributes minus the same contrast without them. Lower expected calibration error (ECE) is better.
Zero baseline
Feature-median baseline
Class
Expected region
Expected
Comparison
Expected
Comparison
1dAVb
PR
0.753–0.780
1.980–2.109
1.096–1.257
1.239–1.312
RBBB
QRS
2.156–2.208
0.499–0.592
1.469–1.764
0.928–1.053
LBBB
QRS
2.048–2.113
0.682–0.742
1.335–1.514
0.996–1.072
Extended Data Table 3: Regional IG attribution under two reference inputs. The analysis includes 85 label-positive CODE-Test exams, comprising 92 positive exam–class pairs. Ranges span the minimum and maximum of the three per-seed median lifts. A lift of 1 indicates attribution proportional to the region’s node count. The comparison region is QRS for 1dAVb and PR for RBBB and LBBB. The feature-median baseline uses training-set feature medians.
Region definition
1dAVb
RBBB
LBBB
All
T leads
Per-beat delineation
47/59
95/96
78/83
220/238 (92%)
1
Fixed, class-specific
48/59
89/96
68/83
205/238 (86%)
5
Fixed, standardized
49/59
89/96
67/83
205/238 (86%)
5
Extended Data Table 4: Effect of region definition on structural-deletion verdicts. All three definitions are evaluated on the same available beats. Cells report how often the expected region leads among correctly classified verdicts. “T leads” counts 1dAVb verdicts in which the T region has the largest Shapley contribution. Both fixed-window definitions use PR from −0.35 to −0.07 s and QRS from −0.06 to +0.12 s relative to the R peak and differ only in the T window: the class-specific variant sets a different T window for each class, and the standardized window spans +0.15 to +0.45 s for every class (Supplementary Note 8).
Extended Data Fig. 1: Each beat becomes a sparse graph that keeps its morphology. One V1 beat of a CODE-Test exam keeps 31 of its 240 samples ( 87 % fewer). Natural visibility connects these nodes with 95 edges; R-peak edges are highlighted.
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
Supplementary Fig. 1: External ranking degrades most for 1dAVb. Run A curves mark the fixed- 0.5 operating point; Supplementary Table 4 reports per-class results across all three seeds.
Supplementary Fig. 2: PR and QRS Shapley contributions per verdict. PR against QRS Shapley contribution for every verdict, primary availability rule ( N=276 verdicts: 84 for 1dAVb, 102 for RBBB, and 90 for LBBB). Color marks the leading region; faded points are misclassified verdicts; markers are the three seeds. The dashed line is the PR-equals-QRS diagonal. Axes cross zero because Shapley contributions are signed.
Supplementary Fig. 3: Uniform rate sweep on both datasets. Fraction of verdicts called SB (solid) or ST (dashed) as every beat’s time axis is scaled to the imposed heart rate. Lines are means over three seeds, and bands span the seeds.
Supplementary Fig. 4: Intact predictions against measured rhythm descriptors. Seed-mean probability of SB and ST against the heart rate measured from the stored R anchors, and of AF against the RR coefficient of variation. Dotted lines mark 50 and 60 beats/min for SB and 100 beats/min for ST.
Supplementary Fig. 5: Mean normalized lead Shapley value per label. Each cell averages, over label-positive verdicts, a lead’s Shapley value divided by the sum of positive lead values. Negative cells can reflect dilution under attention pooling.
Electrocardiogram classification uses machine learning to identify heart rhythms and cardiac conditions from ECG waveforms for screening, diagnosis, and monitoring.
In light of strides in Arti cial Intelligence (AI) and its wide spread application, challenges persist in the interpretability of AI models, particularly within specialized domains like healthcare, such as electro cardiograph (ECG) recognition. Rather than relying solely on end-to-end convolutional neural networks, this paper introduces a novel approach using a domain knowledge-based graph convolution network for ECG recognition. Key landmarks points of PRQST, vital to ECG interpreta tion, are incorporated as domain knowledge. The double-stream directed graph is employed to model both intra and inter ECG cycles. Speci cally, spatial directed graphs capture the positional relationships among key points, while temporal directed graphs delineate temporal dependencies between adjacent cycles in extended ECG sequences. Experimental re sults on the First Chinese ECG Intelligent Competition dataset, which speci cally classify ECG into nine categories, prove the e cacy of the proposed model. The overall average F1 score is 88.1%, the average F1 score of rare categories is 76.3%, both outperform the state-of-the-art models. The introduction of domain knowledge did enhance the detec tion performance, especially for rare categories.
Wenting Ma, Zhipeng Zhang, Xiaohang Yuan +6
China Mobile Research Institute, Beijing, China · China Mobile GBA (Greater Bay Area) Innovation Institute, Guangzhou, China · Beijing Jiaotong University, Beijing, China +2
Cardiologists interpret electrocardiograms by localizing waveform components, measuring rhythm and interval patterns, and translating these structured observations into diagnostic evidence. Whether this expert reading process can serve as an effective prior for ECG agents remains unclear. To address this question, we introduce LuminaECG, a clinically structured ECG reasoning framework that reformulates ECG interpretation as measurement-grounded visual reading. ECG signals are rendered on standard electrocardiographic grid paper to preserve the spatial and scale cues used in clinical reading. P-wave, QRS-complex, and T-wave boundaries are explicitly delineated, and color-coded segmentation decomposes the waveform into discrete visual measurement primitives. A general 2B vision-language backbone is then trained with low-rank supervised fine-tuning to associate these primitives with diagnostic reasoning, without architectural modification. Across open, proprietary, and ECG-specialist zero-shot baselines, LuminaECG improves both waveform measurement and diagnostic recovery. It reaches a clinically meaningful reader tier on the CODE-test benchmark, transfers across geographically diverse ECG datasets without retraining, and generates reports whose structure contains an emergent prognostic signal. These findings suggest that effective ECG agents require not only larger models, but supervision that preserves the alignment between measurable waveform evidence and clinical knowledge.
Hongxiang Gao, He-yang Xu, Yuwen Li +6
State Key Laboratory of Digital Medical Engineering, Southeast University · School of Instrument Science and Engineering, Southeast University
Electrocardiography (ECG) is a cornerstone of cardiac diagnosis, yet most machine learning methods for ECG analysis lack interpretability, limiting their clinical adoption. We present IECG, a weakly-supervised ECG foundation model that jointly performs diagnostic classification and abnormality localization without requiring manual abnormal region annotations, overcoming a long-standing bottleneck in interpretable ECG learning. Central to IECG is a weakly-supervised attention strategy that explicitly incorporates clinical priors by deriving abnormality heatmap pseudo-labels from established ECG clinical knowledge. These pseudo-labels guide the model's CLS-token attention through a KL-divergence loss, encouraging it to focus on diagnostically relevant waveform regions. During pretraining, IECG is jointly optimized with clinically guided attention supervision, ECG-text contrastive alignment, and report captioning objectives, enabling it to learn rich multimodal representations while producing localized waveform evidence. By explicitly aggregating features from clinically guided attention regions, IECG grounds its diagnostic predictions in interpretable waveform evidence without sacrificing classification performance. Extensive experiments demonstrate that IECG achieves state-of-the-art abnormal region localization while maintaining strong classification performance, advancing trustworthy foundation models for ECG analysis.
Huynh Dang Nguyen, Trong-Thang Pham, Anh-Thuan Do +4
Quantum AI & Cyber Security Institute (QACI) - FPT Corporation, Vietnam · University of Arkansas, USA · Hospital Haiphong Medical University, Vietnam +2