Context as a Prior: Using Fragmented Patient Records to Set Event Rates in Sparse Physiological Event Detection

Detectors for rare events in physiological signals, such as an arrhythmia that fills 0.03% of an electrocardiogram (ECG) recording or a true ventricular tachycardia alarm hidden among mostly false ones, are trained almost entirely on the waveform. Everything else known about the patient is left out: hospital, monitor vendor, labs, diagnoses, notes. These facts are scattered across systems that rarely line up. The obvious repair is to feed this context into the detector as extra features. The evidence says that repair is unreliable. When a study stacked an ECG model with an electronic health record (EHR) model to detect pulmonary embolism, the combined model scored worse than the EHR model alone (A Comparative Analysis of Electronic Health Record and Electrocardiogram Waveform Data for Pulmonary Embolism Identification in Critically Ill Patients).

This note proposes a narrower and testable alternative. Much of what fragmented context tells a sparse-event detector is not what the event looks like but how often events happen for this patient or site. Context should therefore enter the model as a learned prior on the event rate: a per-patient or per-site offset added to the detector's log-odds. It should not enter as additional input features. This framing also repairs a quiet problem with how sparse detectors are trained. The balanced 50/50 sampling those detectors depend on deliberately distorts the base rate. The same prior term can undo that distortion in a principled way when the model is deployed.

Core Claim

Write $f(x_t)$ for the waveform detector's score at time $t$, $c$ for whatever fragment of context exists for that patient (site, vendor, available channels, labs, comorbidities), $\pi(c)$ for the event rate the context implies, and $\pi_s$ for the positive fraction the training sampler enforces. The proposed prediction is:

$$\text{logit}\, p(y_t = 1 \mid x, c) = f(x_t) + \log\frac{\pi(c)}{1-\pi(c)} - \log\frac{\pi_s}{1-\pi_s}$$

This form follows from Bayes' rule under one assumption: the waveform's appearance given the label does not depend on context. Under that assumption, $f$ learns a likelihood ratio and context only shifts the prior. The middle term is a small learned network over context, built to accept partial records. The last term removes the artificial prevalence set by the balanced sampler.

The claim makes three falsifiable predictions. First, on cohorts whose event rates differ, the prior term should improve calibration and alarm-budget metrics more than feature fusion does. Second, it should never make results worse in the way stacking did. Third, an explicit interaction term, in which context can also change $f$, should add little unless the waveform's appearance genuinely varies across contexts.

One property must be stated up front because it limits where gains can appear. An additive offset cannot change the ranking of time points within one patient. Any gain must show up in pooled ranking across patients and sites, in calibration, and in precision at a fixed alarm rate. These are exactly the quantities that matter for alarm fatigue and for cross-cohort transfer.

Relation to Prior Work

Three papers motivate the gap. Each attacks one side.

That cross-cohort drop, together with the pulmonary embolism fusion failure, is the contradiction this proposal tries to explain. A plausible reconciliation is that context helps when it carries rate information the detector lacks, and hurts when it is simply concatenated as redundant features.

The method borrows from the sparse-detection literature:

The proposal's specific observation is that both tools change the effective training prevalence. Neither paper corrects for this at deployment.

On the fragmentation side, SEA CDM: Study-Experiment-Assay Common Data Model and Databases for Cross-Domain Data Integration and Analysis supplies the idea of mapping heterogeneous records into shared subject, sample and assay entities. We use only its lesson that context arrives incomplete and must be encoded in a way that tolerates missing parts. We do not build a harmonized database.

VTaC: A Benchmark Dataset of Ventricular Tachycardia Alarms from ICU Monitors constrains the design in two ways. It shows that generative normal-modeling fails on imbalanced alarm data, so we stay discriminative. Its multi-hospital, multi-vendor construction gives a natural setting where base rates differ by site.

Research Program

The work has three parts.

Build the prior-offset model. A waveform branch provides $f$. We use the fully convolutional network that tops VTaC, and the adaptive-gate detector on continuous ECG. A context encoder outputs $\pi(c)$ and handles missing fields with learned "absent" embeddings. The two are trained jointly with balanced sampling, with the $\pi_s$ correction applied in the loss. This keeps $f$ interpretable as a likelihood ratio.

Derive a diagnostic for when context should be additive. We fit the additive model and a version with a context-dependent interaction in $f$. The held-out gap between them estimates how much context changes event appearance rather than event rate. This is the quantity we propose explains why fusion sometimes fails.

Run a controlled synthetic study. On MIT-BIH we subsample events per record to create known, context-dependent prevalence shifts. We then confirm that the prior term recovers them and that feature concatenation does not. This separates the mechanism from the noise of real clinical data.

Baselines

The do-nothing reference is the waveform-only detector with balanced sampling and no prevalence correction. On VTaC this is the fully convolutional network, which VTaC reports at a Challenge Score of 80.08 and AUC of 0.949 in the real-time setting, against 67.32 for the 2015 rule-based algorithms. This is the strongest existing waveform result on our main benchmark.

On continuous ECG the strongest existing method is the adaptive-gate detector, which Enhancing Sparse Event Detection reports at an AF-F1 of 67.26 on the 0.03% PAT&NOD class of SHDB-AF. On the pulmonary embolism cohort the reference numbers from the MIMIC-IV comparison are:

  • EHR model AUROC 0.71 (95% CI 0.68–0.74);
  • waveform model AUROC 0.67;
  • stacked fusion AUROC 0.67.

We re-run every baseline ourselves with identical splits, the same waveform backbone, the same compute and the same hyperparameter search budget. On VTaC we report leave-one-hospital-out splits as well as the standard split. The fusion baselines are:

  • stacking, the published failure;
  • early concatenation of context features into the detector;
  • a FiLM-style variant in which context rescales the waveform features, representing "full interaction."

The key ablation removes the learned $\pi(c)$ but keeps the $\pi_s$ correction. This isolates the value of context-specific rates from the value of merely undoing balanced sampling.

What counts as beating the baselines:

  • On pulmonary embolism: an AUROC whose confidence interval clears the 0.71 EHR-only model, while never falling below either single modality.
  • On VTaC: a higher Challenge Score than 80.08 under leave-one-hospital-out evaluation.
  • Everywhere: lower calibration error and higher precision at a fixed sensitivity.

Why not just…?

Why not just concatenate the EHR features into the detector? This is the obvious idea. The closest published test, stacking EHR and ECG models, fell to 0.67 against 0.71 for EHR alone (PE comparison). Concatenation also gives a high-capacity network room to overfit site-specific shortcuts, which is a likely contributor to the cross-cohort drop in the postoperative study. We include concatenation and the FiLM-style variant as baselines. If either beats the additive prior under leave-one-site-out evaluation, the "context is mostly rate" claim is wrong, and we will report that.

Why not just train a separate EHR risk model and shift each patient's threshold afterward? This is the most serious threat. It is the same equation fitted in two stages instead of jointly. It may well match the joint model, and if it does, that is a useful and simpler result. The proposal's distinctive claim then shrinks to the $\pi_s$ correction and the diagnostic. Joint training could still help because the waveform branch learns a likelihood ratio rather than absorbing context-correlated rates. The two-stage version is run as a direct baseline under the same budget to settle this.

Why not just recalibrate per site, or fine-tune on each new hospital? Per-site recalibration needs labeled events from the new site. At a 0.03% event rate those labels are scarce, which is the fragmentation problem itself. Per-site recalibration also cannot use patient-level context. The leave-one-hospital-out protocol directly compares zero-label transfer with the prior model against recalibration using small labeled budgets from the held-out site.

Why not just use gradient-boosted trees on hand-crafted features? On static snapshots this is competitive: trees on ECG features matched deep fusion on pulmonary embolism. On continuous alarm data, deep convolutional models beat rule-based and simple models by a wide margin on VTaC (80.08 versus 67.32). The prior offset is model-agnostic, so we also attach it to the tree baseline on the pulmonary embolism cohort. This tests the mechanism independently of the backbone.

Proposed Experiments

VTaC, leave-one-hospital-out. The decisive experiment uses hospital, vendor and available-channel indicators as context, assuming the release exposes site identifiers. If it does not, we fall back to channel availability and per-record alarm statistics. Success means pooled precision at fixed sensitivity and the Challenge Score improve over the waveform-only network. The improvement should come mostly from the prior term, with the interaction term adding little.

MIMIC-IV pulmonary embolism cohort. We test whether the prior formulation turns the published fusion loss into a gain over EHR alone. With one snapshot per admission, pooled ranking is the entire metric, so this is where an additive offset should matter most.

SHDB-AF and MIT-BIH with controlled prevalence shifts. These check that the method does not degrade per-event detection relative to the reported 67.26 AF-F1 when context is uninformative. They also check that the method recovers injected rate shifts that concatenation misses.

Calibration check across all three settings. We report calibration error before and after the $\pi_s$ correction. If the correction alone accounts for most of the gains, the honest conclusion is narrower: balanced-sampling detectors should be prior-corrected at deployment. That is still worth reporting.