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.
China Mobile Research Institute, Beijing, China · China Mobile GBA (Greater Bay Area) Innovation Institute, Guangzhou, China · Beijing Jiaotong University, Beijing, China +2
Quantum AI & Cyber Security Institute (QACI) - FPT Corporation, Vietnam · University of Arkansas, USA · Hospital Haiphong Medical University, Vietnam +2