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
  • Understanding HR and HRV
  • Heart Rate (HR)
  • Heart Rate Variability (HRV)
  • Prerequisites
  • Step-by-Step Guide
  • Step 1: Prepare or Collect Your Time-Series Data
  • Step 2: Upload Data to Edge Impulse
  • Step 3: Create an Impulse for HR/HRV Processing
  • Step 4: Add the HR/HRV Block
  • Step 5: Generate Features
  • Step 6: Configure the Regression Block
  • Step 7: Test and Validate the Model
  • Step 8: Deploy the Model (Enterprise Only)
  • Conclusion
  • Additional Resources

Was this helpful?

Export as PDF
  1. Tutorials
  2. End-to-end tutorials
  3. Time-series

HR/HRV

PreviousRegression + anomaly detectionNextEnvironmental (Sensor fusion)

Last updated 17 days ago

Was this helpful?

In this tutorial, you'll learn how to set up the HR/HRV Features block within Edge Impulse Studio to process your physiological data and extract meaningful heart rate (HR) and heart rate variability (HRV) features. These features can be leveraged in various downstream machine learning tasks, such as activity classification, stress detection, and health monitoring. We will extend this section over time with more examples.

For this guide, we will be using a subset of the publicly available PPG-DaLiA dataset, which contains data collected from 15 subjects during daily activities. This dataset includes physiological signals such as photoplethysmography (PPG), accelerometer data, and heart rate ground truth, allowing us to explore how the HR/HRV Features block can be applied to real-world data.

You can download the DaLIA-PPG dataset or clone the project S1_E4 from the links below:

Evaluation available for everyone, deployment only available to Enterprise plan

All users (developer and enterprise) can extract HR/HRV features using this processing block for testing purposes. However, the deployment option is only available for Enterprise users. Contact your Solution Engineer to enable it.

Understanding HR and HRV

Heart Rate (HR)

Heart Rate refers to the number of times your heart beats per minute (BPM). It's a straightforward metric that indicates your cardiac activity and is influenced by factors like physical activity, stress, and overall health.

Heart Rate Variability (HRV)

Heart Rate Variability measures the variation in time intervals between successive heartbeats, known as interbeat intervals (IBIs). HRV provides deeper insights into the autonomic nervous system's regulation of the heart, reflecting your body's ability to adapt to stress, recover, and maintain homeostasis.

Key HRV Metrics:

  • RMSSD (Root Mean Square of Successive Differences): Reflects short-term HRV and parasympathetic activity.

  • SDNN (Standard Deviation of NN intervals): Indicates overall HRV.

  • pNN50: Percentage of intervals differing by more than 50 ms, another measure of parasympathetic activity.

Understanding both HR and HRV can provide a comprehensive view of an individual's cardiovascular and autonomic health.

Prerequisites

  • Physiological Data: You can download a subset of PPG-DaLIA the DaLIA-PPG dataset S1_E4:

Step-by-Step Guide

Step 1: Prepare or Collect Your Time-Series Data

Ensure your CSV file is structured with the following columns:

  • Time: The timestamp for each data point.

  • X, Y, Z: Accelerometer data for motion artifact compensation (optional).

  • ECG/PPG: The PPG or ECG signal for heart rate estimation.

  • HR: Heart rate value, if available (should be uploaded as a multi-label sample for regression).

  • Label: The activity label (optional but useful for classification tasks).

HR Calculation: Avoid uploading data in short snippets. HR calculation relies on history and feedback to accumulate a continuous stream for better calculation and smoothing. Upload long, contiguous data for the most accurate results.

Developer plan users need to use single label and should keep the length to 2 seconds for the best accuracy.

You can download a subset of the PPG-DaLIA dataset S1_E4:

Click to view a sample CSV file structure for HR/HRV data
Time,acc_x,acc_y,acc_z,ppg,eda,temp,hr,activity,activity_label,Subject
2018-06-29 08:44:52.000000,-27,1,58,-0.0,0.0,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.031250,-27,2,59,-0.0,0.0,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.062500,-27,1,59,-0.0,0.0,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.093750,-27,1,58,-0.0,0.0,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.125000,-27,1,59,-0.0,0.0,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.156250,-27,1,59,0.0,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.187500,-27,1,59,0.01,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.218750,-27,1,58,-0.03,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.250000,-27,1,58,-0.05,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.281250,-27,1,59,0.13,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.312500,-27,1,59,0.66,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.343750,-27,1,59,1.37,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.375000,-27,1,59,2.06,0.832765,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.406250,-27,1,59,2.79,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.437500,-27,1,58,3.8,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.468750,-27,1,59,5.06,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.500000,-27,1,58,6.2,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.531250,-27,1,59,7.15,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.562500,-27,1,59,8.31,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.593750,-27,1,59,10.09,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.625000,-27,1,59,11.88,1.180231,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.656250,-27,2,59,13.14,1.618462,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.687500,-27,1,59,14.65,1.618462,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.718750,-27,1,59,17.91,1.618462,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.750000,-27,1,58,22.9,1.618462,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
2018-06-29 08:44:52.781250,-27,1,59,27.58,1.618462,32.15,76.0,NO_ACTIVITY,NO_ACTIVITY,Subject_1
...
Download the CSV here

Step 2: Upload Data to Edge Impulse

  1. Log into your Edge Impulse Studio.

  2. Navigate to Data Acquisition in the left-hand panel.

  3. Click Upload Data and select your CSV file for each subject.

  4. Ensure that the data is correctly parsed, and assign appropriate labels for heartrate applicable (e.g., 100, 90, etc.).

Step 3: Create an Impulse for HR/HRV Processing

  1. Go to Impulse Design > Create Impulse.

  2. Add a HR and HRV Features block:

    • Input Axes: Select accX, accY, accZ, PPG (if using accelerometer data for motion artifact correction).

    • Set Window Size to 2000 ms.

    • Set Frequency (Hz) to 25 Hz (tolerance +/- 1 Hz) or 50 Hz (tolerance +/- 3 Hz).

Step 4: Add the HR/HRV Block

  1. Under Impulse Design, add the HR/HRV Features block.

  • Input Axes: Select your PPG signal for HR estimation.

  • HR Window Size: Set the window size for heart rate computation (e.g., 9 seconds, and no shorter than 2 seconds).

  • HRV Settings: Enable all HRV features to see RMSSD and other params.

  • Input Axes: Select your ECG signal for HR estimation.

  • HR Window Size: Set the window size for heart rate computation (e.g., 10 seconds and upwards of 90 seconds for best accuracy).

  • HRV Settings: Enable HRV features such as RMSSD or time-series statistics.

  • Input Axes: Select your PPG signal for HR estimation.

  • Accelerometer X, Y, Z: Include these axes to filter motion artifacts.

  • HR Window Size: Set the window size for heart rate computation (e.g., 10 seconds).

  • HRV Settings: Enable HRV features such as RMSSD or time-series statistics.

Step 5: Generate Features

  1. Click on Generate Features from the top menu.

  2. Review the feature generation output to ensure that the raw signals are correctly processed.

  3. Edge Impulse will generate the features for both heart rate and HRV over the specified window size.

Step 6: Configure the Regression Block

  1. Add a Learning Block such as a Regression if you wish to estimate HR

  2. Ensure that HR/HRV is selected as the input feature.

  3. Train the model using your labeled data to predict different heart rate.

Step 7: Test and Validate the Model

  1. After training, use Model Testing to evaluate the performance of your HR/HRV feature extraction and heart rate prediction model.

  2. Upload test data to ensure that the heart rate is correctly estimated and any HRV features are extracted as expected.

Step 8: Deploy the Model (Enterprise Only)

For enterprise users, you can deploy the model to your target device and start collecting real-time heart rate and HRV data. When the model is trained and validated, you can deploy it to your target device or C++ binary for real-time heart rate and HRV monitoring.

Deployment will look as follows:

To include heart rate extraction alongside your classifier results, define the following macro in your deployment:

#if EI_DSP_ENABLE_RUNTIME_HR == 1
    ei_impulse_result_hr_t hr_calcs;
#endif

This macro will enable the HR/HRV Features block to calculate heart rate and HRV features in real-time.

typedef struct {
    float heart_rate;  // The calculated heart rate in beats per minute (BPM)
} ei_impulse_result_hr_t;

Conclusion

By following this tutorial, you've successfully set up the HR/HRV Features block in Edge Impulse Studio, extracted meaningful cardiovascular features, and optionally trained a machine learning model. This foundation enables you to build robust, real-time heart rate and HRV monitoring solutions for applications like health monitoring, stress detection, and fitness tracking.

Additional Resources

Read on in the or speak with your enterprise support team for more guidance.

For Developer plan users, the deployment option is not available, contact our sales team if you want to upgrade to an :

Edge Impulse Documentation:

If you have any questions or need further assistance, feel free to reach out on the or consult the documentation.

Public Project
Download CSV
HR/HRV Features block documentation for more deployment details
Enterprise plan
HR/HRV Features
Edge Impulse Forum
DaLIA-PPG Public Project
Illustration of deriving HRV data from ECG and PPG signals, (a) RR intervals in the ECG signal, and (b) PP intervals in the PPG signal. N.U.: Normalised units.
Data Upload
Create Impulse
PPG HR-HRV Settings
ECG HR-HRV Settings
PPG + Accelerometer HR-HRV Settings
HR-HRV Block Generate Features
Regression Block Configuration
HR-HRV Test Classification
HR-HRV Enterprise Deployment
HR-HRV Deployment