Added ACC calculated features and shorter version of ACC data.
parent
a9244a60fc
commit
ab0b9227d7
14
config.yaml
14
config.yaml
|
@ -482,13 +482,14 @@ EMPATICA_ACCELEROMETER:
|
|||
SRC_SCRIPT: src/features/empatica_accelerometer/dbdp/main.py
|
||||
CF:
|
||||
COMPUTE: True
|
||||
FEATURES: ["meanLow", "areaLow", "totalAbsoluteAreaBand", "totalMagnitudeBand", "entropyBand", "skewnessBand", "kurtosisBand",
|
||||
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
|
||||
"meanLow", "areaLow", "totalAbsoluteAreaBand", "totalMagnitudeBand", "entropyBand", "skewnessBand", "kurtosisBand",
|
||||
"postureDistanceLow", "absoluteMeanBand", "absoluteAreaBand", "quartilesBand", "interQuartileRangeBand", "varianceBand",
|
||||
"coefficientOfVariationBand", "amplitudeBand", "totalEnergyBand", "dominantFrequencyEnergyBand", "meanCrossingRateBand",
|
||||
"correlationBand", "quartilesMagnitudesBand", "interQuartileRangeMagnitudesBand", "areaUnderAccelerationMagnitude",
|
||||
"peaksDataLow", "sumPerComponentBand", "velocityBand", "meanKineticEnergyBand", "totalKineticEnergyBand", "squareSumOfComponent",
|
||||
"sumOfSquareComponents", "averageVectorLength", "averageVectorLengthPower", "rollAvgLow", "pitchAvgLow", "rollStdDevLow",
|
||||
"pitchStdDevLow", "rollMotionAmountLow", "rollMotionRegularityLow", "manipulationLow", "rollPeaks", "pitchPeaks", "rollPitchCorrelation"]
|
||||
"pitchStdDevLow", "rollMotionAmountLow", "rollMotionRegularityLow", "manipulationLow", "rollPeaks", "pitchPeaks", "rollPitchCorrelation"] # Acc features
|
||||
SRC_SCRIPT: src/features/empatica_accelerometer/cf/main.py
|
||||
|
||||
|
||||
|
@ -506,11 +507,11 @@ EMPATICA_TEMPERATURE:
|
|||
CONTAINER: TEMP
|
||||
PROVIDERS:
|
||||
DBDP:
|
||||
COMPUTE: False
|
||||
COMPUTE: True
|
||||
FEATURES: ["maxtemp", "mintemp", "avgtemp", "mediantemp", "modetemp", "stdtemp", "diffmaxmodetemp", "diffminmodetemp", "entropytemp"]
|
||||
SRC_SCRIPT: src/features/empatica_temperature/dbdp/main.py
|
||||
CF:
|
||||
COMPUTE: False
|
||||
COMPUTE: True
|
||||
FEATURES: ["autocorrelations", "countAboveMean", "countBelowMean", "maximum", "minimum", "meanAbsChange", "longestStrikeAboveMean",
|
||||
"longestStrikeBelowMean", "stdDev", "median", "meanChange", "numberOfZeroCrossings", "absEnergy", "linearTrendSlope",
|
||||
"ratioBeyondRSigma", "binnedEntropy", "numOfPeaksAutocorr", "numberOfZeroCrossingsAutocorr", "areaAutocorr",
|
||||
|
@ -523,11 +524,11 @@ EMPATICA_ELECTRODERMAL_ACTIVITY:
|
|||
CONTAINER: EDA
|
||||
PROVIDERS:
|
||||
DBDP:
|
||||
COMPUTE: False
|
||||
COMPUTE: True
|
||||
FEATURES: ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda", "diffminmodeeda", "entropyeda"]
|
||||
SRC_SCRIPT: src/features/empatica_electrodermal_activity/dbdp/main.py
|
||||
CF:
|
||||
COMPUTE: False
|
||||
COMPUTE: True
|
||||
FEATURES: ['mean', 'std', 'q25', 'q75', 'qd', 'deriv', 'power', 'numPeaks', 'ratePeaks', 'powerPeaks', 'sumPosDeriv', 'propPosDeriv', 'derivTonic',
|
||||
'sigTonicDifference', 'freqFeats','maxPeakAmplitudeChangeBefore', 'maxPeakAmplitudeChangeAfter', 'avgPeakAmplitudeChangeBefore',
|
||||
'avgPeakAmplitudeChangeAfter', 'avgPeakChangeRatio', 'maxPeakIncreaseTime', 'maxPeakDecreaseTime', 'maxPeakDuration', 'maxPeakChangeRatio',
|
||||
|
@ -559,6 +560,7 @@ EMPATICA_TAGS:
|
|||
PROVIDERS: # None implemented yet
|
||||
|
||||
|
||||
|
||||
########################################################################################################################
|
||||
# PLOTS #
|
||||
########################################################################################################################
|
||||
|
|
Binary file not shown.
|
@ -1,9 +1,10 @@
|
|||
import pandas as pd
|
||||
from scipy.stats import entropy
|
||||
|
||||
from CalculatingFeatures.helper_functions import convert3DEmpaticaToArray, convertInputInto2d, gsrFeatureNames
|
||||
from CalculatingFeatures.helper_functions import convert3DEmpaticaToArray, convertInputInto2d, accelerometerFeatureNames, frequencyFeatureNames
|
||||
from CalculatingFeatures.calculate_features import calculateFeatures
|
||||
|
||||
import sys
|
||||
|
||||
def getSampleRate(data):
|
||||
try:
|
||||
|
@ -17,7 +18,7 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
|
|||
acc_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||
|
||||
if not acc_intraday_data.empty:
|
||||
sample_rate = getSampleRate(acc_intraday_data)
|
||||
sample_rate = getSampleRate(acc_intraday_data)
|
||||
|
||||
acc_intraday_data = filter_data_by_segment(acc_intraday_data, time_segment)
|
||||
|
||||
|
@ -27,20 +28,24 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
|
|||
|
||||
# apply methods from calculate features module
|
||||
acc_intraday_features = \
|
||||
acc_intraday_data.groupby('local_segment').apply(\
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['accelerometer'], x.shape[0]), fs=sample_rate, featureNames=features))
|
||||
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
|
||||
convertInputInto2d(x['double_values_0'], x.shape[0]), \
|
||||
convertInputInto2d(x['double_values_1'], x.shape[0]), \
|
||||
convertInputInto2d(x['double_values_2'], x.shape[0]), \
|
||||
fs=int(sample_rate), featureNames=features))
|
||||
|
||||
acc_intraday_features.reset_index(inplace=True)
|
||||
|
||||
return acc_intraday_features
|
||||
|
||||
|
||||
|
||||
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
|
||||
eda_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||
|
||||
requested_intraday_features = provider["FEATURES"]
|
||||
# name of the features this function can compute
|
||||
base_intraday_features_names = gsrFeatureNames
|
||||
base_intraday_features_names = accelerometerFeatureNames + frequencyFeatureNames
|
||||
# the subset of requested features this function can compute
|
||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||
|
||||
|
@ -49,38 +54,4 @@ def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
|
|||
intraday_features_to_compute, time_segment,
|
||||
filter_data_by_segment)
|
||||
|
||||
return eda_intraday_features
|
||||
|
||||
def dbdp_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
|
||||
|
||||
acc_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||
requested_features = provider["FEATURES"]
|
||||
# name of the features this function can compute
|
||||
base_features_names = ["maxmagnitude", "minmagnitude", "avgmagnitude", "medianmagnitude", "stdmagnitude"]
|
||||
# the subset of requested features this function can compute
|
||||
features_to_compute = list(set(requested_features) & set(base_features_names))
|
||||
|
||||
acc_features = pd.DataFrame(columns=["local_segment"] + features_to_compute)
|
||||
if not acc_data.empty:
|
||||
acc_data = filter_data_by_segment(acc_data, time_segment)
|
||||
|
||||
if not acc_data.empty:
|
||||
acc_features = pd.DataFrame()
|
||||
# get magnitude related features: magnitude = sqrt(x^2+y^2+z^2)
|
||||
magnitude = acc_data.apply(lambda row: np.sqrt(row["double_values_0"] ** 2 + row["double_values_1"] ** 2 + row["double_values_2"] ** 2), axis=1)
|
||||
acc_data = acc_data.assign(magnitude = magnitude.values)
|
||||
|
||||
if "maxmagnitude" in features_to_compute:
|
||||
acc_features["maxmagnitude"] = acc_data.groupby(["local_segment"])["magnitude"].max()
|
||||
if "minmagnitude" in features_to_compute:
|
||||
acc_features["minmagnitude"] = acc_data.groupby(["local_segment"])["magnitude"].min()
|
||||
if "avgmagnitude" in features_to_compute:
|
||||
acc_features["avgmagnitude"] = acc_data.groupby(["local_segment"])["magnitude"].mean()
|
||||
if "medianmagnitude" in features_to_compute:
|
||||
acc_features["medianmagnitude"] = acc_data.groupby(["local_segment"])["magnitude"].median()
|
||||
if "stdmagnitude" in features_to_compute:
|
||||
acc_features["stdmagnitude"] = acc_data.groupby(["local_segment"])["magnitude"].std()
|
||||
|
||||
acc_features = acc_features.reset_index()
|
||||
|
||||
return acc_features
|
||||
return eda_intraday_features
|
|
@ -1,7 +1,7 @@
|
|||
import pandas as pd
|
||||
from scipy.stats import entropy
|
||||
|
||||
from CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, gsrFeatureNames
|
||||
from CalculatingFeatures.helper_functions import convertInputInto2d, gsrFeatureNames
|
||||
from CalculatingFeatures.calculate_features import calculateFeatures
|
||||
|
||||
|
||||
|
@ -28,7 +28,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=sample_rate, featureNames=features))
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], x.shape[0]), fs=int(sample_rate), featureNames=features))
|
||||
|
||||
eda_intraday_features.reset_index(inplace=True)
|
||||
|
||||
|
|
|
@ -28,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=sample_rate, featureNames=features))
|
||||
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], x.shape[0]), fs=int(sample_rate), featureNames=features))
|
||||
|
||||
temperature_intraday_features.reset_index(inplace=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue