HR/HRV features
Last updated
Last updated
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: Processing PPG input with HR/HRV Features Block.
Evaluation available for everyone; deployment only available with Enterprise Plan
All users (Community, Professional, 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.
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.
When using the HR/HRV Features block, it is important to also configure the input block for your impulse appropriately.
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.
For optimal performance, it is recommended to set the window increase (stride) equal to the window size.
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).
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.
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.
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. |
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. |
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. |
HRV Features Group | Min. HRV Window Size (s) |
---|---|
| N/A |
| 10 |
| 30 |
| 90 |
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
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 |
| RMSSD |
| Time-domain |
| Time-domain and frequency-domain |
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).
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.
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.
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.
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.
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.
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.
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.