Laboratory 4 of 5 · Inside a Pulse Oximeter

Filtering and Peak Detection

A raw pulse signal is noisy. Smooth it, set a threshold, find each beat, and see how a pulse rate is calculated. Then see what the cleaning costs.

The signal and the noise are synthetic. The filters here are the simplest useful ones, chosen to teach. Real devices use more advanced methods, and nothing here is a clinical algorithm.

Go to the simulation

Summary

What you will learn

After the sensor measures the light, a processor has to turn a wobbly line into a number. It cleans the signal, finds each heartbeat, and measures the time between beats. In this laboratory you do each of those steps by hand with sliders, and you see that every step has a price.

  • What a filter does, and how smoothing and drift removal differ
  • How a threshold turns a waveform into a list of heartbeats
  • How pulse rate is calculated from the time between beats
  • How noise causes extra beats and missed beats
  • Why filtering always trades one thing for another

Key ideas

Read this first

What is a filter?

A filter keeps some speeds of change in a signal and reduces others. A heartbeat repeats about once or twice a second. Noise that is much faster, or drift that is much slower, can be reduced without touching the beat.

Smoothing

Smoothing replaces each sample with the average of its neighbors. Fast fuzz averages away. A wider window removes more fuzz, but it also rounds off the real pulse and makes it smaller.

Removing drift

Slow drift can be removed by subtracting a running average of the surrounding few seconds. What is left changes only at the speed of the pulse.

Finding beats

A beat is a peak that rises above a threshold. A minimum gap of 0.3 seconds between beats stops one beat from being counted twice, because a heart cannot beat much faster than that.

Pulse rate

Pulse rate in beats per minute is 60 divided by the average time between beats, in seconds. Beats that are missed or invented change that average, so the rate becomes wrong.

Filtering has a price

Whatever a filter removes, it may remove from the real signal too. Movement is the hardest case: it changes at about the same speed as the pulse, so no simple filter can separate them. Try it with the Walking example.

What each control does, and what it costs
ControlWhat it helps withWhat it costs
More smoothingFuzz and light flickerThe pulse gets smaller and rounder, and fine detail such as the notch is lost
Remove slow driftA trace that wanders up and downVery slow real changes are removed too, and the start and end of the signal are less reliable
Higher thresholdNoise peaks counted as beatsWeak real beats are missed
Lower thresholdCatching weak beatsNoise peaks are counted as extra beats

Simulation

Find the heartbeats

Raw signal and filtered signal

Live measurements

Result

A found beat is a detection within 0.12 seconds of a true beat. The true beats are known because the signal is synthetic. In a real device they are not, which is what makes the problem hard. Pulse size kept compares the filtered clean pulse with the original.

How the pulse rate is calculated

The time between each pair of neighboring beats is averaged, and 60 is divided by that average.

Limitations

What this model leaves out

For filters and sampling in more depth, read Signal processing in biomedical devices.

Check your understanding

Four questions