Part VII: Health, Biosignals, and Wearable AI
Chapter 28: Biosignal Foundations

ECG, PPG, EEG, EMG, respiration, EDA

"The body broadcasts on six channels at once, in six different units, and none of them is labeled. I was hired to listen."

A Newly Onboarded AI Agent

Prerequisites

This chapter assumes the measurement view of Part I: that a sensor is a lossy, biased transducer rather than a window, developed in Chapter 2, and the sampling and bandwidth vocabulary (Nyquist rate, passband, spectra) built in Chapter 3. No physiology background is required; the biology you need is introduced here, and the filtering tools return with full mathematics in Chapter 6. Amplitude and frequency figures in this section are order-of-magnitude anchors for engineering decisions, not clinical thresholds.

The Big Picture

A living body leaks its internal state constantly, as electricity across the skin, as light bouncing off pulsing blood, as the mechanical heave of a chest. Six signals dominate wearable and clinical AI, and they are not six flavors of the same thing. They differ by three orders of magnitude in amplitude, by two orders in bandwidth, and by the physics that generates them: some are electrical, one is optical, some are mechanical or chemical. Before you filter, featurize, or feed a network, you must know which physical quantity each channel actually reports and at what scale. Get that wrong and every downstream choice, from sampling rate to the size of your neural receptive field, is quietly misconfigured.

Three physical routes out of the body

Every biosignal in this chapter reaches your analog-to-digital converter by one of three physical routes, and the route dictates almost everything about the sensor. Electrical signals are potential differences that ionic currents create as cells depolarize; you read them with electrodes as a voltage. The heart (ECG), the cortex (EEG), and skeletal muscle (EMG) all broadcast this way, which is why they share hardware (differential amplifiers, reference electrodes) yet occupy wildly different amplitude bands. Optical signals are read by shining light into tissue and measuring what returns; photoplethysmography (PPG) is the canonical example, inferring blood volume from how much a green or infrared beam is absorbed. Mechanical and chemical signals cover the rest: respiration is the mechanical expansion of the ribcage or the cooling of exhaled air, and electrodermal activity (EDA) is a chemical-electrical hybrid, the skin's changing conductance as sweat glands fill.

Why insist on this taxonomy first? Because the transduction route, not the organ, predicts the failure modes you will spend Section 28.2 fighting. Electrical channels are corrupted by the same 50/60 Hz mains hum and by electrode-skin impedance shifts. Optical channels are wrecked by motion and by ambient light leaking into the photodiode. Mechanical channels drift with posture. Knowing the route tells you, in advance, which artifact to expect and which second sensor can explain it away.

Key Insight

The single most consequential number about a biosignal is its amplitude scale. EEG lives in microvolts (\(\sim\)10 to 100 \(\mu\text{V}\)), ECG in millivolts (\(\sim\)0.5 to 4 mV), and surface EMG spans up to several millivolts. That is a dynamic range of roughly \(10^3\). A cortical signal is a thousand times fainter than a heartbeat measured a few centimeters away, so an amplifier tuned for one will clip or bury the other. Amplitude scale, more than any spectral property, decides your analog front-end and your quantization budget.

The cardiovascular pair: ECG and PPG see the same beat differently

ECG and PPG both track the heartbeat, but they measure different physical events separated in time, and confusing them is a classic beginner error. The electrocardiogram records the electrical command: the coordinated depolarization that makes the heart contract, seen as the familiar P wave, QRS complex, and T wave. It is what: a voltage of roughly 1 mV between electrodes, with diagnostic content from about 0.5 to 40 Hz (the full clinical band reaches 150 Hz), typically sampled at 250 to 500 Hz. It is precise in time; the sharp QRS peak marks each beat to within a few milliseconds, which is why ECG is the reference for heart-rate and rhythm work in Chapter 29.

The photoplethysmogram records the mechanical consequence: the pulse of blood volume arriving at the fingertip or wrist a fraction of a second after the electrical command, detected as a dip in transmitted or reflected light. Its pulsatile (AC) component is often only 1 to 2 percent of the steady (DC) light level, so PPG is intrinsically a small-signal-on-large-background measurement, sampled at 25 to 250 Hz and band-limited to a few hertz. The gap between the ECG R peak and the PPG upstroke is the pulse transit time, a quantity that carries blood-pressure information exploited in Chapter 30. When you fuse the two, remember: the same beat produces a crisp electrical spike and, tens of milliseconds later, a soft optical hill.

In Practice: the wrist that reports two heart rates

A fitness-band team ships a wrist PPG that agrees with a chest-strap ECG to within one beat per minute at rest, then fails a treadmill test. During running the optical rate reads a suspiciously round 180, exactly the user's step cadence. The photodiode is seeing venous blood sloshing and the band bouncing at stride frequency, not arterial pulse. The team's fix is not a brighter LED; it is to add an accelerometer channel and subtract the motion spectrum, and to gate output on a signal-quality index so the watch stays silent rather than confidently wrong. The lesson generalizes: an optical cardiovascular sensor and a mechanical motion sensor share a frequency band during exercise, and only fusion separates them.

Neural and muscular electricity: EEG and EMG

EEG and EMG are both electrical, both read with electrodes, and both easy to mistake for each other on a raw plot, yet they sit at opposite ends of the amplitude and frequency map. The electroencephalogram is the faintest signal in routine use: summed postsynaptic potentials of cortical neurons, attenuated by skull and scalp down to tens of microvolts. Its information is spectral, conventionally parsed into bands, delta (\(<\)4 Hz), theta (4 to 8 Hz), alpha (8 to 13 Hz), beta (13 to 30 Hz), and gamma (\(>\)30 Hz), each loosely tied to states from deep sleep to alert attention. Because the signal is tiny and the interesting structure is in relative band power, EEG demands high-input-impedance amplifiers and careful referencing, themes taken up in Chapter 31.

The electromyogram is the opposite temperament: a loud, broadband burst. Surface EMG captures the summed action potentials of firing motor units, reaching several millivolts with meaningful energy from roughly 20 to 450 Hz, which forces sampling at 1000 Hz or higher to avoid aliasing the upper band. Where EEG rewards patient spectral analysis, EMG is often used for fast onset detection: the muscle is either recruiting or it is not, and the envelope of the rectified signal tells you when. That amplitude-and-bandwidth contrast is why the two, despite sharing a transduction route, need different front-ends and different feature pipelines, developed further in Chapter 32.

The slow signals: respiration and EDA

The last pair moves so slowly that beginners often forget they are signals at all. Respiration oscillates at roughly 0.1 to 0.5 Hz (about 6 to 30 breaths per minute) and can be sensed many ways: a chest strain belt, a thoracic impedance measurement, an inductance plethysmography band, or a thermistor reading the warm-cool cycle of airflow at the nose. Because it is slow, respiration is cheap to sample (tens of hertz suffice) but expensive to isolate, since it modulates other signals: it rides on the ECG baseline and on PPG amplitude, an entanglement that lets you sometimes recover breathing rate from a heart sensor alone.

Electrodermal activity, historically called galvanic skin response, is slower still and chemical in origin. Eccrine sweat glands, driven by the sympathetic nervous system, change the skin's conductance measured in microsiemens. EDA splits into a slowly wandering tonic level (skin conductance level) and brief phasic bumps (skin conductance responses) that rise over one to five seconds after an arousing stimulus. Its band is essentially below 1 Hz, so 4 to 32 Hz sampling is ample. EDA is the workhorse of stress and arousal inference precisely because it is an almost direct readout of sympathetic tone, with no fast dynamics to chase. Table 28.1.1 collects the amplitude, bandwidth, and sampling anchors for all six modalities so you can size a front-end at a glance.

Table 28.1.1: Engineering anchors for the six core biosignals. Values are typical order-of-magnitude ranges for wearable and ambulatory settings, not clinical limits.
SignalRouteAmplitudeUseful bandTypical sampling
ECGElectrical\(\sim\)1 mV0.5 to 40 Hz (to 150 Hz)250 to 500 Hz
PPGOpticalAC \(\sim\)1 to 2% of DC0.5 to 8 Hz25 to 250 Hz
EEGElectrical10 to 100 \(\mu\text{V}\)0.5 to 40 Hz (to 100 Hz)250 to 1000 Hz
EMGElectricalup to several mV20 to 450 Hz1000 to 2000 Hz
RespirationMechanicaldevice-dependent0.1 to 0.5 Hz4 to 50 Hz
EDAChemical/electrical1 to 20 \(\mu\text{S}\)< 1 Hz4 to 32 Hz

The table makes one design rule concrete. Sampling rate is set by the top of the useful band through Nyquist, so EMG at 450 Hz forces at least 1000 Hz sampling while EDA below 1 Hz is comfortable at 8 Hz. The short Python below turns the table into an automatic check: given a signal's band edge, it reports the minimum safe sampling rate and flags any recording that undersampled.

import numpy as np

# (name, upper edge of useful band in Hz, sampling rate the device actually used)
recordings = [("ECG", 40, 500), ("EMG", 450, 500), ("EDA", 1, 8), ("EEG", 40, 250)]

for name, f_high, fs in recordings:
    nyquist_min = 2 * f_high          # theoretical floor
    safe_min = 2.5 * f_high           # practical margin for a realizable anti-alias filter
    status = "OK" if fs >= safe_min else "UNDERSAMPLED"
    print(f"{name:4s}  band<= {f_high:4d} Hz  fs={fs:5d} Hz  "
          f"need>= {safe_min:6.1f} Hz  -> {status}")
Listing 28.1. A ten-line sampling-adequacy check. Each modality's upper band edge sets a Nyquist floor of \(2 f_{\text{high}}\); the practical \(2.5\times\) margin leaves room for a real anti-aliasing filter's transition band. Running it flags the EMG row (500 Hz sampling for a 450 Hz band) as undersampled, exactly the mistake that aliases high-frequency muscle energy into the physiological band.

As Listing 28.1 shows, the EMG entry that looked fine in isolation is caught: sampling a 450 Hz band at 500 Hz leaves no room for an anti-aliasing filter, so out-of-band energy folds back onto the signal you care about. This is the sampling discipline of Chapter 3 applied to physiology, and it is the first gate every biosignal pipeline should pass.

The Right Tool

Written from scratch, loading an ECG, filtering it to its diagnostic band, detecting R peaks, and computing heart rate and heart-rate variability is roughly 60 to 80 lines of careful signal code, most of it easy to get wrong at window edges and around ectopic beats. The neurokit2 library collapses the common path to two lines and returns a fully labeled dataframe:

import neurokit2 as nk
signals, info = nk.ecg_process(ecg, sampling_rate=500)   # cleans, finds R peaks, rates
hr = signals["ECG_Rate"].mean()                          # beats per minute
Listing 28.2. neurokit2.ecg_process handles cleaning, R-peak detection, and instantaneous rate in one call, replacing about 70 lines of hand-written pipeline. It covers ECG, PPG, EDA, EMG, and respiration behind one consistent API. The library removes the drudgery; deciding whether its default filter suits your device and population remains your judgment.

The convenience is real and so is the caveat: a default cleaner tuned for clinical ECG may over-smooth a noisy wrist recording, so validate the library's choices on your own data before trusting the numbers, a discipline sharpened in Chapter 6.

Exercise

You are handed an unlabeled single-channel recording sampled at 1000 Hz. In two or three sentences, describe how you would decide whether it is ECG, EEG, or EMG using only its amplitude scale and dominant frequency content, without any physiology metadata. Then name one situation in which your rule would misclassify the signal, and which extra channel would resolve it.

Self-Check

1. Why do ECG and EEG share amplifier hardware yet require different gain and quantization settings?

2. The ECG R peak and the PPG upstroke both mark one heartbeat. Why are they not simultaneous, and what does the delay between them encode?

3. Respiration and EDA both sit below a few hertz. Give one reason each is nonetheless hard to isolate cleanly from the signals it shares a recording with.

What's Next

In Section 28.2, we turn from what these six signals are to how they get corrupted: the physiological noise and motion artifacts that ride on every channel, why an optical sensor and an accelerometer end up fighting over the same frequency band during exercise, and the artifact taxonomy that decides which corruption you can filter and which you must instead detect and reject.