LogoLogo
HomeAPI & SDKsProjectsForumStudio
  • Getting started
    • For beginners
    • For ML practitioners
    • For embedded engineers
  • Frequently asked questions (FAQ)
  • Tutorials
    • End-to-end tutorials
      • Computer vision
        • Image classification
        • Object detection
          • Object detection with bounding boxes
          • Detect objects with centroid (FOMO)
        • Visual anomaly detection
        • Visual regression
      • Audio
        • Sound recognition
        • Keyword spotting
      • Time-series
        • Motion recognition + anomaly detection
        • Regression + anomaly detection
        • HR/HRV
        • Environmental (Sensor fusion)
    • Data
      • Data ingestion
        • Collecting image data from the Studio
        • Collecting image data with your mobile phone
        • Collecting image data with the OpenMV Cam H7 Plus
        • Using the Edge Impulse Python SDK to upload and download data
        • Trigger connected board data sampling
        • Ingest multi-labeled data using the API
      • Synthetic data
        • Generate audio datasets using Eleven Labs
        • Generate image datasets using Dall-E
        • Generate keyword spotting datasets using Google TTS
        • Generate physics simulation datasets using PyBullet
        • Generate timeseries data with MATLAB
      • Labeling
        • Label audio data using your existing models
        • Label image data using GPT-4o
      • Edge Impulse Datasets
    • Feature extraction
      • Building custom processing blocks
      • Sensor fusion using embeddings
    • Machine learning
      • Classification with multiple 2D input features
      • Visualize neural networks decisions with Grad-CAM
      • Sensor fusion using embeddings
      • FOMO self-attention
    • Inferencing & post-processing
      • Count objects using FOMO
      • Continuous audio sampling
      • Multi-impulse (C++)
      • Multi-impulse (Python)
    • Lifecycle management
      • CI/CD with GitHub Actions
      • Data aquisition from S3 object store - Golioth on AI
      • OTA model updates
        • with Arduino IDE (for ESP32)
        • with Arduino IoT Cloud
        • with Blues Wireless
        • with Docker on Allxon
        • with Docker on Balena
        • with Docker on NVIDIA Jetson
        • with Espressif IDF
        • with Nordic Thingy53 and the Edge Impulse app
        • with Particle Workbench
        • with Zephyr on Golioth
    • API examples
      • Customize the EON Tuner
      • Ingest multi-labeled data using the API
      • Python API bindings example
      • Running jobs using the API
      • Trigger connected board data sampling
    • Python SDK examples
      • Using the Edge Impulse Python SDK to run EON Tuner
      • Using the Edge Impulse Python SDK to upload and download data
      • Using the Edge Impulse Python SDK with Hugging Face
      • Using the Edge Impulse Python SDK with SageMaker Studio
      • Using the Edge Impulse Python SDK with TensorFlow and Keras
      • Using the Edge Impulse Python SDK with Weights & Biases
    • Expert network projects
  • Edge Impulse Studio
    • Organization hub
      • Users
      • Data campaigns
      • Data
        • Cloud data storage
      • Data pipelines
      • Data transformation
        • Transformation blocks
      • Upload portals
      • Custom blocks
        • Custom AI labeling blocks
        • Custom deployment blocks
        • Custom learning blocks
        • Custom processing blocks
        • Custom synthetic data blocks
        • Custom transformation blocks
      • Health reference design
        • Synchronizing clinical data with a bucket
        • Validating clinical data
        • Querying clinical data
        • Transforming clinical data
    • Project dashboard
      • Select AI hardware
    • Devices
    • Data acquisition
      • Uploader
      • Data explorer
      • Data sources
      • Synthetic data
      • Labeling queue
      • AI labeling
      • CSV Wizard (time-series)
      • Multi-label (time-series)
      • Tabular data (pre-processed & non-time-series)
      • Metadata
      • Auto-labeler | deprecated
    • Impulses
    • EON Tuner
      • Search space
    • Processing blocks
      • Audio MFCC
      • Audio MFE
      • Audio Syntiant
      • Flatten
      • HR/HRV features
      • Image
      • IMU Syntiant
      • Raw data
      • Spectral features
      • Spectrogram
      • Custom processing blocks
      • Feature explorer
    • Learning blocks
      • Anomaly detection (GMM)
      • Anomaly detection (K-means)
      • Classification
      • Classical ML
      • Object detection
        • MobileNetV2 SSD FPN
        • FOMO: Object detection for constrained devices
      • Object tracking
      • Regression
      • Transfer learning (images)
      • Transfer learning (keyword spotting)
      • Visual anomaly detection (FOMO-AD)
      • Custom learning blocks
      • Expert mode
      • NVIDIA TAO | deprecated
    • Retrain model
    • Live classification
    • Model testing
    • Performance calibration
    • Deployment
      • EON Compiler
      • Custom deployment blocks
    • Versioning
    • Bring your own model (BYOM)
    • File specifications
      • deployment-metadata.json
      • ei-metadata.json
      • ids.json
      • parameters.json
      • sample_id_details.json
      • train_input.json
  • Tools
    • API and SDK references
    • Edge Impulse CLI
      • Installation
      • Serial daemon
      • Uploader
      • Data forwarder
      • Impulse runner
      • Blocks
      • Himax flash tool
    • Edge Impulse for Linux
      • Linux Node.js SDK
      • Linux Go SDK
      • Linux C++ SDK
      • Linux Python SDK
      • Flex delegates
      • Rust Library
    • Rust Library
    • Edge Impulse Python SDK
  • Run inference
    • C++ library
      • As a generic C++ library
      • On Android
      • On your desktop computer
      • On your Alif Ensemble Series Device
      • On your Espressif ESP-EYE (ESP32) development board
      • On your Himax WE-I Plus
      • On your Raspberry Pi Pico (RP2040) development board
      • On your SiLabs Thunderboard Sense 2
      • On your Spresense by Sony development board
      • On your Syntiant TinyML Board
      • On your TI LaunchPad using GCC and the SimpleLink SDK
      • On your Zephyr-based Nordic Semiconductor development board
    • Arm Keil MDK CMSIS-PACK
    • Arduino library
      • Arduino IDE 1.18
    • Cube.MX CMSIS-PACK
    • Docker container
    • DRP-AI library
      • DRP-AI on your Renesas development board
      • DRP-AI TVM i8 on Renesas RZ/V2H
    • IAR library
    • Linux EIM executable
    • OpenMV
    • Particle library
    • Qualcomm IM SDK GStreamer
    • WebAssembly
      • Through WebAssembly (Node.js)
      • Through WebAssembly (browser)
    • Edge Impulse firmwares
    • Hardware specific tutorials
      • Image classification - Sony Spresense
      • Audio event detection with Particle boards
      • Motion recognition - Particle - Photon 2 & Boron
      • Motion recognition - RASynBoard
      • Motion recognition - Syntiant
      • Object detection - SiLabs xG24 Dev Kit
      • Sound recognition - TI LaunchXL
      • Keyword spotting - TI LaunchXL
      • Keyword spotting - Syntiant - RC Commands
      • Running NVIDIA TAO models on the Renesas RA8D1
      • Two cameras, two models - running multiple object detection models on the RZ/V2L
  • Edge AI Hardware
    • Overview
    • Production-ready
      • Advantech ICAM-540
      • Seeed SenseCAP A1101
      • Industry reference design - BrickML
    • MCU
      • Ambiq Apollo4 family of SoCs
      • Ambiq Apollo510
      • Arducam Pico4ML TinyML Dev Kit
      • Arduino Nano 33 BLE Sense
      • Arduino Nicla Sense ME
      • Arduino Nicla Vision
      • Arduino Portenta H7
      • Blues Wireless Swan
      • Espressif ESP-EYE
      • Himax WE-I Plus
      • Infineon CY8CKIT-062-BLE Pioneer Kit
      • Infineon CY8CKIT-062S2 Pioneer Kit
      • Nordic Semi nRF52840 DK
      • Nordic Semi nRF5340 DK
      • Nordic Semi nRF9160 DK
      • Nordic Semi nRF9161 DK
      • Nordic Semi nRF9151 DK
      • Nordic Semi nRF7002 DK
      • Nordic Semi Thingy:53
      • Nordic Semi Thingy:91
      • Open MV Cam H7 Plus
      • Particle Photon 2
      • Particle Boron
      • RAKwireless WisBlock
      • Raspberry Pi RP2040
      • Renesas CK-RA6M5 Cloud Kit
      • Renesas EK-RA8D1
      • Seeed Wio Terminal
      • Seeed XIAO nRF52840 Sense
      • Seeed XIAO ESP32 S3 Sense
      • SiLabs Thunderboard Sense 2
      • Sony's Spresense
      • ST B-L475E-IOT01A
      • TI CC1352P Launchpad
    • MCU + AI accelerators
      • Alif Ensemble
      • Arduino Nicla Voice
      • Avnet RASynBoard
      • Seeed Grove - Vision AI Module
      • Seeed Grove Vision AI Module V2 (WiseEye2)
      • Himax WiseEye2 Module and ISM Devboard
      • SiLabs xG24 Dev Kit
      • STMicroelectronics STM32N6570-DK
      • Synaptics Katana EVK
      • Syntiant Tiny ML Board
    • CPU
      • macOS
      • Linux x86_64
      • Raspberry Pi 4
      • Raspberry Pi 5
      • Texas Instruments SK-AM62
      • Microchip SAMA7G54
      • Renesas RZ/G2L
    • CPU + AI accelerators
      • AVNET RZBoard V2L
      • BrainChip AKD1000
      • i.MX 8M Plus EVK
      • Digi ConnectCore 93 Development Kit
      • MemryX MX3
      • MistyWest MistySOM RZ/V2L
      • Qualcomm Dragonwing RB3 Gen 2 Dev Kit
      • Renesas RZ/V2L
      • Renesas RZ/V2H
      • IMDT RZ/V2H
      • Texas Instruments SK-TDA4VM
      • Texas Instruments SK-AM62A-LP
      • Texas Instruments SK-AM68A
      • Thundercomm Rubik Pi 3
    • GPU
      • Advantech ICAM-540
      • NVIDIA Jetson
      • Seeed reComputer Jetson
    • Mobile phone
    • Porting guide
  • Integrations
    • Arduino Machine Learning Tools
    • AWS IoT Greengrass
    • Embedded IDEs - Open-CMSIS
    • NVIDIA Omniverse
    • Scailable
    • Weights & Biases
  • Tips & Tricks
    • Combining impulses
    • Increasing model performance
    • Optimizing compute time
    • Inference performance metrics
  • Concepts
    • Glossary
    • Course: Edge AI Fundamentals
      • Introduction to edge AI
      • What is edge computing?
      • What is machine learning (ML)?
      • What is edge AI?
      • How to choose an edge AI device
      • Edge AI lifecycle
      • What is edge MLOps?
      • What is Edge Impulse?
      • Case study: Izoelektro smart grid monitoring
      • Test and certification
    • Data engineering
      • Audio feature extraction
      • Motion feature extraction
    • Machine learning
      • Data augmentation
      • Evaluation metrics
      • Neural networks
        • Layers
        • Activation functions
        • Loss functions
        • Optimizers
          • Learned optimizer (VeLO)
        • Epochs
    • What is embedded ML, anyway?
    • What is edge machine learning (edge ML)?
Powered by GitBook
On this page
  • Configuration
  • Input block
  • Selecting features passed to learning block
  • Parameter definitions
  • Minimum HRV window sizes
  • Outputs
  • HRV features groups
  • Number of processed features
  • Deployment
  • Optimizing for MCU-based deployments
  • Examples
  • Accessing heart rate values at runtime
  • Outputting heart rate values without classification
  • Minimizing RAM Usage
  • Conclusion

Was this helpful?

Export as PDF
  1. Edge Impulse Studio
  2. Processing blocks

HR/HRV features

PreviousFlattenNextImage

Last updated 18 days ago

Was this helpful?

The HR/HRV Features block processes physiological signals like photoplethysmogram (PPG) or electrocardiogram (ECG), with optional accelerometer inputs for enhanced accuracy in motion-prone applications, to extract key metrics such as heart rate (HR) and heart rate variability (HRV). HR measures the number of beats per minute, while HRV measures the time variance between successive heartbeats, also known as the interbeat interval (IBI).

The block offers real-time HR estimation and HRV analysis on resource-constrained edge devices and leverages cutting-edge algorithms for precise feature extraction. The extracted features can be used on their own or to inform downstream machine learning tasks such as stress detection or heart health analysis.

To see a demonstration of how to use the HR/HRV Features block, refer to our tutorial: .

Evaluation available for everyone; deployment only available with Enterprise plan

All users (developer and enterprise) can extract heart rate and HRV features using this block for testing purposes. However, the deployment option is only available for Enterprise users. Please contact your Solutions Engineer to enable it.

Configuration

Tip: Use accelerometer data whenever possible to enhance the accuracy of heart rate and HRV estimation in dynamic environments.

By configuring the HR/HRV Features block, you can obtain critical metrics like heart rate and HRV in real-time, enabling applications such as fitness tracking, stress monitoring, and health diagnostics. The extracted features can be fine-tuned to match the performance and constraints of edge devices, ensuring both efficiency and accuracy.

Input block

When using the HR/HRV Features block, it is important to also configure the input block for your impulse appropriately.

Window size

There are minimum input block window size requirements depending on your configuration of the HR/HRV Features block. If you are using HRV features, the input block window size must be greater than or equal to the HRV update interval. If you are not using HRV features, the input block window size must be greater than or equal to 2 seconds.

The minimum window size of 2 seconds is determined by the fact that the heart rate calculation is performed once for every 2 second period. When the window size is increased beyond 2 seconds, more heart rate values will be provided to the learning block. For example, a 2 second window will pass 1 heart rate value per window whereas a 10 second window will pass 5 heart rate values per window.

Window increase (stride)

For optimal performance, it is recommended to set the window increase (stride) equal to the window size.

Frequency (Hz)

All input signals (PPG or ECG, and accelerometer) must have a frequency of either 25 Hz (tolerance +/- 1 Hz) or 50 Hz (tolerance +/- 3 Hz).

Selecting features passed to learning block

Heart rate values, HRV features, or both can be passed to the learning block. To only send heart rate values, select none for the HRV features parameter. To send only HRV features, select your desired HRV features parameter value (other than none) and deselect the include calculated heart rates parameter. To send both heart rate values and HRV features, select your desired HRV features parameter value (other than none) and select the include calculated heart rates parameter.

Parameter definitions

Compatible with the DSP Autotuner

Picking the right parameters for DSP algorithms can be difficult. It often requires a lot of experience and experimenting. The autotuning function makes this process easier by looking at the entire dataset and recommending a set of parameters that is tuned for your dataset.

Note that this applies to the heart rate and accelerometer settings, not the HRV settings.

The following parameters are available for configuring the HR/HRV Features block. Note that all heart rate and accelerometer settings can be estimated using the autotuning of parameters, and is the suggested approach.

Heart rate settings

Parameter
Description

Filter preset

Sets the aggressiveness of the input signal filter.

HR window size

The signal history used when calculating the heart rate. The larger the value, the smoother and more averaged the heart rate values.

Accelerometer settings

Parameter
Description

Sensitivity

The sensitivity to motion artifacts.

Accelerometer signal level while resting

The sum of the standard deviation of all three axes; the accelerometer noise floor. The value is dependent on hardware design, yet can be estimated from the signal using the autotuner.

HRV settings

Parameter
Description

HRV features

The group of HRV features to use.

Include calculated heart rates in classifier input

Whether or not to include heart rate values in addition to HRV features.

HRV update interval

How often new HRV features are calculated. Typically a fraction of the input block window size, e.g. 30 seconds update interval for a 90 seconds input window size.

HRV window size

The signal history used when calculating the HRV features. The larger the value, the smoother and more averaged the HRV features. There are minimums based on the HRV features group selected, see below.

Minimum HRV window sizes

HRV Features Group
Min. HRV Window Size (s)

none

N/A

rmssd

10

time-domain

30

all

90

Outputs

The HR/HRV Features block outputs heart rate values and HRV features based on your configuration. The HRV features contain time-domain and frequency-domain features as shown below.

Heart rate

  • Heart Rate Values

HRV time-domain features

  • IBI Slope

  • HR Mean

  • HR Slope

  • RMSSD Slope

  • RMSSD

  • AVNN

  • SDNN

  • Range NN

  • MAD NN

  • pNN50

  • NN Percentile (10)

  • NN Percentile (25)

  • NN Percentile (75)

  • NN Percentile (90)

  • IQR

  • SDSD

  • SD1

  • SD2

  • SD2/SD1 Ratio

HRV frequency-domain features

  • Raw VLF Energy

  • Raw LF Energy

  • Raw HF Energy

  • Raw Total Energy

  • Relative VLF Energy

  • Relative LF Energy

  • Relative HF Energy

  • LF/HF Ratio

  • Peak VLF Energy

  • Peak LF Energy

  • Peak HF Energy

HRV features groups

Instead of individually selecting the HRV features that are output, you can select a group that contains multiple features. The HRV features associated with each group are defined below.

HRV Features Group
Features Included

none

None

rmssd

RMSSD

time-domain

Time-domain

all

Time-domain and frequency-domain

Number of processed features

The number of processed features will depend on your configuration of the input block and HR/HRV Features block. For example if you have an input window of 90 seconds, selected all for the HRV features group (30 features), enabled including heart rate values being passed to the learning block, and have an HRV update interval of 30 seconds, there will be 135 processed features - 45 heart rate values (90 seconds input window / 2 seconds per heart rate value) and 90 HRV features (90 seconds input window / 30 seconds update interval x 30 features).

Deployment

If you are an Enterprise customer, please contact your Solutions Engineer to enable deployment.

The HR/HRV Features block has industry leading efficiency for RAM and flash usage and can be deployed into a wide range of devices, including fitness trackers, health monitors, and stress detection systems. The functionality can be deployed either as C++ or C bindings.

Optimizing for MCU-based deployments

To optimize for MCU-based systems, your enterprise representative can provide a MAP file. This file contains a detailed breakdown of the memory footprint (flash and RAM) for the HR/HRV Features block, including the IBI processing components. This data is critical for fine-tuning and optimizing the deployment of the block on resource-constrained devices.

Examples

Accessing heart rate values at runtime

One important note when working with the HR/HRV Features block is that you can extract heart rate values even when running a classifier. This is particularly useful if your model is performing classification tasks but you'd also like to access heart rate data. The code snippet below demonstrates how to access the heart rate information during inference and print the results in a C++ application.

#include "edge-impulse-sdk/classifier/ei_run_classifier.h"

int main() {
    // Initialize signal (PPG data, etc.)
    signal_t signal;
    ei_impulse_result_t result;

    // Run the classifier and print the results
    run_classifier(&signal, &result, false);
    printf("Heart rate: %.2f BPM\n", results.hr_calcs.heart_rate);

    return 0;
}

Outputting heart rate values without classification

If you want to use the HR/HRV Features block solely for heart rate values without any classification in Studio, you can configure a regression learning block to "pass through" the result. This can be achieved by using expert mode for the block to set up a simple neural network.

import tensorflow as tf

# Example: Setting up a basic HR model in Edge Impulse
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.InputLayer(input_shape=1))
model.add(tf.keras.layers.Dense(1, name='y_pred', activation='linear'))

After saving and training the model (though there's effectively no training needed in this case), you can then use Model Testing or Live Classification to evaluate the heart rate estimation.

If you also would like to deploy the HR/HRV Features block without running a classifier on device, when compiling define the following macro via CMake or Makefile to avoid flash overhead for the unused learn block.

#define EI_CLASSIFIER_DSP_ONLY 1

Minimizing RAM Usage

When running classifiers that make use of a large window size, such as for HRV features, you can avoid buffering the entire window of PPG or ECG data by leveraging the callback structure of signal_t. get_data() will only ask for 2 seconds of samples on each invocation, so if you block (either via RTOS sleep or a while loop on bare metal) while waiting for each 2 seconds of PPG or ECG data, you can avoid allocating the entire input window. Note also that the SDK does not internally buffer the entire window; each 2 seconds is immediately processed down to IBIs.

// Callback: fill a section of the out_ptr buffer when requested
static int get_signal_data(size_t offset, size_t length, float *out_ptr) {
    // Zephyr RTOS, for instance
    k_sem_take(&ppg_2s_data_ready_sem, K_FOREVER);
    for (size_t i = 0; i < length; i++) {
        out_ptr[i] = ppg_buffer[i]; // don't need offset b/c we're filling in realtime
    }
    k_sem_give(&ppg_2s_data_ready_sem);

    return EIDSP_OK;
}

Conclusion

The HR/HRV Features block enables real-time extraction of key metrics such as heart rate and heart rate variability from physiological signals like PPG or ECG. These metrics are critical for applications in fitness tracking, stress detection, and medical diagnostics. To go further, follow our step-by-step guides in the tutorials section.

Processing PPG input with HR/HRV Features Block
HR/HRV features processing block configuration
HR/HRV features processing block impulse configuration
HR/HRV features processing block parameters