Cardiologists read a 12-lead electrocardiogram (ECG) by territory. They ask whether the inferior leads show ST elevation, whether the lateral leads show it too, and whether a mirror-image depression appears elsewhere. Deep ECG classifiers return one probability per diagnosis and hide how the leads were combined. We propose a classifier whose output is, by construction, a sum of terms. Each term comes from one anatomical lead group or from one pair of groups, and a pair is allowed to contribute only if both of its groups already contribute on their own. Each term is computed by a long-context state space model, a sequence network that reads a signal in time linear in its length. The result is that every diagnosis can be decomposed exactly into "which territories, which territory pairs, and when in the recording," with no post-hoc attribution method in between.
The bet is that this structure costs almost no accuracy and buys explanations that are faithful by definition, stable when the model is retrained on resampled data, and anatomically plausible. A second, smaller question rides along. In ECGs, the high-variance directions of the signal belong to the large QRS spike and to baseline drift, not to the faint P-waves and ST shifts that define many diagnoses. That makes ECG a natural test of whether variance-based compression (principal component analysis, PCA, which keeps the directions along which the data varies most) is safe for diagnostic models. NLP results suggest it is safe there.
Core Claim
On PTB-XL, a model with the following properties will match an unconstrained state space model within about one point of macro AUC on every diagnostic superclass. Its prediction for each diagnostic class is an additive sum over five lead territories and their ten pairwise interactions, with strong heredity gating. Strong heredity means an interaction between two territories is active only if both territories are active alone. Matching accuracy is the claim that fails first. If it holds, the model should also produce territory selections that are markedly more stable across resamples than either a flat, unconstrained-interaction version or post-hoc lead attributions from the unconstrained model. For localized infarction subclasses, its selections should agree with textbook territory assignments. The heredity constraint is the ingredient under test. The additive structure without it, and post-hoc attribution without any structure, are the two foils.
Model
We group the 12 leads into lateral (I, aVL, V5, V6), inferior (II, III, aVF), septal (V1, V2), anterior (V3, V4), and aVR.
Each territory $g$ gets its own encoder $E_g$, a stack of diagonal state space layers. We use the diagonal form because Diagonal State Spaces are as Effective as Structured State Spaces showed it matches the structured version. Each territory pair $(g,h)$ gets a smaller joint encoder $E_{gh}$ that reads both territories' leads. For diagnostic class $c$ the logit is
$$\ell_c(x) = b_c + \sum_{g} z_{c,g}\,\frac{1}{T}\sum_{t=1}^{T} w_{c,g}^\top E_g(x_g)_t + \sum_{g<h} z_{c,g}\, z_{c,h}\, s(\gamma_{c,gh})\,\frac{1}{T}\sum_{t=1}^{T} w_{c,gh}^\top E_{gh}(x_g,x_h)_t .$$
In this equation, $x_g$ is the signal of territory $g$, $T$ is the number of time steps, and $w$ are class-specific linear readouts. The $z_{c,g}\in[0,1]$ are class-specific territory gates and the $\gamma_{c,gh}$ are class-specific pair gates. The function $s$ is the smooth-step relaxation from GRAND-SLAMIN’ Interpretable Additive Modeling with Structural Constraints, which turns a yes/no inclusion decision into a differentiable gate that reaches exact zero. That paper fits additive models to static tabular features and enforces hierarchy with penalties.
We instead enforce strong heredity by multiplying the gates. This product form follows Structured gene-environment interaction analysis, which writes an interaction coefficient as the product of its main effects and an interaction weight. Under it, a pair term vanishes whenever either territory's gate is zero, without any penalty tuning. A sparsity penalty on the $z$ and $s(\gamma)$ pushes each class toward few territories.
Because the readout is a time average followed by a linear map, the contribution of territory $g$ at time $t$ is exactly $z_{c,g} w_{c,g}^\top E_g(x_g)_t / T$. A full territory-by-time contribution map therefore costs one forward pass, linear in recording length.
This is where the design departs from LaTIM: Measuring Latent Token-to-Token Interactions in Mamba Models. LaTIM unrolls the model's recurrence after training to recover token-to-token contributions, which costs quadratic time and needs an approximation of the nonlinearity. Our map is exact, but it answers a coarser question: which territories, at which output times, drove the decision. It does not say which input sample influenced which output. We will state this limitation explicitly.
The model also differs from SSM-CGM: Interpretable State-Space Forecasting Model of Continuous Glucose Monitoring for Personalized Diabetes Management. SSM-CGM scores each input variable with gating networks but has no notion of a constrained interaction.
Research Program
The work has three parts.
The first part is building and training the territory-additive model on PTB-XL (PTB-XL, a large publicly available electrocardiography dataset). PTB-XL has 21,837 ten-second 12-lead records from 18,885 patients and a three-tier hierarchy of 71 statements with 5 superclasses and 24 subclasses. We use its patient-stratified folds.
The second part is measuring what the structure buys. We measure:
- selection stability across resamples, in the sense of Imposing the 'Right' Structural Constraints in High-Dimensional Regression, which found that heredity in sparse regression left test error nearly unchanged while giving the highest selection stability;
- faithfulness, meaning whether removing what the explanation calls important actually changes the prediction;
- anatomical plausibility of each class's selected territories.
The motivation for the stability claim comes from static settings. The Kernel Interaction Trick: Fast Bayesian Discovery of Pairwise Interactions in High Dimensions reports that flat lasso interaction methods picked up dozens of spurious interactions while a heredity-respecting model picked up none. Whether this transfers to learned sequence encoders is exactly what is unknown.
One constraint shapes the design. Bilevel Network Learning via Hierarchically Structured Sparsity depends on predefined groups and degrades when they are wrong. Using anatomical territories with centuries of clinical agreement avoids that weakness. We still test a random regrouping to confirm that the anatomy matters.
The third part is the PCA study, which serves as a measurement lens rather than a component. La RoSA: Enhancing LLM Efficiency via Layerwise Rotated Sparse Activation rotates language-model activations onto their principal components and drops the low-variance 40%. On LLaMA2-7B this costs a 0.17 perplexity gap. Simple and Effective Unsupervised Redundancy Elimination to Compress Dense Vectors for Passage Retrieval compresses retrieval vectors up to 96× with little loss.
ECG suggests the opposite risk. ECGNET: Learning Where to Attend for Detection of Atrial Fibrillation with Deep Visual Attention localizes diagnostic evidence in missing low-amplitude P-waves. We apply variance-ranked truncation in two places: the 12-lead spatial signal, and the state space hidden states, following La RoSA. Our hypothesis is that ST/T-change and conduction classes degrade well before normal-vs-abnormal discrimination does.
The territory model makes the reason visible. We can check whether the territory terms that collapse under truncation are those carrying low-amplitude evidence. This yields a concrete rule for when variance-based compression is unsafe in diagnostic sequence models. The rule is our PCA contribution. We are not proposing PCA as part of the classifier, because a learned first linear layer can absorb any rotation of all components.
Baselines
Do-nothing reference. The do-nothing reference is the unconstrained state space classifier. It uses the same diagonal state space layers and the same total parameter count as the territory model, but takes all 12 leads jointly with a dense input projection. This is the S4-style architecture that S4ECG: Exploring the impact of long-range interactions for arrhythmia prediction and Benchmarking ECG FMs: A Reality Check Across Clinical Tasks show to be strong for ECG. It defines the accuracy ceiling the structure must approach. Both models get the same folds, preprocessing at 100 Hz, augmentation, optimizer, and the same hyperparameter search budget, which we set at 30 trials each, selected on the validation fold.
Strongest reported competitor. The strongest reported PTB-XL result in the file is the convolutional ensemble from Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL, with macro AUC of approximately 0.939 on diagnostic statements. We retrain an XResNet/Inception one-dimensional ensemble on our splits to confirm that number. The file also reports ECG-CPC, a 3.8M-parameter state space model, as dominating 5 of 7 task categories. However, I found no reported result on Lacuna for ECG-CPC macro AUC on PTB-XL diagnostic statements. Where weights are obtainable, we fine-tune it as a further competitor.
What counts as beating the competitors. Beating them on accuracy is not the goal. Success means two things together. First, staying within 0.01 macro AUC of the unconstrained model on each superclass. Second, beating it on selection stability and faithfulness by the margins given below.
Ablations. Two ablations isolate the key ingredient. The first is the same additive model with free interaction gates and a flat sparsity penalty, so interactions may switch on without their territories. The second is a main-effects-only version with no pair terms. A third control replaces anatomical territories with a random partition of equal sizes.
Feature-based reference. For readers who prefer classical glass-box tools, we include a gradient-boosted additive model with pairwise terms on wavelet features as a feature-based reference. The PTB-XL benchmark paper reports that wavelet features plus a neural network lagged significantly behind raw-waveform models, but gives no number for that comparison.
Why not just…?
Why not just explain an unconstrained model post hoc, with relevance propagation aggregated per territory? This is cheaper and keeps full accuracy. The PTB-XL benchmark already used relevance propagation to show models attend to pacemaker spikes. But post-hoc maps carry no guarantee that the model actually depends on the highlighted regions, and nothing stops two retrainings from using different leads. We test this directly. We compute the post-hoc territory ranking for the unconstrained model, delete territories in that order, and compare the resulting drop in prediction confidence with the same deletion in our model, where removing a term is exact. We also compare cross-resample stability. If post-hoc rankings prove equally faithful and stable, the case for the architecture weakens to "same answer, built in." We would report that.
Why not just use the main-effects-only additive model? This is the real threat. If no diagnosis needs territory interactions, heredity has nothing to govern. Clinical reasoning about reciprocal changes predicts that localized myocardial infarction subclasses need pairs, while hypertrophy and conduction disturbances may not. The main-effects ablation settles it per class. If pair terms add nothing anywhere, we drop the heredity claim and report the simpler model as the result.
Why not just allow interactions with ordinary sparsity and skip heredity? In static regression, flat penalties match heredity on accuracy and lose on stability and false interactions, according to Tong and Yuan and the kernel interaction paper. In a sequence model the joint pair encoders might simply absorb the main effects, making heredity cosmetic. The free-gate ablation tests this. We compare how often it selects pair terms whose territories are both off, and how stable its selections are across resamples.
Proposed Experiments
Accuracy. We report macro AUC overall and per superclass and subclass on PTB-XL. We check transfer by training on PTB-XL and evaluating on ICBEB2018, the external set used in the PTB-XL benchmark.
Stability. We retrain every model on ten bootstrap resamples of the training folds. For each class we compute the mean pairwise Jaccard overlap of selected territories and pairs. For the unconstrained model, the selection is the top territories by post-hoc attribution, matched in count. Success is a clear stability gain over both the free-gate ablation and post-hoc attribution, which we set at 0.2 in mean Jaccard.
Plausibility. For the inferior, anterior, and lateral infarction subclasses, we check whether the selected main territory matches the label's territory. We also check whether the selected pairs include the expected reciprocal partner. The random-partition control establishes that agreement is not trivial.
Faithfulness. We run deletion curves and a weight-randomization sanity check on the territory-time contribution maps.
PCA lens. We sweep the number of retained principal components of the 12-lead signal and of the hidden states. For each superclass we report how many components are needed to keep AUC within 0.01, and which territory terms change most. The decisive outcome is whether ST/T and conduction classes need substantially more components than the variance spectrum suggests. If they do, La RoSA-style compression transfers poorly to diagnostic ECG.
Long recordings. As a final check of the linear-cost map, we time territory-time contribution extraction against LaTIM-style unrolling on stitched 20-minute 12-lead sequences. We expect linear versus quadratic growth.
References
- Diagonal State Spaces are as Effective as Structured State Spaces
- GRAND-SLAMIN’ Interpretable Additive Modeling with Structural Constraints
- Structured gene‐environment interaction analysis
- LaTIM: Measuring Latent Token-to-Token Interactions in Mamba Models
- SSM-CGM: Interpretable State-Space Forecasting Model of Continuous Glucose Monitoring for Personalized Diabetes Management
- PTB-XL, a large publicly available electrocardiography dataset
- Imposing the 'Right' Structural Constraints in High-Dimensional Regression
- The Kernel Interaction Trick: Fast Bayesian Discovery of Pairwise Interactions in High Dimensions
- Bilevel Network Learning via Hierarchically Structured Sparsity
- La RoSA: Enhancing LLM Efficiency via Layerwise Rotated Sparse Activation
- Simple and Effective Unsupervised Redundancy Elimination to Compress Dense Vectors for Passage Retrieval
- ECGNET: Learning Where to Attend for Detection of Atrial Fibrillation with Deep Visual Attention
- S4ECG: Exploring the impact of long-range interactions for arrhythmia prediction
- Benchmarking ECG FMs: A Reality Check Across Clinical Tasks
- Deep Learning for ECG Analysis: Benchmarks and Insights from PTB-XL