When2What: A Timing-Conditioned Framework for Long-Horizon Forecasting of Continuous Cardiovascular Waveforms

Chaoqi Zhang, Shujie Yan, Zhao Zhang, Yanhua Sun, Yu Wang, Li Li, Lingzhong Meng, Xiaoyi Chen, Haixu TangarXiv 2026 · arXiv

TL;DR

When2What is a novel framework for long-horizon forecasting of cardiovascular waveforms (like ECG and blood pressure) that solves the "flatline" problem of standard deep learning models. By decoupling the prediction of when a heartbeat occurs from what its shape looks like, the model preserves sharp, clinically essential features even when exact timing is uncertain.

What Problem Does This Paper Address?

Forecasting cardiovascular signals—such as the electrocardiogram (ECG), arterial blood pressure (ABP), or photoplethysmogram (PPG)—over long horizons (e.g., 60 seconds) is notoriously difficult. These signals are "quasi-periodic," meaning they repeat but with slight, stochastic variations in heart rate.

Standard time-series models (like Transformers or LSTMs) are typically trained to minimize Mean Squared Error (MSE). When faced with uncertainty about exactly when a future heartbeat will occur, an MSE-optimized model does the mathematically "safe" thing: it outputs the average of all possible future paths. Because these paths contain heartbeats that are slightly shifted in time, averaging them results in a featureless, flat baseline. For a clinician, this is useless; the sharp R-peaks and pulse upstrokes that indicate heart health are completely erased.

Methods

The authors introduce a three-stage "Predict, Commit, and Generate" pipeline called When2What:

  1. Predict (P): A shared Mamba-Attention backbone processes 120 seconds of history to estimate a dense "timing map"—a probability distribution of where future beats are likely to occur.
  2. Commit (C): This is the "bottleneck" stage. Instead of passing a blurry probability map to the next step, the model selects discrete beat events (local maxima) and sharpens them into unit-height Gaussian impulses. This forces the model to "commit" to a specific heart rate schedule.
  3. Generate (G): A neural waveform generator takes these committed timing "anchors" and the historical signal to synthesize a continuous 60-second forecast.
The When2What framework decouples timing prediction from waveform generation.

To ensure the generator learns to produce sharp shapes rather than averages, it is trained using teacher forcing, where it receives ground-truth timing during training but must rely on predicted timing during inference.

Datasets

The study primarily utilizes VitalDB, a large-scale dataset of intraoperative physiological recordings (ECG, ABP, and PPG). To test the model's robustness, the authors evaluated it on several external datasets:

  • MOVER: Intraoperative ECG from a different medical center.
  • SHDB-AF: Ambulatory Holter ECG recordings from patients with atrial fibrillation.
  • NSRDB & LTAFDB: Used for analyzing beat-time predictability across different physiological states.

Key Insights and Ideas

  • Temporal Asymmetry: The authors discovered a fundamental "asymmetry" in cardiovascular signals. While our ability to predict exactly when a beat will happen (timing) decays within seconds due to heart rate variability, the shape of the beat (morphology) remains remarkably stable for several minutes.
  • The MSE Trap: The paper highlights that for quasi-periodic signals, low MSE is a misleading metric. Preserving sharp, realistic heartbeats actually increases MSE if the timing is off by even a few milliseconds. This establishes a mathematical trade-off between "pointwise accuracy" and "structural integrity."
  • Decoupling is Key: By separating "When" from "What," the model can use the stable historical morphology to fill in the gaps once a timing schedule is decided, preventing the collapse into flat lines seen in "Direct" regression models.
Analysis shows that while timing predictability (a) drops quickly, beat shape (b) remains highly consistent over long periods.

Key Results

  • Superior Beat Preservation: On 60-second ECG forecasts, When2What achieved a near-term waveform event skill of 0.644, whereas standard models like Informer or PatchTST collapsed into flat baselines (negative skill).
  • High Fidelity: The model reproduced 95.62% of its predicted heartbeats in the final generated waveform, compared to only ~72% for a multi-task model that didn't use explicit timing conditioning.
  • Zero-Shot Generalization: The framework transferred effectively to external hospital cohorts and different signal types (ABP and PPG) without retraining, proving that the "Predict-Commit-Generate" paradigm is robust across physiological domains.
Visual comparison showing how Direct models flatten the signal while When2What preserves sharp R-peaks.

Limitations and Future Work

The current version of When2What is deterministic—it commits to a single "best guess" beat schedule. However, because heart rate is inherently stochastic, there are many plausible futures. The authors suggest that a promising next step is integrating this framework with probabilistic generative models (like Diffusion or VAEs) to sample multiple potential heartbeat schedules and provide clinicians with calibrated uncertainty intervals. Additionally, while the model handles single channels well, extending it to multi-modal forecasting (e.g., predicting ECG and ABP simultaneously) remains an open challenge.

Summary updated

Abstract

Long-horizon forecasting of quasi-periodic cardiovascular waveforms, such as the electrocardiogram (ECG), arterial blood pressure (ABP), and photoplethysmogram (PPG), requires predicting both when future cardiac events will occur (beat timing) and what the local structural pattern looks like around each event (beat morphology). However, standard sequence forecasters trained with pointwise mean squared error (MSE) average across uncertain future heartbeat phases, flattening sharp R peaks and pulse upstrokes into featureless baselines. Our analysis of intraoperative ECG reveals a clear temporal asymmetry: beat-time predictability from history decays within seconds due to stochastic heart-rate variability, whereas local beat morphology aligned at true beat times remains stable over several minutes. Guided by this insight, we introduce When2What, a timing-conditioned framework comprising three stages: Predict, Commit, and Generate. Given a 120-s history, When2What predicts a dense 60-s timing map, selects and sharpens discrete beat events into unit-height Gaussian impulses, and conditions a neural waveform generator on both these committed events and the observed history. Across intraoperative ECG, When2What substantially outperforms existing time-series and physiological forecasters, achieving a near-term waveform event skill of 0.644 and reproducing 95.62% of its predicted heartbeats in the generated waveform where direct long-horizon forecasters collapse into flat baselines. Furthermore, When2What transfers zero-shot to external hospital and atrial fibrillation cohorts, extends effectively to ABP and PPG pulse waveforms, and is supported by ablations and synthetic analyses that establish explicit timing conditioning as an effective paradigm for quasi-periodic long-horizon waveform forecasting.
BibTeX
@misc{zhang2026when,
  author = {Chaoqi Zhang and Shujie Yan and Zhao Zhang and Yanhua Sun and Yu Wang and Li Li and Lingzhong Meng and Xiaoyi Chen and Haixu Tang},
  title = {{When2What: A Timing-Conditioned Framework for Long-Horizon Forecasting of Continuous Cardiovascular Waveforms}},
  year = {2026},
  eprint = {2611.08993},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.08993},
}
Figure