01 · The questionCan the watch clean its own pulse?
Optical heart rate on the wrist works by shining light into the skin and watching how much comes back. When the arm swings, the sensor shifts against the skin, and the movement can be larger than the pulse itself. The same watch also carries an accelerometer and a gyroscope that measure that movement directly.
This project uses them as a reference: predict the motion part of the PPG from the IMU, then subtract it, keeping the output a real waveform from the recorded PPG, not a set of beat templates.
02 · MethodFive steps, all zero-phase
- RepairNon-finite samples and ADC rails (a value stuck for 0.1 s or more) are bridged on the original time grid.
- Cardiac bandPPG and IMU are band-passed to 0.4–4 Hz with a third-order Butterworth, run forwards and backwards.
- Adaptive noise cancellationIn overlapping 8-second blocks, a ridge-regularised 16-tap FIR model per IMU axis predicts the motion in the PPG. A block's prediction is subtracted only if it holds up on held-out 1-second chunks of the same block.
- Output bandThe result is band-passed to 1.4–4 Hz to remove the remaining low-frequency motion.
- Two-peak correctionA pulse-rate track, with IMU-heavy frequencies down-weighted, finds places where one beat has split into two bumps and smooths the smaller one away.
Zero-phase filtering matters because beats are scored within ±150 ms. A causal filter would delay every peak; here the median peak offset is −12 ms and no constant shift improves F1.
03 · ResultsUp to 2.4× better beat detection
| Mean F1 (±150 ms) | Run | Bike low | Bike high | All dev. |
|---|---|---|---|---|
| Raw PPG | 0.572 | 0.401 | 0.295 | 0.432 |
| This cleaner | 0.666 | 0.643 | 0.706 | 0.610 |
04 · DecisionsWhy it's built this way
- The output band is the biggest single gain. Most motion energy sits below the pulse band; the 1.4–4 Hz band alone takes raw PPG from 0.432 to 0.590 mean F1.
- Cancellation with safeguards. During running the IMU predicts arm motion well, and switching cancellation off costs one running subject 18 F1 points. A held-out check and a PPG–IMU coherence gate stop uncertain fits from being subtracted.
- Insensitive constants. Changing the two-peak limits by ±20% moves pooled F1 by at most 0.0008, and leave-one-subject-out tuning did not beat the defaults.
- Robust inputs. Missing or reordered IMU channels, NaN gaps, flat sensors and ADC rails are all handled, and the output is always finite and the same length as the input.
05 · Run itOne command
# clean one WRIST record, write the cleaned PPG $ pip install -r requirements.txt $ python run_inference.py wrist/1.0.0/s1_walk cleaned_s1_walk.npy # or from Python from run_inference import clean_ppg cleaned = clean_ppg(record.p_signal, record.sig_name, record.fs)