Get a sample rate from two sequential timestamps.
parent
393dab72f5
commit
ca59a54d8f
|
@ -7,11 +7,20 @@ from CalculatingFeatures.calculate_features import calculateFeatures
|
|||
pd.set_option('display.max_columns', None)
|
||||
|
||||
|
||||
def getSampleRate(data):
|
||||
try:
|
||||
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
|
||||
except:
|
||||
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
|
||||
|
||||
return 1000/timestamps_diff
|
||||
|
||||
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment, filter_data_by_segment):
|
||||
eda_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||
|
||||
if not eda_intraday_data.empty:
|
||||
if not eda_intraday_data.empty:
|
||||
sample_rate = getSampleRate(eda_intraday_data)
|
||||
|
||||
eda_intraday_data = filter_data_by_segment(eda_intraday_data, time_segment)
|
||||
|
||||
if not eda_intraday_data.empty:
|
||||
|
@ -21,7 +30,7 @@ def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment
|
|||
# apply methods from calculate features module
|
||||
eda_intraday_features = \
|
||||
eda_intraday_data.groupby('local_segment').apply(\
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], x.shape[0]), fs=4, featureNames=features))
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], x.shape[0]), fs=sample_rate, featureNames=features)) # To-Do: Hardcoded f/s ...
|
||||
|
||||
eda_intraday_features.reset_index(inplace=True)
|
||||
|
||||
|
|
|
@ -4,13 +4,21 @@ from scipy.stats import entropy
|
|||
from CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, genericFeatureNames
|
||||
from CalculatingFeatures.calculate_features import calculateFeatures
|
||||
|
||||
import sys
|
||||
|
||||
def getSampleRate(data):
|
||||
try:
|
||||
timestamps_diff = data['timestamp'].iloc[1] - data['timestamp'].iloc[0]
|
||||
except:
|
||||
raise Exception("Error occured while trying to get the sample rate from the first two sequential timestamps.")
|
||||
|
||||
return 1000/timestamps_diff
|
||||
|
||||
def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, time_segment, filter_data_by_segment):
|
||||
temperature_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||
|
||||
if not temperature_intraday_data.empty:
|
||||
if not temperature_intraday_data.empty:
|
||||
sample_rate = getSampleRate(temperature_intraday_data)
|
||||
|
||||
temperature_intraday_data = filter_data_by_segment(temperature_intraday_data, time_segment)
|
||||
|
||||
if not temperature_intraday_data.empty:
|
||||
|
@ -20,7 +28,7 @@ def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, tim
|
|||
# apply methods from calculate features module
|
||||
temperature_intraday_features = \
|
||||
temperature_intraday_data.groupby('local_segment').apply(\
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], x.shape[0]), fs=4, featureNames=features))
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], x.shape[0]), fs=sample_rate, featureNames=features)) # To-Do: Hardcoded f/s ...
|
||||
|
||||
temperature_intraday_features.reset_index(inplace=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue