Interface Counterfactuals: Explaining When a Wearable ECG Decision Comes From the Skin Contact

Soft, skin-conformal electrodes such as dry silver textile shirts, printed graphene strain gauges and elastomer patches let us record the heart and breathing continuously during daily life. They still slip, lift and stretch against moving skin. When they do, the recorded waveform picks up artifacts whose frequencies overlap with the heartbeat features a classifier relies on. The usual remedies are better mechanics in the device and saliency heatmaps for the model. Neither answers the question a clinician actually faces at an alarm: did the patient's heart cause this call, or did the electrode move?

We propose to answer that question directly and to check the answer against ground truth. Many flexible ECG front-ends can measure the electrode–skin interface through the same electrode pair, using impedance pneumography, which injects a tiny current and reads the changing impedance. We use that physical channel to estimate the artifact the interface added to the ECG. The explanation for each decision is then a counterfactual: would the classifier have made the same call if the interface had stayed still? Because real recorded artifacts can be added to clean, annotated ECG, we can build a benchmark in which we know, for each window, whether the model's decision was artifact-driven. That lets us measure whether an explanation is faithful, which is currently the weakest point of clinical XAI, rather than only whether it looks plausible.

Core Claim

An explanation grounded in a measured interface signal identifies artifact-driven decisions of a wearable ECG classifier more reliably than three alternatives: gradient saliency, reconstruction-error quality scores, and blind artifact estimators that never see the interface. The improvement should be largest during non-Gaussian interface events such as electrode lift-off and contact-resistance spikes. Linear adaptive filtering models these poorly, and synthetic Gaussian corruption does not contain them at all.

Concretely, write the recorded ECG window as $x = s + a$, where $s$ is the cardiac signal and $a$ is the interface artifact. We learn an interface model $g$ that predicts $\hat a = g(z, x)$ from the co-recorded impedance signal $z$. For a fixed classifier $f$ that outputs class probabilities, the explanation of a decision is

$$ \rho(x) = d\big(f(x),\, f(x - \hat a)\big), $$

where $d$ is the total-variation distance between the two class-probability vectors. The value $\rho$ is reported together with an ensemble spread over $g$, so the clinician sees both "how much of this call is the contact" and how sure we are of that estimate. The explanation is about the specific model $f$, not about a cleaned signal in general. This keeps the target faithfulness to the model rather than plausibility to a reader.

Research Program

The work has three parts.

The interface model. Adaptive Motion Artifact Reduction in Wearable ECG Measurements Using Impedance Pneumography Signal recorded ECG and impedance through one electrode pair in 20 subjects performing five upper-body motions. It showed that low-passed ECG and impedance correlate above 0.6 for most motions, and that a recursive-least-squares (RLS) adaptive filter, which assumes a slowly varying linear coupling, removes much of the artifact. That paper supplies our method's premise and our main competitor. We train $g$ on the same kind of data as a small causal temporal convolutional network. Its training target is the residual left after subtracting beat-synchronous averaged templates from motion segments. The network is allowed to be nonlinear and to switch regimes. Our hypothesis is that this flexibility matters exactly at lift-off and re-contact, where coupling is not linear. If it does not matter, the RLS version of $\rho$ is the result, and the benchmark still stands.

The faithfulness benchmark. Clean annotated beats come from the MIT-BIH Arrhythmia Database, using the inter-patient DS1/DS2 split. We pair them with real artifact waveforms extracted from the ECG–impedance recordings, transplanting each artifact together with its own impedance trace. For any classifier, a window is labeled artifact-driven when $f$'s decision on the corrupted window differs from its decision on the clean original. This is model-specific ground truth that saliency methods have never been scored against. Artifact amplitude is swept so that results can be reported as curves rather than single points. We also hold out entire motion types to test whether $g$ generalizes beyond the movements it was trained on.

A real-hardware check. We will make a modest new recording that replicates the impedance-plus-ECG acquisition of the RLS paper on dry textile electrodes like those in Comprehensive Signal Quality Evaluation of a Wearable Textile ECG Garment: A Sex-Balanced Study. We will record simultaneously against a clinical Holter, with a sex-balanced cohort, during sitting, walking, running and cycling. The Holter-versus-textile disagreement of $f$ gives real-world ground truth for artifact-driven decisions. The Oppelt study also showed that much apparent degradation in female wearers comes from static electrode displacement rather than transduction failure. We therefore report all results by sex and keep static geometric displacement separate from dynamic contact artifact. Our method targets only the dynamic part, and the evaluation must not credit it for the static part.

Baselines

All explanation methods are evaluated on the same classifier, data, artifact transplants and splits. Every learned component, including the gating autoencoders and our $g$, gets the same hyperparameter-search budget on a validation split drawn from DS1 subjects and training motions only.

The classifier itself is a residual attention CNN in the style of Interpatient ECG Arrhythmia Detection by Residual Attention CNN. That model applies attention blocks to wavelet images of beats and reports 98.5% accuracy, F1 of 82.8% for supraventricular ectopic beats and F1 of 91.7% for ventricular ectopic beats on clean inter-patient MIT-BIH. We first reproduce those clean numbers. Beyond that, the classifier is held fixed, because we are explaining it, not replacing it.

The naive reference point is the classifier's own confidence, $1 - \max f(x)$, used as an "is this call trustworthy" score. If confidence already flags artifact-driven calls, no explanation machinery is needed.

The gradient baseline is SmoothGrad, as used on strain signals in A deep learning–enabled smart garment for accurate and versatile monitoring of sleep conditions in daily life. Its score is the fraction of attribution mass falling outside the QRS and T-wave intervals of the clean template, which is a generous version of what a reader would do with a heatmap.

The quality-score baseline is the strongest existing method for "is this sensor input corrupted." Multimodal Sleep Apnea Detection with Missing or Noisy Modalities trains a Transformer autoencoder per channel and uses its reconstruction error to down-weight bad channels. It reports AUROC of about 0.93 on clean pediatric polysomnography and above 0.88 at 10 dB SNR, but only for apnea detection under synthetic Gaussian noise on rigid sensors. We train an ECG autoencoder of matched size on clean DS1 beats and use its reconstruction error as the explanation score. The rule-based alternative follows Weakly Supervised Classification of Vital Sign Alerts as Real or Artifact, which labeled ICU alarms as real or artifact with labeling functions and reached AUC 0.951 for respiratory rate and 0.940 for SpO2. We write impedance-amplitude and impedance-slope labeling functions and train its downstream random forest on them.

The physics-linear competitor is $\rho$ computed with an RLS estimate of $\hat a$ in place of $g$. Adaptive Motion Artifact Reduction in Wearable ECG Measurements Using Impedance Pneumography Signal reports this filter's denoising fit as mean squared error consistently below 0.15 and $R^2$ above 0.7. For the specific task of detecting artifact-driven decisions, we found no reported result on Lacuna for any method, so the benchmark itself is new. Two ablations isolate the key ingredient, which is the measured interface channel. The first replaces $g$ with an equally sized network that estimates $\hat a$ from the ECG alone. The second feeds $g$ an impedance trace shifted by several seconds. Beating the field means a higher AUROC for detecting artifact-driven decisions than every baseline at matched artifact amplitude, with confidence intervals from a subject-level bootstrap. It also means a statistically clear margin over the RLS version specifically on held-out lift-off segments.

Why not just…?

Why not just use an interpretable model on heart-rate-variability features? Shallow models do well on coarse tasks; a decision tree reached 93.3% intra-subject stress accuracy in Wearable Flexible Electronics Based Cardiac Electrode for Researcher Mental Stress Detection System Using Machine Learning Models on Single Lead Electrocardiogram Signal. However, their features come from detected R-peaks, and motion artifacts corrupt those detections upstream without leaving any trace in the tree. A transparent tree on corrupted features is transparent about the wrong thing. We include a heart-rate-variability tree in the textile study to show this directly. For the tree, $\rho$ should flag the windows where R-peak hit rate falls below the Holter's, which Oppelt reports as roughly 0.95 for textile versus 0.96–0.97 for Holter overall.

Why not just filter with RLS and classify the cleaned signal? This is the real threat. If the residual artifact after RLS rarely flips decisions, our nonlinear $g$ adds little, and the RLS counterfactual is the practical answer. The experiments settle this by stratifying windows into steady motion and lift-off/re-contact events. We expect parity on the first and an advantage only on the second. We will report parity honestly if that is what we find. Filtering alone also does not tell the clinician which decisions changed. The counterfactual score is still needed even when RLS supplies $\hat a$.

Why not just use reconstruction-error gating? A large reconstruction error says the input looks unusual. It does not say whether the unusual part moved this decision, and true arrhythmias are themselves unusual beats. We therefore expect gating to confuse ectopic beats with artifact, with the ventricular class most at risk. The benchmark measures this directly through the false-flag rate on clean ectopic beats.

Decisive Checks

On the semi-synthetic benchmark, the claim fails in either of two cases: interface-grounded $\rho$ does not beat the reconstruction-error and SmoothGrad scores in AUROC for artifact-driven decisions, or the shuffled-impedance ablation performs as well as the real one. The second outcome would mean the model is exploiting ECG shape, not the interface. On the textile-plus-Holter recordings, the operational test is alarm triage. At fixed sensitivity for Holter-confirmed arrhythmic beats, we measure what fraction of textile-only false calls $\rho$ suppresses, reported separately by sex and by activity. A final check guards against $f(x - \hat a)$ simply being out of distribution. On clean windows with no added artifact, $\rho$ must stay near zero, and its ensemble spread must grow when $g$ is applied to motion types it never saw.