Smartphone-Based Heart Rate Monitoring: Preprocessing and Analysis of PPG Signals

Benjamin Gallois PhD
4 min readSep 25, 2023

--

Photo by Joshua Chehov on Unsplash

Introduction

Estimating heart rate from optical signals forms the foundation of numerous wearable devices such as smartwatches and bracelets. This technique, known as Photoplethysmography (PPG), relies on detecting changes in blood volume within tissue. This article will illustrate how heart rate can be deduced from simple images using a primary smartphone device and image analysis. It’s important to note that production algorithms found in wearable devices are considerably more sophisticated, as they must account for various noise sources, such as motion and external light sources.

Protocol

A video is recorded in complete darkness with no motion for your experiment. The subject’s index finger is positioned so that the entire objective is entirely covered by skin, and the tip of the index finger overlays the illuminated flashlight. The smartphone is fully charged, and no apps are running in the background to ensure that no power interference alters the flashlight’s intensity.
Two minutes of video are captured using the smartphone, while simultaneously recording the heart rate using a TomTom ECG chest strap and a Wahoo Element device. The goal is to compare the average heart rate observed during this two-minute test.

Analysis

We utilize OpenCV to load the video and compute the mean for each color channel within each image. This allows us to extract the red, blue, and green mean signals over time. As illustrated in Figure 1, it becomes evident that each signal exhibits the characteristic pattern of the Photoplethysmographic (PPG) signal, which consists of a pulsatile (‘AC’) physiological waveform corresponding to each heartbeat, as well as a slowly varying (‘DC’) baseline. Interestingly, the green signal stands out as the cleanest among them, showcasing maximal amplitude and minimal interference. As a result, we have chosen the green signal for further analysis and investigation.

Figure 1a. Mean color signals
Figure 1b. Mean color signals

Initially, we employ a Wiener filter to eliminate any signal noise. Subsequently, we undertake detrending to remove any long-term trends present in the time series. Finally, a high-pass filter is applied to eliminate low-frequency signal components unrelated to heart rate (those below 20 beats per minute), as visualized in Figure 2.
Following these preprocessing steps, we utilize the Fourier transform to analyze the signal in the frequency domain. We identify the frequency with the highest amplitude as the average heart rate observed during the two-minute test, see Figure 3.

Figure 2. Cleaned signal
Figure 3. Frequency analysis

Results

The average heart rate recorded using the chest strap was 84.67 BPM. The smartphone camera’s computed heart rate was 85.06 BPM, resulting in a relative error of 0.46 percent. Regarding heart rate recording, we can compute the HR versus time by applying the same method but using time windows of 4 seconds (with a mean heart rate of 85 BPM, we will have approximately 6 beats per window) to calculate the Fourier transform and determine the frequency with the highest amplitude. We then apply a rolling average over a 6-second window to smooth the signal. Figure 4 represents the two curves, and we can observe that they follow the same general trend.

Figure 4. HR vs Time

Conclusion

We have demonstrated the feasibility of deducing heart rate from smartphone images with minimal image and signal processing. It’s important to note that this simplified technique was applied to images captured under ideal conditions, free from motion artifacts and external light interference. In practice, production devices and applications employ significantly more sophisticated algorithms, enabling them to achieve higher accuracy and finer time resolution in heart rate measurement. These advanced systems perform thorough signal analysis and noise reduction to deliver more reliable results.

--

--

Benjamin Gallois PhD

🔬PhD in physics 🌐Open-source dev 🚀FastTrack creator 💼Freelance in computer vision & blockchain 🚴‍♂️Competitive cyclist 🏆Sports science enthusiast