Sign In Join Early Access
Back to Blog
Engineering

How LSTM Models Handle Irregular Physiological Signals

How LSTM Models Handle Irregular Physiological Signals

When you design an LSTM model in a notebook using a clean, regularly sampled time series, the mechanics feel straightforward. Each time step feeds one feature vector into the recurrent cell, the hidden state propagates, and you get a sequence output. Real wearable physiological data does not cooperate with that abstraction. Users remove their device before showering, charge it overnight but put it back on at irregular times, and experience periods of elevated motion that make temperature and HRV readings unreliable. The resulting time series has gaps, artifacts, variable effective sampling rates, and segments of missing data that are not randomly distributed. This post describes the specific irregularity problems we encountered and what we do about each of them.

Types of Irregularity in Wrist Sensor Data

It is worth separating the sources of irregularity because they require different handling strategies.

Device removal gaps are the most common. When the sensor is not on the wrist, no readings are recorded. These gaps can range from 20 minutes (washing dishes) to 8 hours (forgotten on the nightstand). The gap duration matters: a 20-minute gap has minimal impact on the cycle-level signal; a 10-hour gap spanning the overnight temperature trough is a material loss of the most informative window in the daily cycle.

Motion artifacts are different from gaps. The sensor continues to record but the readings are corrupted. High skin temperature from vigorous exercise or inaccurate HRV measurements from wrist movement during a run produce values that are not missing but are also not physiologically meaningful for cycle phase inference. Feeding corrupted values into an LSTM as if they were clean causes more harm than omitting them.

Variable sampling intervals appear when devices switch between high-frequency and low-frequency recording modes to manage battery life, or when firmware drops samples under computational load. Our processing pipeline standardizes to a target resolution, but the source data often has small jitter in sample timing that accumulates over long recording periods.

Finally, there is structured missingness: the gap patterns are not random. People tend to remove devices during exercise, during medical procedures, and when traveling. These are exactly the periods with potentially informative physiological events. A naive missing-at-random assumption is wrong here.

Artifact Detection Before the Model Sees Anything

Our approach is to remove artifactual segments before they reach the LSTM, rather than relying on the model to learn to ignore them. We apply a pre-processing step that flags temperature samples deviating more than a threshold from the rolling 60-minute moving average, contingent on co-occurring accelerometer data indicating high-intensity motion. Flagged samples are marked as missing rather than treated as valid measurements.

HRV readings receive a different treatment because HRV quality can be assessed from the inter-beat interval (IBI) sequence itself. Short IBIs that violate physiological plausibility bounds, sequences with coefficient of variation outside expected nocturnal ranges, and segments with fewer than five valid IBI pairs in a 5-minute window are all removed before the HRV-derived features enter the pipeline. The HRV channel sees significantly more missing data than temperature after this filtering, which was expected: wrist PPG for HRV is inherently noisier than wrist thermistor for temperature.

Handling Gaps in the LSTM Input Sequence

LSTM cells carry hidden state forward from one time step to the next. When there is a gap in the input sequence, there is a decision to make: interpolate and pretend the gap did not exist, mask the missing steps, or reset the hidden state. We use different strategies for different gap durations.

For gaps shorter than 90 minutes, we forward-fill the last valid temperature value and mark the filled segment with a binary missingness indicator feature appended to the input vector. The LSTM sees the carried-forward value plus a flag indicating it is an imputed reading. This allows the recurrent dynamics to continue across the gap while giving the model information that the recent inputs are not fresh observations. The 90-minute threshold is based on the typical thermal time constant of the wrist: beyond this duration, the carried-forward value has decayed enough from the true temperature that linear imputation would introduce meaningful error.

For gaps longer than 90 minutes but shorter than 6 hours, we use a gap token: a distinct feature vector that the model was trained to recognize as a contiguous missing block. The gap token does not carry forward a temperature value; instead it signals a structural discontinuity. The LSTM updates its hidden state on the gap token but with learned weights that reduce the influence of the pre-gap state on the post-gap prediction.

For gaps longer than 6 hours, we treat the sequences on either side as separate segments and reset the hidden state. Attempting to propagate state across a 10-hour gap introduces more error than starting fresh on the post-gap segment, because the cellular hidden state represents a recency-weighted memory of recent input patterns, and inputs more than 6 hours ago carry minimal weight in our learned models anyway.

Training on Irregular Data Rather Than Clean Data

One approach to gap handling is to train on clean data and add gap-handling as a post-processing step. We found this works poorly in practice. A model trained entirely on complete overnight temperature sequences learns representations that assume continuity. When that model encounters a gap-token or a forward-filled segment at inference time, the hidden state update dynamics are poorly suited to handling the missingness structure, because the model never had to learn them.

Our current training pipeline synthetically introduces gaps and artifacts into otherwise-complete sequences during training, at rates and duration distributions calibrated to the gap statistics we see in real collection data. The model learns during training that it must handle missing tokens and forward-filled imputed values as routine input conditions, not exceptions. This substantially improved held-out performance on sequences with realistic gap rates compared to the clean-trained baseline.

We also augment training data with different gap locations relative to the phase transitions, because a gap that falls during the peri-ovulatory window has very different implications for prediction quality than a gap that falls mid-luteal phase. Random gap placement during augmentation produces a model that sees gaps as phase-agnostic; deliberately placing some training gaps at phase-transition periods produces a model that learns to propagate additional uncertainty during those critical windows.

Per-Sequence Coverage Gating

Handling gaps gracefully within the model does not eliminate the need for coverage thresholds. There is a data density below which the model's outputs are unreliable regardless of how sophisticated the imputation and gap-handling logic is. For overnight temperature segments, our current gate requires at least 70 percent data density across the sleep window (defined as inferred sleep onset to offset from the accelerometer channel). Sequences falling below this threshold are excluded from overnight feature extraction and the model processes only the available sub-segments, with explicit uncertainty inflation in the output layer.

We surface coverage quality to users in the UI as a data quality indicator on each overnight session. A user who sees three consecutive nights flagged as low coverage during what should be the peri-ovulatory window has actionable information: wearing the device more consistently during this window would improve the ovulation inference. Hiding coverage failures and silently degrading prediction quality would remove that feedback loop.

The Imperfect Middle Ground

The strategies described above manage the irregularity problem; they do not eliminate it. A model handling 30 percent gap rates with sophisticated imputation is doing more guessing than a model handling 5 percent gap rates with the same method. We do not claim equivalent prediction quality across all wear compliance levels. What we do claim is that the model communicates its confidence honestly, inflating uncertainty estimates when it is working from degraded coverage, and that the inference pipeline does not silently produce confident-seeming outputs from low-quality input windows.

The longer-term approach is to design for wear compliance during the highest-signal collection windows rather than relying on post-hoc gap handling. That is a product problem as much as a modeling problem. Data quality feedback, notification design around the peri-ovulatory period, and device form factors that make overnight wear more natural all reduce the gap rate before it reaches the model. We are doing both in parallel: improving the model's robustness to gaps and reducing the gaps through product design. The modeling work described here handles the residual irregularity that persists even with good wear habits.