Cr-feat window length for all empaticas sensors.

sociality-task
= 2022-04-12 14:00:44 +00:00
parent 1c42347b9b
commit 74cf4ada1c
5 changed files with 105 additions and 50 deletions

View File

@ -477,10 +477,10 @@ EMPATICA_ACCELEROMETER:
CONTAINER: ACC
PROVIDERS:
DBDP:
COMPUTE: True
COMPUTE: False
FEATURES: ["maxmagnitude", "minmagnitude", "avgmagnitude", "medianmagnitude", "stdmagnitude"]
SRC_SCRIPT: src/features/empatica_accelerometer/dbdp/main.py
CF:
CR:
COMPUTE: True
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
"meanLow", "areaLow", "totalAbsoluteAreaBand", "totalMagnitudeBand", "entropyBand", "skewnessBand", "kurtosisBand",
@ -490,7 +490,10 @@ EMPATICA_ACCELEROMETER:
"peaksDataLow", "sumPerComponentBand", "velocityBand", "meanKineticEnergyBand", "totalKineticEnergyBand", "squareSumOfComponent",
"sumOfSquareComponents", "averageVectorLength", "averageVectorLengthPower", "rollAvgLow", "pitchAvgLow", "rollStdDevLow",
"pitchStdDevLow", "rollMotionAmountLow", "rollMotionRegularityLow", "manipulationLow", "rollPeaks", "pitchPeaks", "rollPitchCorrelation"] # Acc features
SRC_SCRIPT: src/features/empatica_accelerometer/cf/main.py
WINDOWS:
COMPUTE: False
WINDOW_LENGTH: 10 # specify window length in seconds
SRC_SCRIPT: src/features/empatica_accelerometer/cr/main.py
# See https://www.rapids.science/latest/features/empatica-heartrate/
@ -507,48 +510,57 @@ EMPATICA_TEMPERATURE:
CONTAINER: TEMP
PROVIDERS:
DBDP:
COMPUTE: True
COMPUTE: False
FEATURES: ["maxtemp", "mintemp", "avgtemp", "mediantemp", "modetemp", "stdtemp", "diffmaxmodetemp", "diffminmodetemp", "entropytemp"]
SRC_SCRIPT: src/features/empatica_temperature/dbdp/main.py
CF:
CR:
COMPUTE: True
FEATURES: ["autocorrelations", "countAboveMean", "countBelowMean", "maximum", "minimum", "meanAbsChange", "longestStrikeAboveMean",
"longestStrikeBelowMean", "stdDev", "median", "meanChange", "numberOfZeroCrossings", "absEnergy", "linearTrendSlope",
"ratioBeyondRSigma", "binnedEntropy", "numOfPeaksAutocorr", "numberOfZeroCrossingsAutocorr", "areaAutocorr",
"calcMeanCrossingRateAutocorr", "countAboveMeanAutocorr", "sumPer", "sumSquared", "squareSumOfComponent",
"sumOfSquareComponents"]
SRC_SCRIPT: src/features/empatica_temperature/cf/main.py
WINDOWS:
COMPUTE: False
WINDOW_LENGTH: 90 # specify window length in seconds
SRC_SCRIPT: src/features/empatica_temperature/cr/main.py
# See https://www.rapids.science/latest/features/empatica-electrodermal-activity/
EMPATICA_ELECTRODERMAL_ACTIVITY:
CONTAINER: EDA
PROVIDERS:
DBDP:
COMPUTE: True
COMPUTE: False
FEATURES: ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda", "diffminmodeeda", "entropyeda"]
SRC_SCRIPT: src/features/empatica_electrodermal_activity/dbdp/main.py
CF:
CR:
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',
'avgPeakIncreaseTime', 'avgPeakDecreaseTime', 'avgPeakDuration', 'maxPeakResponseSlopeBefore', 'maxPeakResponseSlopeAfter',
'signalOverallChange', 'changeDuration', 'changeRate', 'significantIncrease', 'significantDecrease']
SRC_SCRIPT: src/features/empatica_electrodermal_activity/cf/main.py
WINDOWS:
COMPUTE: False
WINDOW_LENGTH: 80 # specify window length in seconds
SRC_SCRIPT: src/features/empatica_electrodermal_activity/cr/main.py
# See https://www.rapids.science/latest/features/empatica-blood-volume-pulse/
EMPATICA_BLOOD_VOLUME_PULSE:
CONTAINER: BVP
PROVIDERS:
DBDP:
COMPUTE: True
COMPUTE: False
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
"maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"] # HRV features
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py
CF:
CR:
COMPUTE: True
FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR']
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/cf/main.py
WINDOWS:
COMPUTE: False
WINDOW_LENGTH: 4 # specify window length in seconds
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/cr/main.py
# See https://www.rapids.science/latest/features/empatica-inter-beat-interval/
EMPATICA_INTER_BEAT_INTERVAL:

View File

@ -14,7 +14,7 @@ def getSampleRate(data):
return 1000/timestamps_diff
def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment, filter_data_by_segment):
def extractAccFeaturesFromIntradayData(acc_intraday_data, features, window_length, time_segment, filter_data_by_segment):
acc_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
if not acc_intraday_data.empty:
@ -27,12 +27,20 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
acc_intraday_features = pd.DataFrame()
# apply methods from calculate features module
acc_intraday_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))
if window_length is None:
acc_intraday_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))
else:
acc_intraday_features = \
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
convertInputInto2d(x['double_values_0'], window_length*int(sample_rate)), \
convertInputInto2d(x['double_values_1'], window_length*int(sample_rate)), \
convertInputInto2d(x['double_values_2'], window_length*int(sample_rate)), \
fs=int(sample_rate), featureNames=features))
acc_intraday_features.reset_index(inplace=True)
@ -40,18 +48,23 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
acc_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
requested_intraday_features = provider["FEATURES"]
if provider["WINDOWS"]["COMPUTE"]:
requested_window_length = provider["WINDOWS"]["WINDOW_LENGTH"]
else:
requested_window_length = None
# name of the features this function can compute
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))
# extract features from intraday data
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data,
intraday_features_to_compute, time_segment,
filter_data_by_segment)
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data, intraday_features_to_compute,
requested_window_length, time_segment, filter_data_by_segment)
return acc_intraday_features

View File

@ -15,7 +15,7 @@ def getSampleRate(data):
return 1000/timestamps_diff
def extractBVPFeaturesFromIntradayData(bvp_intraday_data, features, time_segment, filter_data_by_segment):
def extractBVPFeaturesFromIntradayData(bvp_intraday_data, features, window_length, time_segment, filter_data_by_segment):
bvp_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
if not bvp_intraday_data.empty:
@ -28,27 +28,37 @@ def extractBVPFeaturesFromIntradayData(bvp_intraday_data, features, time_segment
bvp_intraday_features = pd.DataFrame()
# apply methods from calculate features module
bvp_intraday_features = \
bvp_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['blood_volume_pulse'], x.shape[0]), fs=int(sample_rate), featureNames=features))
if window_length is None:
bvp_intraday_features = \
bvp_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['blood_volume_pulse'], x.shape[0]), fs=int(sample_rate), featureNames=features))
else:
bvp_intraday_features = \
bvp_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['blood_volume_pulse'], window_length*int(sample_rate)), fs=int(sample_rate), featureNames=features))
bvp_intraday_features.reset_index(inplace=True)
return bvp_intraday_features
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
bvp_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
requested_intraday_features = provider["FEATURES"]
if provider["WINDOWS"]["COMPUTE"]:
requested_window_length = provider["WINDOWS"]["WINDOW_LENGTH"]
else:
requested_window_length = None
# name of the features this function can compute
base_intraday_features_names = hrvFeatureNames + frequencyFeatureNames
# the subset of requested features this function can compute
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
# extract features from intraday data
bvp_intraday_features = extractBVPFeaturesFromIntradayData(bvp_intraday_data,
intraday_features_to_compute, time_segment,
filter_data_by_segment)
bvp_intraday_features = extractBVPFeaturesFromIntradayData(bvp_intraday_data, intraday_features_to_compute,
requested_window_length, time_segment, filter_data_by_segment)
return bvp_intraday_features

View File

@ -13,7 +13,7 @@ def getSampleRate(data):
return 1000/timestamps_diff
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment, filter_data_by_segment):
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, window_length, time_segment, filter_data_by_segment):
eda_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
if not eda_intraday_data.empty:
@ -26,27 +26,38 @@ def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment
eda_intraday_features = pd.DataFrame()
# 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=int(sample_rate), featureNames=features))
if window_length is None:
eda_intraday_features = \
eda_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], x.shape[0]), fs=int(sample_rate), featureNames=features))
else:
eda_intraday_features = \
eda_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], window_length*int(sample_rate)), fs=int(sample_rate), featureNames=features))
eda_intraday_features.reset_index(inplace=True)
return eda_intraday_features
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
def cr_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"]
if provider["WINDOWS"]["COMPUTE"]:
requested_window_length = provider["WINDOWS"]["WINDOW_LENGTH"]
else:
requested_window_length = None
# name of the features this function can compute
base_intraday_features_names = gsrFeatureNames
# the subset of requested features this function can compute
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
# extract features from intraday data
eda_intraday_features = extractEDAFeaturesFromIntradayData(eda_intraday_data,
intraday_features_to_compute, time_segment,
filter_data_by_segment)
eda_intraday_features = extractEDAFeaturesFromIntradayData(eda_intraday_data, intraday_features_to_compute,
requested_window_length, time_segment, filter_data_by_segment)
return eda_intraday_features

View File

@ -4,6 +4,7 @@ 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:
@ -13,7 +14,7 @@ def getSampleRate(data):
return 1000/timestamps_diff
def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, time_segment, filter_data_by_segment):
def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, window_length, time_segment, filter_data_by_segment):
temperature_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
if not temperature_intraday_data.empty:
@ -26,27 +27,35 @@ def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, tim
temperature_intraday_features = pd.DataFrame()
# 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=int(sample_rate), featureNames=features))
if window_length is None:
temperature_intraday_features = \
temperature_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], x.shape[0]), fs=int(sample_rate), featureNames=features))
else:
temperature_intraday_features = \
temperature_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], window_length*int(sample_rate)), fs=int(sample_rate), featureNames=features))
temperature_intraday_features.reset_index(inplace=True)
return temperature_intraday_features
def cf_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs):
temperature_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
requested_intraday_features = provider["FEATURES"]
if provider["WINDOWS"]["COMPUTE"]:
requested_window_length = provider["WINDOWS"]["WINDOW_LENGTH"]
else:
requested_window_length = None
# name of the features this function can compute
base_intraday_features_names = genericFeatureNames
# the subset of requested features this function can compute
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
# extract features from intraday data
temperature_intraday_features = extractTempFeaturesFromIntradayData(temperature_intraday_data,
intraday_features_to_compute, time_segment,
filter_data_by_segment)
temperature_intraday_features = extractTempFeaturesFromIntradayData(temperature_intraday_data, intraday_features_to_compute,
requested_window_length, time_segment, filter_data_by_segment)
return temperature_intraday_features