An algorithm for calculating the heart rate from a photoplethysmography (PPG) signal.
The algorithm for calculating heart rate (HR) from Photoplethysmography (PPG) signals involves analyzing the signal’s characteristics, removing noise, and extracting periodic features to determine heart rate. Here’s a detailed explanation:
1. Principle of PPG Signals
- PPG works by detecting changes in light absorption caused by blood flow variations in blood vessels.
- A light source (typically red or infrared) is projected onto the skin, and the reflected or absorbed light is captured by a photodetector.
- Blood volume changes synchronized with heartbeats generate a periodic waveform in the PPG signal.
2. Signal Preprocessing
PPG signals require preprocessing to remove noise and prepare the data for accurate heart rate calculation.
Key Steps:
- Noise Removal
- Low-pass filter: Removes high-frequency noise.
- High-pass filter: Eliminates baseline drift.
- Band-pass filter: Extracts frequencies within the heart rate range (0.5–4 Hz).
- Signal Smoothing
- Moving average or Gaussian filters are used to smooth the signal and reduce noise.
- Artifact Removal
- Techniques like Wavelet Transform or Independent Component Analysis (ICA) mitigate distortions caused by motion or lighting changes.
3. Peak Detection
The heart rate is calculated by detecting peaks in the PPG waveform, which correspond to maximum blood volume during each heartbeat.
Key Methods:
- Threshold-Based Detection
- Detect peaks based on signal derivatives and thresholding.
- Zero-Crossing Detection
- Identify points where the signal derivative crosses zero to locate maxima and minima.
- Fast Fourier Transform (FFT)
- Analyze the frequency spectrum to detect periodic peaks representing heart rate.
- Wavelet Transform
- Use time-frequency resolution to identify peaks and analyze periodic patterns.
4. Heart Rate Calculation
- R-R Interval Measurement
- Measure the time interval between successive peaks to compute heart rate.
- Formula: HR (BPM)=60 / Average R-R Interval (seconds)
- Frequency Domain Analysis
- Use FFT to find dominant frequency peaks representing the heart rate.
- Weighted Moving Average
- Stabilize real-time HR fluctuations by applying a weighted average to recent measurements.
5. Motion Compensation and Advanced Features
PPG signals are prone to distortions from motion artifacts, skin conditions, and ambient lighting. Mitigation strategies include:
- Motion Artifact Removal
- Use accelerometer data to correct for motion-induced distortions.
- Apply adaptive filtering techniques for noise removal.
- Multi-Channel PPG
- Combine signals from multiple PPG sensors at different locations to improve accuracy.
6. Applications and Benefits
- Wearable Devices: Smartwatches (e.g., Apple Watch, Fitbit), fitness trackers.
- Healthcare: Non-invasive heart rate monitoring, stress management, activity tracking.
- Advantages: Simple hardware setup, real-time analysis, and widespread usability.
PPG-based heart rate algorithms rely on high-quality signal preprocessing, precise peak detection, and effective noise reduction, enabling accurate and reliable HR measurement in various conditions.
Why is noise removal important in PPG signals?
PPG signals are easily affected by external factors such as skin movement, ambient lighting, and sensor contact. Failure to remove this noise can lead to false peak detection, resulting in results that differ from the actual heart rate.
Therefore, it’s essential to use low-pass, high-pass, and band-pass filters to retain only the pure signal corresponding to the heart rate band (0.5-4 Hz).
How is heart rate converted to actual beats per minute (BPM)?
Basically, the R-R interval (the time between two consecutive peaks) is measured and the average interval is used to calculate BPM.
The formula is HR (BPM) = 60 / Average R-R interval (seconds). For example, if the average interval is 0.8 seconds, 60 / 0.8 = 75 BPM.
![WEARABLE_INSIGHT [FORUM]](https://wearableinsight.net/wp-content/uploads/2025/04/로고-3WEARABLE-INSIGHT1344x256.png)

