Skip to content

calculate_vitals

Calculate Vitals

Calculate vital signs from the blood volume pulse (BVP) signal.

Parameters:

Name Type Description Default
bvp list

List of BVP signal values.

required
fps int

Frames per second of the BVP signal.

required
trim bool

Whether to trim the signal. Defaults to False.

False
outliers_removal bool

Whether to remove outliers from the calculated NNI. Defaults to False.

False
replace_median bool

Whether to replace outliers with the median value. Defaults to False.

False

Returns:

Name Type Description
list

A list containing the heart rate (HR), HRV estimates dictionary, and peaks indices.

Source code in redesign_pipeline/vital_calculations/calculate_vitals.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def calculate_vitals(bvp,fps,trim=False,outliers_removal=False,replace_median=False):
    """
    Calculate vital signs from the blood volume pulse (BVP) signal.

    Args:
        bvp (list): List of BVP signal values.
        fps (int): Frames per second of the BVP signal.
        trim (bool, optional): Whether to trim the signal. Defaults to False.
        outliers_removal (bool, optional): Whether to remove outliers from the calculated NNI. Defaults to False.
        replace_median (bool, optional): Whether to replace outliers with the median value. Defaults to False.

    Returns:
        list: A list containing the heart rate (HR), HRV estimates dictionary, and peaks indices.

    """

    hr = BVP_to_BPM(bvp, fps=fps)
    peaks_indices = multiple_peaks_finding(bvp,trim)
    nni = nni_from_peaks_indices(peaks_indices)
    if outliers_removal:
        nni = reject_outliers_multimodel(nni,replace_median=replace_median)
    hrv_dict = get_hrv_estimates(nni, fps, freq=True)

    return [hr,hrv_dict,peaks_indices]