Which Part of the Heartbeat Reads the Blood? Wave-Level Attribution for ECG Lab-Value Models

Deep networks can now look at a routine 10-second electrocardiogram (ECG), the recording of the heart's electrical activity, and predict whether a patient's blood tests are abnormal. The targets include NT-proBNP, a heart-strain hormone, hemoglobin, albumin, and urea nitrogen. None of these models says what in the waveform it used. It might have used T-wave shape, P-wave width, the timing between beats, or nothing about the waveform at all beyond the patient's age and vital signs. This proposal builds an attribution method that answers that question in clinically meaningful units. For every prediction, it splits the model's output into four shares. One share comes from demographics and vitals. One comes from beat-to-beat rhythm. One comes from the shape of each named wave (P, QRS, ST-T). The last is morphology that standard interval measurements do not capture. It then checks that split with interventions on the input signal, not only with gradients.

The method rests on Integrated Gradients, which scores each input sample by accumulating the model's gradient along a path from a reference signal to the real one. Our change is to choose the reference physiologically. Instead of a flat zero line, we use a population template beat that has been time-warped onto the patient's own beat boundaries. Walking from one such reference to another isolates rhythm from shape. Summing the attribution over delineated wave segments turns noisy per-sample maps into per-wave scores. The scientific payoff is a direct test of a claim that is currently only asserted: that waveform models "see" subclinical systemic chemistry that hand-measured intervals miss.

Why this, and why now

The motivation comes from two CardioLab papers from the same group. The tabular study trained gradient-boosted trees on automated ECG intervals, demographics and vitals and reached AUROC 0.901 for albumin, 0.881 for hemoglobin and 0.866 for NTproBNP (CardioLab: Laboratory Values Estimation from Electrocardiogram Features). The multimodal follow-up fused a state-space sequence model (S4) on raw waveforms with an MLP on metadata. It reported 0.870 for hemoglobin, 0.859 for albumin and 0.882 for NTproBNP (CardioLab: Multimodal Deep Learning Approach). The raw-waveform model does not clearly beat the interval model on albumin or hemoglobin. Both papers name explainability as future work. Nobody currently knows whether the waveform branch contributes information beyond intervals and demographics, or which wave carries it. The same black-box status applies to CRT-Net, a hybrid network that stacks a convolutional front end, a bidirectional recurrent layer and a Transformer. It reports 91.7% accuracy for chronic kidney disease and 90.2% for type-2 diabetes on 1,235 local ECGs, with no attribution at all.

The method comes from three sources. Segment Integrated Gradients (XRAI) showed on images that summing Integrated Gradients over regions, with two baselines, localizes better than Grad-CAM or pixel-level Integrated Gradients (localization AUC 0.836 vs 0.742 vs 0.710 on ImageNet segmentation). The authors flag time series as untested. We replace XRAI's generic over-segmentation with physiological delineation. MEETI supplies wavelet-extracted P, QRS and T onsets and offsets for 784,680 MIMIC-IV-ECG records (MEETI), so every segment boundary is already available on the same cohort the CardioLab labels come from. Clinically meaningful interpretability of an AI model for ECG classification showed that fine-grained input gradients on a convolutional network correlate with electrophysiologist annotations (0.94 for premature ventricular contractions, 0.96 for atrial flutter). That work covers localized arrhythmias only.

One claim in the literature needs correcting. That paper describes its Jacobian method as limited to feed-forward networks, and the research file extends this into a "recurrence barrier." Backpropagation through time computes exact input gradients for recurrent and state-space models. What those models lose is the clean alignment between an internal state and a moment in the input. That loss is a reason to attribute at the input in physiological units rather than at hidden layers, which is what we do. We therefore do not claim to have made gradients work through recurrence.

Explaining deep learning for ECG using time-localized clusters found that a 1D-ResNet's internal activations cluster into P, QRS and T segments without supervision. This constrains the design: wave-level units are the natural resolution of these models, which supports aggregating attribution per wave. That paper links clusters to outputs only through a downstream random forest, not through the model's own gradients.

Core Claim

A prediction $F(x)$ for ECG $x$ can be decomposed exactly into demographic, rhythm and per-wave morphology shares. Two references make this possible. The first, $x^{r}$, keeps the patient's R-peak times but replaces every beat with a population median beat time-warped onto the patient's delineated boundaries. The second, $x^{0}$, places that template beat at the population mean regular heart rate. The model's output moves from $F(x^{0})$ to $F(x^{r})$ purely through rhythm, and from $F(x^{r})$ to $F(x)$ purely through beat shape. For the shape step, the Integrated Gradients completeness property gives

$$F(x)-F(x^{r}) = \sum_{s} A_s, \qquad A_s=\sum_{t\in s}(x_t-x^{r}_t)\int_0^1 \partial_{t}F\big(x^{r}+\alpha(x-x^{r})\big)\,d\alpha,$$

where $s$ ranges over delineated segments (P wave, PR, QRS, ST, T and remainder, per lead) and $t$ indexes samples. Summing over all segments therefore recovers the full shape step. The demographic branch gets an analogous share, using a cohort-mean baseline. The order of the steps matters, so we average over all orderings of the three factors (six paths, a Shapley average), which is cheap.

The factorized template reference is the key ingredient. It stays inside the distribution of real ECGs, whereas a zero flatline does not. A zero reference mixes "this patient's T wave is flat" with "a heartbeat exists at all."

We also add an intervention the gradients cannot fake, an interval-preserving morphology swap. We replace a patient's beats with beats from another patient whose PR, QRS and QT intervals and heart rate are matched within tolerance, and measure how far the prediction moves. A large, attribution-predicted shift is direct evidence of information beyond intervals. No shift means an interval model already captures what the deep model uses.

Research Program

We train three architectures of matched size on the CardioLab MIMIC-IV lab-matching protocol (ECG within 60 minutes of the lab draw, patient-level splits). The first is a 1D-ResNet. The second is an S4 model reproducing the CardioLab design. The third is a CNN–bidirectional GRU hybrid in the CRT-Net style, where convolutions summarize each beat and the recurrent layer carries beat-to-beat context. Each has an identical metadata MLP fused late.

The hybrid is included as a lens, not as a performance claim. The rhythm/morphology split is a question about exactly the distinction its two stages are meant to encode. Comparing it with the ResNet and S4 tells us whether attribution conclusions are properties of the physiology or of the architecture. If three equally accurate models point to different waves, that is itself a result, and clinicians should hear it.

Targets are the labs with the strongest reported signal: NTproBNP, hemoglobin, hematocrit, albumin, urea nitrogen and creatinine. We train each with binary abnormality heads for comparability and continuous regression heads, because the file notes binarization discards severity. Attribution runs on the held-out test set with 64-step path integrals. Segment boundaries come from MEETI.

Baselines

The naive reference point is a metadata-only model: the same MLP on demographics and vitals, with no waveform. If the full model's AUROC barely exceeds it for a lab, the waveform share should be near zero. Our decomposition must reproduce that agreement, which serves as a free sanity check. There is no reported result on Lacuna for a metadata-only model on these labs, so we will report it ourselves.

The strongest interpretable competitor is gradient-boosted trees on MEETI's per-beat intervals and amplitudes plus metadata, explained with SHAP. This reproduces CardioLab tabular, whose reported AUROCs are albumin 0.901, hemoglobin 0.881, NTproBNP 0.866. It is the strongest competitor because it is already interpretable in wave terms. The deep model has to beat it on discrimination to justify itself. Our attribution has to say something it cannot, namely a non-trivial share of the prediction outside the interval features. We will run it on identical patient splits with an equal hyperparameter search budget.

The strongest predictive competitor is the S4-plus-MLP model of CardioLab multimodal, with reported AUROC NTproBNP 0.882, hemoglobin 0.870, albumin 0.859. Our models count as competitive if they land within the confidence intervals of these numbers on our reproduced split. We claim no accuracy gain.

Attribution baselines, all computed on the same trained models, are:

  • Grad-CAM on the last convolutional layer.
  • Vanilla input gradients, the Jacobian approach of Gliner et al..
  • Integrated Gradients with a zero reference.
  • Segment occlusion, in which each wave is replaced by the template wave.

Two ablations isolate the proposal's ingredients. The first swaps the factorized template reference for a zero reference while keeping segment aggregation. The second keeps the reference and reports per-sample rather than per-segment maps. The method beats the attribution baselines if it recovers planted signals more accurately and predicts the effect of the swap interventions better (see below).

Why not just…?

Why not just use XGBoost on intervals with SHAP? This is the real threat, and on albumin and hemoglobin the reported numbers favor it. We do not argue it away; the morphology-swap experiment settles it per lab. If interval-matched swaps leave deep predictions unchanged and our beyond-interval share is near zero, the right conclusion is that tabular models suffice for that lab, and we will say so. The proposal's value then lies in identifying which labs genuinely need waveforms.

Why not just occlude segments instead of computing gradients? Occlusion with template replacement is simple and faithful by construction, so we include it as a baseline, not a straw man. Its weakness is that it scores one segment at a time and misses interactions. Its scores also do not add up to the prediction. The planted-signal test will show whether it matches our method. If it does, we will recommend it for its simplicity.

Why not just use a pure convolutional network and Grad-CAM? A pure CNN is already one of our three architectures, since the PTB-XL benchmark reports convolutional ensembles reaching about 0.939 macro AUC on diagnostic statements (Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL). Grad-CAM's resolution is bounded by the final layer's stride, which blurs across the P–QRS–T boundaries we need to separate, as Gliner et al. observed. Its localization is directly measured in the planted-signal test.

Why not a concept bottleneck on intervals? A concept bottleneck forces the model to predict named clinical measurements first and then decide only from them. With intervals as the concepts, it is essentially the tabular baseline with a learned front end. It assumes away the very question we test, whether signal exists beyond intervals.

Proposed Experiments

The first decisive check is planted-signal recovery. On real MIMIC-IV-ECG test signals we synthetically scale T-wave amplitude, widen the P wave, or lengthen RR variability, and define labels that depend only on the planted change. We then train models on these labels. A correct method must place most attribution mass on the planted segment and assign the planted factor to the right share (morphology vs rhythm). We measure this as the fraction of absolute attribution inside the true segment and compare it against every attribution baseline. This test has ground truth, which the real labs lack.

The second is intervention faithfulness on real labs. For each test ECG we rank segments by $A_s$, replace the top-$k$ with template waves, and plot the prediction drop against $k$. This is a deletion curve with in-distribution replacement, echoing XRAI's performance-information curves. We also correlate each ECG's predicted beyond-interval share with the measured prediction shift under interval-matched morphology swaps. A method that is faithful should predict which swaps move the model.

The third is the scientific readout. For each lab and architecture we report the mean decomposition into demographic, rhythm, per-wave and beyond-interval shares, with bootstrap intervals and agreement across the three architectures. We will check the results against expected physiology. For example, NTproBNP should load on QRS and ST-T morphology, reflecting ventricular strain, not only on heart rate. We will also test the shortcut hypothesis from Don't blame Dataset Shift! directly. That paper argues that gradient descent with cross-entropy loss systematically drives shortcut learning. Here, the demographic share should shrink in age- and sex-matched subsets if the waveform signal is real.

There is no reported result on Lacuna for wave-level attribution accuracy on ECG lab-value models. Expert-correlation figures exist only for arrhythmias (0.94 and 0.96 in Gliner et al.).