Three bad beats make an old heart look young

Heart rate variability is read from the gaps between single heartbeats, and three wrong beats in three hundred can turn a 77-year-old's heart into a 23-year-old's. pulse puts every beat of an ECG or RR file in front of you, on paper, so you can see what the number is made of.

Published
21 November 2026
Reads
An RR file or a single-lead ECG, in your browser
Examples
Two women at rest, aged 23 and 77 (PhysioNet)
Method
Systole's HRV, sleepecg's beat detector
Download
190 KB, plus 2 MB of recordings
Open pulse Source code on GitHub Based on systole on GitHub
Contents
  1. Her breathing, written in her heartbeat
  2. When the clean-up makes it worse
  3. Checking it against systole and sleepecg
  4. Limits
  5. Data and licences
  6. Further reading

A woman of 77 lies still for five minutes with an ECG on. Her RMSSD, the figure a chest strap or a sleep tracker would report as heart rate variability, is 15.7 ms. Remove one beat, add one that isn’t there and nudge a third a little early, out of roughly three hundred, and it reads 98.1 ms. A woman of 23 in the same study, healthy and breathing slowly, scores 96.3.

Nothing about her heart changed. HRV is computed from the gaps between individual beats, and a missed or invented beat makes one gap enormous and its neighbour tiny. A loose strap does exactly this. pulse opens on her recording drawn on ECG paper, with a button that damages the three beats, so you can watch it happen.

Her breathing, written in her heartbeat

Both recordings come from the Fantasia study on PhysioNet. Volunteers lay quietly watching a film, with an ECG and a belt round the chest that tracks breathing. pulse draws the belt above the ECG on the same strip.

On the 23-year-old’s strip the beats bunch up with each breath in and spread out with each breath out. Breathing in briefly releases the vagus nerve’s brake on the heart; breathing out puts it back. The spectrum of her beat-to-beat intervals has its tallest peak at 0.316 Hz. The belt, analysed separately, peaks at 0.317 Hz: 19 breaths a minute. The heart-rate calculation never sees the belt, yet it finds her breathing to within a thousandth of a hertz.

The 77-year-old breathes at 0.250 Hz, 15 times a minute, and her heart rate follows at 0.250 Hz too, but faintly. Her high-frequency power is 52 ms² against the young woman’s 4,061. On the Poincaré plot, each interval against the next, the young heart makes a broad cloud (68.0 ms across the diagonal) and the old one a thin streak along it (11.0 ms). Her heart rate still wanders slowly, but from one beat to the next it hardly changes.

When the clean-up makes it worse

The usual defence against bad beats is automatic artefact correction. pulse runs the Lipponen–Tarvainen method as systole implements it, and shows its numbers in their own column beside the raw beats and yours.

On the damaged older heart it does its job. RMSSD comes back to 14.1 ms and the spectral peak returns to her breathing rate.

On the younger woman it goes wrong. The same three bad beats lift her RMSSD from 96.3 to 131.9 ms; correction overshoots to 82.8 and drags her high-frequency peak from 0.316 to 0.160 Hz, nowhere near her breathing. Run it on her clean beats, which match PhysioNet’s hand-checked annotations one for one, and it still flags six intervals, splits two of them in half and lowers her RMSSD by 16%. Her breathing swings her heart rate so far that the corrector mistakes health for error.

The beat detector matters as much. sleepecg’s detector, the one pulse uses, finds every annotated beat on both recordings. A textbook Pan–Tompkins detector, run on the older woman’s ECG, finds 295 beats where there are 289, missing some and inventing more, and reports an RMSSD of 84.1 ms.

This is why pulse keeps a person in the loop. Click a stray point on the Poincaré plot and the strip jumps to that beat, where you can reject it or add the one that was missed. Your checked beats sit beside the raw and auto-corrected ones, and automatic correction never touches them. Then drop in your own RR export from a strap or an ECG CSV; it is read in the page and never uploaded.

Checking it against systole and sleepecg

The engine is about 1,400 lines of Rust in a 188 KB WebAssembly file. It follows systole 0.3.5 for the metrics, the spectrum and the artefact correction, and sleepecg 0.6.0 for finding R peaks. On five reference series, systole’s example file, the two Fantasia excerpts and two windows from the nsr2db long-term database, every time-domain, Poincaré and band-power value agrees with systole to better than one part in a million. The spectra agree bin by bin, the artefact flags are identical, and the detector returns exactly sleepecg’s beats.

One difference is deliberate. systole nudges each detected beat to the highest ECG sample within 0.1 s, and crashes when a beat falls that close to the start of a recording, as one does in the young woman’s excerpt. pulse clamps the search to the recording.

Kubios HRV, the most widely used desktop program, gives slightly different frequency-domain numbers. On systole’s example file it agrees on RMSSD to 0.002 ms and on SD1 and SD2 to within 0.3%, but differs by 2–11% on band power because it interpolates the intervals differently. pulse shows the Kubios values in their own column and follows systole.

Limits

pulse is for learning what HRV is made of, not for medicine: no diagnosis, no readiness score. It analyses five minutes at a time, longer files get a window picker, and it greys out very-low-frequency power, which five minutes cannot measure. It does not read optical (PPG) data from wrist sensors, whose beat times are less precise than an ECG’s.

Data and licences

Further reading