Cr-feat window length for all empaticas sensors.
parent
1c42347b9b
commit
74cf4ada1c
36
config.yaml
36
config.yaml
|
@ -477,10 +477,10 @@ EMPATICA_ACCELEROMETER:
|
||||||
CONTAINER: ACC
|
CONTAINER: ACC
|
||||||
PROVIDERS:
|
PROVIDERS:
|
||||||
DBDP:
|
DBDP:
|
||||||
COMPUTE: True
|
COMPUTE: False
|
||||||
FEATURES: ["maxmagnitude", "minmagnitude", "avgmagnitude", "medianmagnitude", "stdmagnitude"]
|
FEATURES: ["maxmagnitude", "minmagnitude", "avgmagnitude", "medianmagnitude", "stdmagnitude"]
|
||||||
SRC_SCRIPT: src/features/empatica_accelerometer/dbdp/main.py
|
SRC_SCRIPT: src/features/empatica_accelerometer/dbdp/main.py
|
||||||
CF:
|
CR:
|
||||||
COMPUTE: True
|
COMPUTE: True
|
||||||
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
|
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
|
||||||
"meanLow", "areaLow", "totalAbsoluteAreaBand", "totalMagnitudeBand", "entropyBand", "skewnessBand", "kurtosisBand",
|
"meanLow", "areaLow", "totalAbsoluteAreaBand", "totalMagnitudeBand", "entropyBand", "skewnessBand", "kurtosisBand",
|
||||||
|
@ -490,7 +490,10 @@ EMPATICA_ACCELEROMETER:
|
||||||
"peaksDataLow", "sumPerComponentBand", "velocityBand", "meanKineticEnergyBand", "totalKineticEnergyBand", "squareSumOfComponent",
|
"peaksDataLow", "sumPerComponentBand", "velocityBand", "meanKineticEnergyBand", "totalKineticEnergyBand", "squareSumOfComponent",
|
||||||
"sumOfSquareComponents", "averageVectorLength", "averageVectorLengthPower", "rollAvgLow", "pitchAvgLow", "rollStdDevLow",
|
"sumOfSquareComponents", "averageVectorLength", "averageVectorLengthPower", "rollAvgLow", "pitchAvgLow", "rollStdDevLow",
|
||||||
"pitchStdDevLow", "rollMotionAmountLow", "rollMotionRegularityLow", "manipulationLow", "rollPeaks", "pitchPeaks", "rollPitchCorrelation"] # Acc features
|
"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/
|
# See https://www.rapids.science/latest/features/empatica-heartrate/
|
||||||
|
@ -507,48 +510,57 @@ EMPATICA_TEMPERATURE:
|
||||||
CONTAINER: TEMP
|
CONTAINER: TEMP
|
||||||
PROVIDERS:
|
PROVIDERS:
|
||||||
DBDP:
|
DBDP:
|
||||||
COMPUTE: True
|
COMPUTE: False
|
||||||
FEATURES: ["maxtemp", "mintemp", "avgtemp", "mediantemp", "modetemp", "stdtemp", "diffmaxmodetemp", "diffminmodetemp", "entropytemp"]
|
FEATURES: ["maxtemp", "mintemp", "avgtemp", "mediantemp", "modetemp", "stdtemp", "diffmaxmodetemp", "diffminmodetemp", "entropytemp"]
|
||||||
SRC_SCRIPT: src/features/empatica_temperature/dbdp/main.py
|
SRC_SCRIPT: src/features/empatica_temperature/dbdp/main.py
|
||||||
CF:
|
CR:
|
||||||
COMPUTE: True
|
COMPUTE: True
|
||||||
FEATURES: ["autocorrelations", "countAboveMean", "countBelowMean", "maximum", "minimum", "meanAbsChange", "longestStrikeAboveMean",
|
FEATURES: ["autocorrelations", "countAboveMean", "countBelowMean", "maximum", "minimum", "meanAbsChange", "longestStrikeAboveMean",
|
||||||
"longestStrikeBelowMean", "stdDev", "median", "meanChange", "numberOfZeroCrossings", "absEnergy", "linearTrendSlope",
|
"longestStrikeBelowMean", "stdDev", "median", "meanChange", "numberOfZeroCrossings", "absEnergy", "linearTrendSlope",
|
||||||
"ratioBeyondRSigma", "binnedEntropy", "numOfPeaksAutocorr", "numberOfZeroCrossingsAutocorr", "areaAutocorr",
|
"ratioBeyondRSigma", "binnedEntropy", "numOfPeaksAutocorr", "numberOfZeroCrossingsAutocorr", "areaAutocorr",
|
||||||
"calcMeanCrossingRateAutocorr", "countAboveMeanAutocorr", "sumPer", "sumSquared", "squareSumOfComponent",
|
"calcMeanCrossingRateAutocorr", "countAboveMeanAutocorr", "sumPer", "sumSquared", "squareSumOfComponent",
|
||||||
"sumOfSquareComponents"]
|
"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/
|
# See https://www.rapids.science/latest/features/empatica-electrodermal-activity/
|
||||||
EMPATICA_ELECTRODERMAL_ACTIVITY:
|
EMPATICA_ELECTRODERMAL_ACTIVITY:
|
||||||
CONTAINER: EDA
|
CONTAINER: EDA
|
||||||
PROVIDERS:
|
PROVIDERS:
|
||||||
DBDP:
|
DBDP:
|
||||||
COMPUTE: True
|
COMPUTE: False
|
||||||
FEATURES: ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda", "diffminmodeeda", "entropyeda"]
|
FEATURES: ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda", "diffminmodeeda", "entropyeda"]
|
||||||
SRC_SCRIPT: src/features/empatica_electrodermal_activity/dbdp/main.py
|
SRC_SCRIPT: src/features/empatica_electrodermal_activity/dbdp/main.py
|
||||||
CF:
|
CR:
|
||||||
COMPUTE: True
|
COMPUTE: True
|
||||||
FEATURES: ['mean', 'std', 'q25', 'q75', 'qd', 'deriv', 'power', 'numPeaks', 'ratePeaks', 'powerPeaks', 'sumPosDeriv', 'propPosDeriv', 'derivTonic',
|
FEATURES: ['mean', 'std', 'q25', 'q75', 'qd', 'deriv', 'power', 'numPeaks', 'ratePeaks', 'powerPeaks', 'sumPosDeriv', 'propPosDeriv', 'derivTonic',
|
||||||
'sigTonicDifference', 'freqFeats','maxPeakAmplitudeChangeBefore', 'maxPeakAmplitudeChangeAfter', 'avgPeakAmplitudeChangeBefore',
|
'sigTonicDifference', 'freqFeats','maxPeakAmplitudeChangeBefore', 'maxPeakAmplitudeChangeAfter', 'avgPeakAmplitudeChangeBefore',
|
||||||
'avgPeakAmplitudeChangeAfter', 'avgPeakChangeRatio', 'maxPeakIncreaseTime', 'maxPeakDecreaseTime', 'maxPeakDuration', 'maxPeakChangeRatio',
|
'avgPeakAmplitudeChangeAfter', 'avgPeakChangeRatio', 'maxPeakIncreaseTime', 'maxPeakDecreaseTime', 'maxPeakDuration', 'maxPeakChangeRatio',
|
||||||
'avgPeakIncreaseTime', 'avgPeakDecreaseTime', 'avgPeakDuration', 'maxPeakResponseSlopeBefore', 'maxPeakResponseSlopeAfter',
|
'avgPeakIncreaseTime', 'avgPeakDecreaseTime', 'avgPeakDuration', 'maxPeakResponseSlopeBefore', 'maxPeakResponseSlopeAfter',
|
||||||
'signalOverallChange', 'changeDuration', 'changeRate', 'significantIncrease', 'significantDecrease']
|
'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/
|
# See https://www.rapids.science/latest/features/empatica-blood-volume-pulse/
|
||||||
EMPATICA_BLOOD_VOLUME_PULSE:
|
EMPATICA_BLOOD_VOLUME_PULSE:
|
||||||
CONTAINER: BVP
|
CONTAINER: BVP
|
||||||
PROVIDERS:
|
PROVIDERS:
|
||||||
DBDP:
|
DBDP:
|
||||||
COMPUTE: True
|
COMPUTE: False
|
||||||
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
|
FEATURES: ["fqHighestPeakFreqs", "fqHighestPeaks", "fqEnergyFeat", "fqEntropyFeat", "fqHistogramBins","fqAbsMean", "fqSkewness", "fqKurtosis", "fqInterquart", # Freq features
|
||||||
"maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"] # HRV features
|
"maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"] # HRV features
|
||||||
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py
|
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py
|
||||||
CF:
|
CR:
|
||||||
COMPUTE: True
|
COMPUTE: True
|
||||||
FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR']
|
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/
|
# See https://www.rapids.science/latest/features/empatica-inter-beat-interval/
|
||||||
EMPATICA_INTER_BEAT_INTERVAL:
|
EMPATICA_INTER_BEAT_INTERVAL:
|
||||||
|
|
|
@ -14,7 +14,7 @@ def getSampleRate(data):
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
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)
|
acc_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||||
|
|
||||||
if not acc_intraday_data.empty:
|
if not acc_intraday_data.empty:
|
||||||
|
@ -27,12 +27,20 @@ def extractAccFeaturesFromIntradayData(acc_intraday_data, features, time_segment
|
||||||
acc_intraday_features = pd.DataFrame()
|
acc_intraday_features = pd.DataFrame()
|
||||||
|
|
||||||
# apply methods from calculate features module
|
# apply methods from calculate features module
|
||||||
acc_intraday_features = \
|
if window_length is None:
|
||||||
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
|
acc_intraday_features = \
|
||||||
convertInputInto2d(x['double_values_0'], x.shape[0]), \
|
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
|
||||||
convertInputInto2d(x['double_values_1'], x.shape[0]), \
|
convertInputInto2d(x['double_values_0'], x.shape[0]), \
|
||||||
convertInputInto2d(x['double_values_2'], x.shape[0]), \
|
convertInputInto2d(x['double_values_1'], x.shape[0]), \
|
||||||
fs=int(sample_rate), featureNames=features))
|
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)
|
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"])
|
acc_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||||
|
|
||||||
requested_intraday_features = provider["FEATURES"]
|
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
|
# name of the features this function can compute
|
||||||
base_intraday_features_names = accelerometerFeatureNames + frequencyFeatureNames
|
base_intraday_features_names = accelerometerFeatureNames + frequencyFeatureNames
|
||||||
# the subset of requested features this function can compute
|
# the subset of requested features this function can compute
|
||||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||||
|
|
||||||
# extract features from intraday data
|
# extract features from intraday data
|
||||||
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data,
|
acc_intraday_features = extractAccFeaturesFromIntradayData(acc_intraday_data, intraday_features_to_compute,
|
||||||
intraday_features_to_compute, time_segment,
|
requested_window_length, time_segment, filter_data_by_segment)
|
||||||
filter_data_by_segment)
|
|
||||||
|
|
||||||
return acc_intraday_features
|
return acc_intraday_features
|
|
@ -15,7 +15,7 @@ def getSampleRate(data):
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
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)
|
bvp_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||||
|
|
||||||
if not bvp_intraday_data.empty:
|
if not bvp_intraday_data.empty:
|
||||||
|
@ -28,27 +28,37 @@ def extractBVPFeaturesFromIntradayData(bvp_intraday_data, features, time_segment
|
||||||
bvp_intraday_features = pd.DataFrame()
|
bvp_intraday_features = pd.DataFrame()
|
||||||
|
|
||||||
# apply methods from calculate features module
|
# apply methods from calculate features module
|
||||||
bvp_intraday_features = \
|
if window_length is None:
|
||||||
bvp_intraday_data.groupby('local_segment').apply(\
|
bvp_intraday_features = \
|
||||||
lambda x: calculateFeatures(convertInputInto2d(x['blood_volume_pulse'], x.shape[0]), fs=int(sample_rate), featureNames=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)
|
bvp_intraday_features.reset_index(inplace=True)
|
||||||
|
|
||||||
return bvp_intraday_features
|
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"])
|
bvp_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||||
|
|
||||||
requested_intraday_features = provider["FEATURES"]
|
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
|
# name of the features this function can compute
|
||||||
base_intraday_features_names = hrvFeatureNames + frequencyFeatureNames
|
base_intraday_features_names = hrvFeatureNames + frequencyFeatureNames
|
||||||
# the subset of requested features this function can compute
|
# the subset of requested features this function can compute
|
||||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||||
|
|
||||||
# extract features from intraday data
|
# extract features from intraday data
|
||||||
bvp_intraday_features = extractBVPFeaturesFromIntradayData(bvp_intraday_data,
|
bvp_intraday_features = extractBVPFeaturesFromIntradayData(bvp_intraday_data, intraday_features_to_compute,
|
||||||
intraday_features_to_compute, time_segment,
|
requested_window_length, time_segment, filter_data_by_segment)
|
||||||
filter_data_by_segment)
|
|
||||||
|
|
||||||
return bvp_intraday_features
|
return bvp_intraday_features
|
|
@ -13,7 +13,7 @@ def getSampleRate(data):
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
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)
|
eda_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||||
|
|
||||||
if not eda_intraday_data.empty:
|
if not eda_intraday_data.empty:
|
||||||
|
@ -26,27 +26,38 @@ def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment
|
||||||
eda_intraday_features = pd.DataFrame()
|
eda_intraday_features = pd.DataFrame()
|
||||||
|
|
||||||
# apply methods from calculate features module
|
# apply methods from calculate features module
|
||||||
eda_intraday_features = \
|
if window_length is None:
|
||||||
eda_intraday_data.groupby('local_segment').apply(\
|
eda_intraday_features = \
|
||||||
lambda x: calculateFeatures(convertInputInto2d(x['electrodermal_activity'], x.shape[0]), fs=int(sample_rate), featureNames=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)
|
eda_intraday_features.reset_index(inplace=True)
|
||||||
|
|
||||||
return eda_intraday_features
|
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"])
|
eda_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||||
|
|
||||||
requested_intraday_features = provider["FEATURES"]
|
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
|
# name of the features this function can compute
|
||||||
base_intraday_features_names = gsrFeatureNames
|
base_intraday_features_names = gsrFeatureNames
|
||||||
# the subset of requested features this function can compute
|
# the subset of requested features this function can compute
|
||||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||||
|
|
||||||
# extract features from intraday data
|
# extract features from intraday data
|
||||||
eda_intraday_features = extractEDAFeaturesFromIntradayData(eda_intraday_data,
|
eda_intraday_features = extractEDAFeaturesFromIntradayData(eda_intraday_data, intraday_features_to_compute,
|
||||||
intraday_features_to_compute, time_segment,
|
requested_window_length, time_segment, filter_data_by_segment)
|
||||||
filter_data_by_segment)
|
|
||||||
|
|
||||||
return eda_intraday_features
|
return eda_intraday_features
|
|
@ -4,6 +4,7 @@ from scipy.stats import entropy
|
||||||
from CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, genericFeatureNames
|
from CalculatingFeatures.helper_functions import convert1DEmpaticaToArray, convertInputInto2d, genericFeatureNames
|
||||||
from CalculatingFeatures.calculate_features import calculateFeatures
|
from CalculatingFeatures.calculate_features import calculateFeatures
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
def getSampleRate(data):
|
def getSampleRate(data):
|
||||||
try:
|
try:
|
||||||
|
@ -13,7 +14,7 @@ def getSampleRate(data):
|
||||||
|
|
||||||
return 1000/timestamps_diff
|
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)
|
temperature_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||||
|
|
||||||
if not temperature_intraday_data.empty:
|
if not temperature_intraday_data.empty:
|
||||||
|
@ -26,27 +27,35 @@ def extractTempFeaturesFromIntradayData(temperature_intraday_data, features, tim
|
||||||
temperature_intraday_features = pd.DataFrame()
|
temperature_intraday_features = pd.DataFrame()
|
||||||
|
|
||||||
# apply methods from calculate features module
|
# apply methods from calculate features module
|
||||||
temperature_intraday_features = \
|
if window_length is None:
|
||||||
temperature_intraday_data.groupby('local_segment').apply(\
|
temperature_intraday_features = \
|
||||||
lambda x: calculateFeatures(convertInputInto2d(x['temperature'], x.shape[0]), fs=int(sample_rate), featureNames=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)
|
temperature_intraday_features.reset_index(inplace=True)
|
||||||
|
|
||||||
return temperature_intraday_features
|
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"])
|
temperature_intraday_data = pd.read_csv(sensor_data_files["sensor_data"])
|
||||||
|
|
||||||
requested_intraday_features = provider["FEATURES"]
|
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
|
# name of the features this function can compute
|
||||||
base_intraday_features_names = genericFeatureNames
|
base_intraday_features_names = genericFeatureNames
|
||||||
# the subset of requested features this function can compute
|
# the subset of requested features this function can compute
|
||||||
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
intraday_features_to_compute = list(set(requested_intraday_features) & set(base_intraday_features_names))
|
||||||
|
|
||||||
# extract features from intraday data
|
# extract features from intraday data
|
||||||
temperature_intraday_features = extractTempFeaturesFromIntradayData(temperature_intraday_data,
|
temperature_intraday_features = extractTempFeaturesFromIntradayData(temperature_intraday_data, intraday_features_to_compute,
|
||||||
intraday_features_to_compute, time_segment,
|
requested_window_length, time_segment, filter_data_by_segment)
|
||||||
filter_data_by_segment)
|
|
||||||
|
|
||||||
return temperature_intraday_features
|
return temperature_intraday_features
|
Loading…
Reference in New Issue