Part VII: Health, Biosignals, and Wearable AI
Chapter 30: PPG and Wearable Cardiovascular Sensing

AFib screening on consumer wearables (Apple/Fitbit heart studies)

"We shipped a heart monitor to half a million wrists in a weekend. The hard part was not the algorithm; it was mailing back the ECG patches."

A Logistically Humbled AI Agent

Prerequisites

This section assumes the optical pulse waveform of Section 30.1: you should know that a wrist PPG measures blood-volume pulses from reflected green light, and that its timing, not its exact shape, carries the rhythm information. It reuses the rare-event and base-rate arithmetic developed for clinical ECG in Section 29.2 and the Bayes-rule reasoning of Chapter 4. Motion artifact and signal-quality gating, which decide when a wrist trace is even worth scoring, are treated in depth in Section 30.6; here we take clean windows as given and focus on the screening system built around them.

The Big Picture

An electrocardiogram is the gold standard for detecting atrial fibrillation, but you have to be wearing one at the exact moment the arrhythmia strikes, and AFib is famously intermittent. The consumer wearable flips the constraint: the sensor is already on the wrist, all day and all night, for years. Trade the clean ECG for a noisy optical pulse and you gain something no clinic can offer, which is continuous, opportunistic, population-scale observation. The two landmark demonstrations, the Apple Heart Study and the Fitbit Heart Study, each enrolled more than 400,000 people entirely through an app, with no clinic visit, and turned the wristband into the widest cardiac net ever cast. This section is about how a green LED and a photodiode become a regulated screening instrument: what the algorithm actually measures, how the studies were designed to confirm its flags, and why the answer is a funnel of sensors rather than a single clever classifier.

From pulse timing to a rhythm decision

A wrist PPG has no P wave and no crisp QRS complex, so the morphology tricks of ECG are unavailable. What it does have is the arrival time of each blood-volume pulse, which lets you build a pulse-to-pulse interval series, the optical analogue of the R-to-R tachogram. In normal sinus rhythm those intervals are regular and drift slowly. In AFib the ventricles fire at irregular intervals, so the pulse series scatters. Detecting AFib on a watch is therefore, at its core, the same irregularity measurement introduced for the clinical case in Section 29.2: quantify how disordered the interval sequence is, and flag windows that cross a threshold. This is the anomaly-and-change framing of Chapter 12 aimed at a physiological target through a much noisier lens.

Why does the noise change the design so completely? Because motion corrupts a PPG far more than it corrupts a chest ECG. A single irregular-looking window is almost always an artifact, not an arrhythmia. The engineering answer, used by both major studies, is opportunistic sampling plus temporal persistence: only score short "tachograms" collected when the wearer is still (Apple sampled during periods of stillness; Fitbit ran its check largely during inactivity and sleep), and only raise a notification when several consecutive tachograms are independently classified as irregular. Apple's rule required 5 of 6 consecutive tachograms to read irregular before notifying. That persistence gate is not a detail; it is the primary tool for converting a jittery per-window classifier into a specific per-person alert.

Key Insight

On a consumer wearable, specificity is manufactured in time, not just in the model. A per-window AFib classifier with modest false-positive rate would flood a healthy population with alarms if fired on every window. Requiring \(k\) of \(n\) consecutive clean windows to agree drives the effective false-positive rate down roughly as the product of per-window rates, at the cost of missing very short AFib episodes. The wearable trades sensitivity to brief paroxysms for the specificity that makes the alert trustworthy, exactly the operating-point choice the base-rate math of Chapter 4 says a rare-event screener must make.

The listing below builds an opportunistic PPG screener in miniature. It scores each still-window tachogram for irregularity, then applies a "5 of the last 6" persistence rule before it will notify, mirroring the Apple Heart Study logic on synthetic data.

import numpy as np

def tachogram_irregular(ppi_ms, thresh=0.12):
    """Flag one PPG tachogram as irregular from pulse-to-pulse intervals."""
    ppi = np.asarray(ppi_ms, float)
    rmssd = np.sqrt(np.mean(np.diff(ppi) ** 2))   # beat-to-beat scatter
    return (rmssd / ppi.mean()) > thresh           # normalize out heart rate

def screener(windows, k=5, n=6):
    """Notify only when k of the last n still-window tachograms are irregular."""
    flags, notified = [], False
    for w in windows:
        flags.append(tachogram_irregular(w))
        recent = flags[-n:]
        if len(recent) == n and sum(recent) >= k:
            notified = True
    return notified, flags

rng = np.random.default_rng(0)
sinus = [1000 + rng.normal(0, 8, 30) for _ in range(6)]          # regular
afib  = [1000 + rng.normal(0, 130, 30) for _ in range(6)]        # irregular
print("sinus ->", screener(sinus)[0])   # False: no notification
print("afib  ->", screener(afib)[0])    # True: persistence rule fires
Listing 30.2. An opportunistic PPG AFib screener. Each tachogram is scored by normalized RMSSD (heart rate divided out), and a notification requires 5 of 6 consecutive irregular windows. The persistence rule is what suppresses isolated motion-driven false positives; a single noisy window cannot trip the alarm.

As Listing 30.2 shows, the per-window test is almost trivial; the intelligence lives in the sampling policy and the persistence gate wrapped around it. Real products add a signal-quality classifier upstream (Section 30.6) so that only trustworthy tachograms ever reach the scorer, and they calibrate the threshold on the deployment population rather than on tidy clinical data.

The Right Tool

Extracting reliable pulse-to-pulse intervals from a raw optical trace, bandpass filtering, systolic-peak detection, artifact rejection, and interval bookkeeping, is roughly 120 to 200 lines of fragile code around dropped and doubled peaks. The heartpy library collapses it to two calls:

import heartpy as hp
wd, m = hp.process(ppg, sample_rate=64.0)   # peaks + cleaning
intervals = wd["RR_list_cor"]               # corrected pulse-to-pulse intervals (ms)
Listing 30.3. heartpy replaces about 150 lines of peak detection and interval cleaning with two calls, returning artifact-corrected intervals ready for the irregularity score. It supplies the plumbing; the persistence rule, threshold, and per-population validation remain your decisions.

The library removes the plumbing, not the judgment: intervals extracted from a motion-corrupted wrist trace still need the quality gate of Section 30.6 before they mean anything.

The two studies that made the case

The Apple Heart Study (Perez and colleagues, New England Journal of Medicine, 2019) enrolled about 419,000 participants entirely through an iPhone app, with no in-person visit. The watch algorithm sampled tachograms during stillness and issued an irregular-pulse notification under the 5-of-6 rule. Roughly half a percent of participants (and a larger fraction of those over 65) were notified. Anyone notified was mailed an ambulatory ECG patch to wear for about a week as the reference standard. Among participants who returned a patch with simultaneous data, the wrist notification's positive predictive value against concurrent ECG was about 0.84, yet only around a third of notified participants showed AFib on the patch over its wear window, because the intermittent arrhythmia often did not recur during the days-later recording. The Fitbit Heart Study (Lubitz and colleagues, 2022) followed the same siteless template at even larger scale, about 455,000 participants, with a photoplethysmography algorithm that ran mainly during inactivity and sleep; its per-detection positive predictive value against a concurrent one-week ECG patch was reported near 0.98, reflecting a conservative operating point.

In Practice: the notification-to-confirmation funnel

Picture the path of one real alert. A 68-year-old wearing an Apple Watch has six still tachograms scored overnight; five read irregular, so at breakfast the phone shows an irregular-rhythm notification. The watch has not diagnosed anything. It has triaged, cheaply, on a person who would never have booked a cardiology appointment for a symptom she does not feel. She is mailed an ECG patch, wears it a week, and it captures a paroxysm of AFib that confirms the flag; her physician starts anticoagulation and her stroke risk drops. Had the patch caught nothing, the cost of the false trail was a mailer and a clinic message, not a wrong prescription. Every design choice, opportunistic sampling, the 5-of-6 gate, a conservative threshold, an ECG confirmation step, exists so that a cheap wide-net optical sensor never carries the clinical decision alone. Scale comes from chaining a ubiquitous imprecise sensor to a scarce precise one, not from making the watch perfect.

Why these are screening, not diagnostic, devices

The regulatory framing follows directly from the funnel. Apple's irregular-rhythm notification feature and its on-demand single-lead ECG app were cleared by the FDA in 2018 through the De Novo pathway as over-the-counter screening tools, explicitly not intended to replace clinical diagnosis, and Fitbit's photoplethysmography algorithm received comparable clearance. A screening claim is much weaker than a diagnostic one: the device must reliably raise a flag worth confirming, and it must not alarm so often that users mute it, but it is never the final word. This is why the studies report the notification-to-confirmation funnel rather than a lone accuracy number, and why every claim is anchored to a concurrent ECG reference. The broader machinery of prospective clinical validation, regulatory pathways, and post-market surveillance that these studies exemplify is the subject of Chapter 34.

The scale that makes wearable screening attractive also concentrates its risks. When a single algorithm runs on tens of millions of wrists, a small bias becomes a population-level harm. Two recurring threads matter here. First, the alert is only as trustworthy as its calibration on the deployment distribution, so a probability that means the same thing across ages, activities, and devices requires the calibration discipline of Chapter 18. Second, green-light PPG is absorbed differently by different skin tones, so signal quality, and therefore both sensitivity and the false-alarm rate, can vary systematically across users; that fairness-and-calibration problem is important enough to earn its own treatment in Section 30.7. A screener that works beautifully on the enrolled cohort but degrades on darker skin or during exercise is not finished; it is dangerous at scale.

Research Frontier

Current work is moving PPG-based cardiac screening from a hand-tuned irregularity threshold toward learned representations. Deep models trained on very large PPG corpora (for example the DeepBeat work of Torres-Soto and Ashley, npj Digital Medicine, 2020, which jointly learns signal quality and AFib) and, increasingly, self-supervised wearable foundation models pretrained on millions of unlabeled traces, aim to detect AFib and beyond it from raw optical data with fewer labels, a direction taken up in Chapter 20. The open frontier is estimating AFib burden (the fraction of time in the rhythm) rather than issuing a binary alert, and doing so with calibrated, subgroup-fair confidence rather than a single population-average accuracy.

Exercise

A wearable vendor sets a per-tachogram irregularity classifier with a 4 percent false-positive rate on clean still-windows, and issues a notification only when 5 of 6 consecutive independent tachograms read irregular. Approximating the windows as independent, estimate the notification false-positive rate under the persistence rule and compare it to firing on a single window. Then state, in one sentence, the clinical cost the vendor pays for this specificity gain.

Self-Check

1. A wrist PPG has no P wave. What single property of the pulse series still lets it flag AFib, and what physiological fact makes that property irregular?

2. Both heart studies mailed an ECG patch to notified participants. Why is that confirmation step essential to calling the watch a screening rather than a diagnostic device?

3. Why does opportunistic sampling during stillness, plus a 5-of-6 persistence rule, matter more on a PPG watch than on a clinical chest ECG?

What's Next

In Section 30.3, we broaden the same wrist sensor from rhythm to the everyday vital signs it is more commonly asked to report: blood-oxygen saturation, resting and continuous heart rate, and heart-rate variability, examining what each measurement really estimates from reflected light and where the optics quietly break down.