arXiv:2610.41795cs.LGOct 2026

Manuscript Offprint

arXiv:2610.41795

Accurate and Auditable ECG Classification via Visibility Graph Neural Networks

Artur Xavier, Guilherme Henrique Gomes Evangelista, Aitazaz Khan, Antonio Luiz Pinho Ribeiro, Mohammed J. Zaki, Srinivasan Parthasarathy, Wagner Meira

Abstract

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.

Keywords: electrocardiography, graph neural networks, visibility graphs, explanation auditing, sparse representation

The 12-lead electrocardiogram (ECG) is a gold-standard, non-invasive test used to detect cardiac rhythm and conduction disorders [1, 2]. Each lead captures the heart's electrical activity over time from a unique perspective. Physicians interpret these waveforms by analyzing their shape, duration, and sequence across beats and leads. A machine learning model designed to assist in this analysis should be explainable, providing evidence linked to identifiable regions that physicians want to investigate.

Recent machine learning models have demonstrated strong performance in classification tasks by analyzing raw ECG measurements over time [1, 3–6]. ECGFounder, pretrained on more than 10 million ECGs, itself identifies black-box opacity as an open limitation [4]. These models represent clinical structures, such as beat boundaries and waveform landmarks, only implicitly, through raw sample positions and amplitudes. As a result, standard attribution methods often highlight isolated points instead of meaningful waveform regions. Additionally, it remains challenging to establish the model's true dependence on these highlighted areas. Attribution methods, like Integrated Gradients (IG) [7], are highly sensitive to the choice of reference input [8, 9]. Explanation methods for graph neural networks (GNNs) can disagree with one another [10–13], attention can fail faithfulness tests [14], and redundant predictors can yield seed-dependent explanations [15], so explanations need localization, perturbation, and replication checks [16, 17].

Graph-based representations of ECGs provide a potential solution. However, such an approach (e.g., based on visibility graphs [18, 19]) must represent waveform regions while keeping graph construction manageable. Such a graph should preserve the predictive signal and the timestamps needed for regional interventions without assigning a node to every sample. Existing sparse and relational ECG methods choose other units: learned subsequences [20], relations between channels [21], three hand-designed P/QRS/T segment nodes per beat [22], or lead-level graphs for myocardial-infarction localization [23]. Prior ECG visibility graphs operate on raw samples [19]. Their naive adaptation, which we call all-points, makes every sample a node and connects pairs that are geometrically visible, and it exemplifies the scale constraint: on the full CODE training dataset (CODE100), it exceeds one trillion edges and requires more than one terabyte of storage.

We explore turning-point visibility graphs, an alternative that locally sparsifies the naive graph representation [24] by selecting samples before graph construction. This selection uses local extrema to capture waveform shape and clinical landmarks, such as R peaks and points associated with ventricular activation, to help define individual beats. Unlike P/QRS/T segment nodes [22], the retained nodes carry no clinical wave labels. For each beat, the selected samples form the graph nodes, and the natural visibility criterion determines their connections. We encode each beat graph with a GNN, then combine the resulting representations first within each lead and then across leads to make exam-level predictions. We call the resulting model LYNX-ECG (Lead-level visibilitY Networks for eXplainable ECG). Because each node retains its

Figure

Fig. 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.

original timestamp, we can map attribution and deletion results back to predefined ECG landmarks and regions, such as the R peak and other waveform segments. Fig. 1 summarizes these steps.

Our contributions are as follows. First, LYNX-ECG adapts visibility graphs to ECG classification and is competitive with ECG foundation models such as ECG-Founder. Second, turning-point selection reduces the node count by more than 86% while keeping this performance. Third, by combining IG with structural deletion, timing interventions, and an exact lead decomposition, we audit which regions, timing, and leads drive each diagnosis, an audit that raw-signal models can approximate only by masking samples. Fourth, we evaluate how node selection, topology, edge attributes, and message direction on two real-world datasets affect classification tasks.

Results

We evaluated turning-point visibility graphs for six-label ECG classification on held-out CODE-Test and on PTB-XL as an external dataset [2], whose diagnostic labels we mapped to the same six targets (Methods; Supplementary Table 1).

We report macro F1, the area under the receiver operating characteristic curve (AUROC), and the area under the precision-recall curve (AUPRC). F1, precision, and recall use a fixed threshold of 0.5, and every result covers three training seeds.

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).

ModelCODE-Test (n=827n=827)PTB-XL strict-SCP (n=21799n=21799)
Macro F1 ↑AUROC ↑Macro F1 ↑AUROC ↑
LYNX-ECG0.889±0.0040.889 \pm 0.0040.9984±0.00010.9984 \pm 0.00010.730±0.0010.730 \pm 0.0010.9815±0.00050.9815 \pm 0.0005
DNN [1]0.849±0.0230.849 \pm 0.0230.9976±0.00020.9976 \pm 0.00020.718±0.0030.718 \pm 0.0030.9809±0.00080.9809 \pm 0.0008
ViT [25]0.683±0.0180.683 \pm 0.0180.9814±0.01300.9814 \pm 0.01300.715±0.0100.715 \pm 0.0100.9791±0.00180.9791 \pm 0.0018
EfficientNet [26]0.582±0.0890.582 \pm 0.0890.9744±0.00440.9744 \pm 0.00440.728±0.0030.728 \pm 0.0030.9790±0.00130.9790 \pm 0.0013
ECGFounder-Scratch [4]0.863±0.0040.863 \pm 0.0040.9979±0.00030.9979 \pm 0.00030.730±0.0130.730 \pm 0.0130.9818±0.00070.9818 \pm 0.0007
ECGFounder-Finetuned [4]0.858±0.0350.858 \pm 0.0350.9961±0.00160.9961 \pm 0.00160.734±0.0030.734 \pm 0.0030.9730±0.00100.9730 \pm 0.0010

References (37)