rapids/calculate_HR_features_test.py

24 lines
899 B
Python
Raw Normal View History

from calculatingfeatures.CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, frequencyFeatureNames, hrvFeatureNames
from calculatingfeatures.CalculatingFeatures.calculate_features import calculateFeatures
import pandas as pd
pathToHrvCsv = "calculatingfeatures/example_data/S2_E4_Data/BVP.csv"
windowLength = 500
# get an array of values from HRV empatica file
hrv_data, startTimeStamp, sampleRate = convert1DEmpaticaToArray(pathToHrvCsv)
# Convert the HRV data into 2D array
hrv_data_2D = convertInputInto2d(hrv_data, windowLength)
# Create a list with feature names
featureNames = []
featureNames.extend(hrvFeatureNames)
featureNames.extend(frequencyFeatureNames)
pd.set_option('display.max_columns', None)
# Calculate features
calculatedFeatures = calculateFeatures(hrv_data_2D, fs=int(sampleRate), featureNames=featureNames)
print(calculatedFeatures)