Changed wrapper method calculate_feature to its newest version (for TEMP and ACC).

sociality-task
Primoz 2022-05-11 14:21:21 +00:00
parent 31e36e7400
commit c1564f0cae
3 changed files with 47 additions and 18 deletions

View File

@ -477,7 +477,7 @@ 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
CR: CR:
@ -502,7 +502,7 @@ EMPATICA_HEARTRATE:
CONTAINER: HR CONTAINER: HR
PROVIDERS: PROVIDERS:
DBDP: DBDP:
COMPUTE: True COMPUTE: False
FEATURES: ["maxhr", "minhr", "avghr", "medianhr", "modehr", "stdhr", "diffmaxmodehr", "diffminmodehr", "entropyhr"] FEATURES: ["maxhr", "minhr", "avghr", "medianhr", "modehr", "stdhr", "diffmaxmodehr", "diffminmodehr", "entropyhr"]
SRC_SCRIPT: src/features/empatica_heartrate/dbdp/main.py SRC_SCRIPT: src/features/empatica_heartrate/dbdp/main.py
@ -511,7 +511,7 @@ 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
CR: CR:
@ -532,18 +532,18 @@ 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
CR: CR:
COMPUTE: True COMPUTE: False
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']
WINDOWS: WINDOWS:
COMPUTE: True COMPUTE: False
WINDOW_LENGTH: 300 # specify window length in seconds WINDOW_LENGTH: 300 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'max', 'min'] SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'max', 'min']
SRC_SCRIPT: src/features/empatica_electrodermal_activity/cr/main.py SRC_SCRIPT: src/features/empatica_electrodermal_activity/cr/main.py
@ -553,11 +553,11 @@ EMPATICA_BLOOD_VOLUME_PULSE:
CONTAINER: BVP CONTAINER: BVP
PROVIDERS: PROVIDERS:
DBDP: DBDP:
COMPUTE: True COMPUTE: False
FEATURES: ["maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"] FEATURES: ["maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"]
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py
CR: CR:
COMPUTE: True COMPUTE: False
FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR', # Time features FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR', # Time features
'VLF', 'LF', 'LFnorm', 'HF', 'HFnorm', 'LF/HF', 'fullIntegral'] # Freq features 'VLF', 'LF', 'LFnorm', 'HF', 'HFnorm', 'LF/HF', 'fullIntegral'] # Freq features
WINDOWS: WINDOWS:
@ -571,11 +571,11 @@ EMPATICA_INTER_BEAT_INTERVAL:
CONTAINER: IBI CONTAINER: IBI
PROVIDERS: PROVIDERS:
DBDP: DBDP:
COMPUTE: True COMPUTE: False
FEATURES: ["maxibi", "minibi", "avgibi", "medianibi", "modeibi", "stdibi", "diffmaxmodeibi", "diffminmodeibi", "entropyibi"] FEATURES: ["maxibi", "minibi", "avgibi", "medianibi", "modeibi", "stdibi", "diffmaxmodeibi", "diffminmodeibi", "entropyibi"]
SRC_SCRIPT: src/features/empatica_inter_beat_interval/dbdp/main.py SRC_SCRIPT: src/features/empatica_inter_beat_interval/dbdp/main.py
CR: CR:
COMPUTE: True COMPUTE: False
FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR', # Time features FEATURES: ['meanHr', 'ibi', 'sdnn', 'sdsd', 'rmssd', 'pnn20', 'pnn50', 'sd', 'sd2', 'sd1/sd2', 'numRR', # Time features
'VLF', 'LF', 'LFnorm', 'HF', 'HFnorm', 'LF/HF', 'fullIntegral'] # Freq features 'VLF', 'LF', 'LFnorm', 'HF', 'HFnorm', 'LF/HF', 'fullIntegral'] # Freq features
WINDOWS: WINDOWS:

View File

@ -3,6 +3,7 @@ from scipy.stats import entropy
from cr_features.helper_functions import convert_to2d, accelerometer_features, frequency_features from cr_features.helper_functions import convert_to2d, accelerometer_features, frequency_features
from cr_features.calculate_features_old import calculateFeatures from cr_features.calculate_features_old import calculateFeatures
from cr_features.calculate_features import calculate_features
from cr_features_helper_methods import extract_second_order_features from cr_features_helper_methods import extract_second_order_features
import sys import sys
@ -19,21 +20,37 @@ def extract_acc_features_from_intraday_data(acc_intraday_data, features, window_
acc_intraday_features = pd.DataFrame() acc_intraday_features = pd.DataFrame()
# # apply methods from calculate features module
# if window_length is None:
# acc_intraday_features = \
# acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
# convert_to2d(x['double_values_0'], x.shape[0]), \
# convert_to2d(x['double_values_1'], x.shape[0]), \
# convert_to2d(x['double_values_2'], x.shape[0]), \
# fs=sample_rate, featureNames=features))
# else:
# acc_intraday_features = \
# acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \
# convert_to2d(x['double_values_0'], window_length*sample_rate), \
# convert_to2d(x['double_values_1'], window_length*sample_rate), \
# convert_to2d(x['double_values_2'], window_length*sample_rate), \
# fs=sample_rate, featureNames=features))
# apply methods from calculate features module # apply methods from calculate features module
if window_length is None: if window_length is None:
acc_intraday_features = \ acc_intraday_features = \
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \ acc_intraday_data.groupby('local_segment').apply(lambda x: calculate_features( \
convert_to2d(x['double_values_0'], x.shape[0]), \ convert_to2d(x['double_values_0'], x.shape[0]), \
convert_to2d(x['double_values_1'], x.shape[0]), \ convert_to2d(x['double_values_1'], x.shape[0]), \
convert_to2d(x['double_values_2'], x.shape[0]), \ convert_to2d(x['double_values_2'], x.shape[0]), \
fs=sample_rate, featureNames=features)) fs=sample_rate, feature_names=features))
else: else:
acc_intraday_features = \ acc_intraday_features = \
acc_intraday_data.groupby('local_segment').apply(lambda x: calculateFeatures( \ acc_intraday_data.groupby('local_segment').apply(lambda x: calculate_features( \
convert_to2d(x['double_values_0'], window_length*sample_rate), \ convert_to2d(x['double_values_0'], window_length*sample_rate), \
convert_to2d(x['double_values_1'], window_length*sample_rate), \ convert_to2d(x['double_values_1'], window_length*sample_rate), \
convert_to2d(x['double_values_2'], window_length*sample_rate), \ convert_to2d(x['double_values_2'], window_length*sample_rate), \
fs=sample_rate, featureNames=features)) fs=sample_rate, feature_names=features))
acc_intraday_features.reset_index(inplace=True) acc_intraday_features.reset_index(inplace=True)

View File

@ -3,6 +3,7 @@ from scipy.stats import entropy
from cr_features.helper_functions import convert_to2d, generic_features from cr_features.helper_functions import convert_to2d, generic_features
from cr_features.calculate_features_old import calculateFeatures from cr_features.calculate_features_old import calculateFeatures
from cr_features.calculate_features import calculate_features
from cr_features_helper_methods import extract_second_order_features from cr_features_helper_methods import extract_second_order_features
import sys import sys
@ -19,15 +20,26 @@ def extract_temp_features_from_intraday_data(temperature_intraday_data, features
temperature_intraday_features = pd.DataFrame() temperature_intraday_features = pd.DataFrame()
# apply methods from calculate features module
# if window_length is None:
# temperature_intraday_features = \
# temperature_intraday_data.groupby('local_segment').apply(\
# lambda x: calculateFeatures(convert_to2d(x['temperature'], x.shape[0]), fs=sample_rate, featureNames=features))
# else:
# temperature_intraday_features = \
# temperature_intraday_data.groupby('local_segment').apply(\
# lambda x: calculateFeatures(convert_to2d(x['temperature'], window_length*sample_rate), fs=sample_rate, featureNames=features))
# apply methods from calculate features module # apply methods from calculate features module
if window_length is None: if window_length is None:
temperature_intraday_features = \ temperature_intraday_features = \
temperature_intraday_data.groupby('local_segment').apply(\ temperature_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convert_to2d(x['temperature'], x.shape[0]), fs=sample_rate, featureNames=features)) lambda x: calculate_features(convert_to2d(x['temperature'], x.shape[0]), fs=sample_rate, feature_names=features))
else: else:
temperature_intraday_features = \ temperature_intraday_features = \
temperature_intraday_data.groupby('local_segment').apply(\ temperature_intraday_data.groupby('local_segment').apply(\
lambda x: calculateFeatures(convert_to2d(x['temperature'], window_length*sample_rate), fs=sample_rate, featureNames=features)) lambda x: calculate_features(convert_to2d(x['temperature'], window_length*sample_rate), fs=sample_rate, feature_names=features))
temperature_intraday_features.reset_index(inplace=True) temperature_intraday_features.reset_index(inplace=True)