From c1564f0caeba18fa5b6365e8508f958e7b4f63ed Mon Sep 17 00:00:00 2001 From: Primoz Date: Wed, 11 May 2022 14:21:21 +0000 Subject: [PATCH] Changed wrapper method calculate_feature to its newest version (for TEMP and ACC). --- config.yaml | 22 +++++++-------- .../empatica_accelerometer/cr/main.py | 27 +++++++++++++++---- src/features/empatica_temperature/cr/main.py | 16 +++++++++-- 3 files changed, 47 insertions(+), 18 deletions(-) diff --git a/config.yaml b/config.yaml index 324bba7e..9b49664b 100644 --- a/config.yaml +++ b/config.yaml @@ -3,7 +3,7 @@ ######################################################################################################################## # See https://www.rapids.science/latest/setup/configuration/#participant-files -PIDS: [p01] #,p02] +PIDS: [p01] #, p02] # See https://www.rapids.science/latest/setup/configuration/#automatic-creation-of-participant-files CREATE_PARTICIPANT_FILES: @@ -477,7 +477,7 @@ 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 CR: @@ -502,7 +502,7 @@ EMPATICA_HEARTRATE: CONTAINER: HR PROVIDERS: DBDP: - COMPUTE: True + COMPUTE: False FEATURES: ["maxhr", "minhr", "avghr", "medianhr", "modehr", "stdhr", "diffmaxmodehr", "diffminmodehr", "entropyhr"] SRC_SCRIPT: src/features/empatica_heartrate/dbdp/main.py @@ -511,7 +511,7 @@ 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 CR: @@ -532,18 +532,18 @@ 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 CR: - COMPUTE: True + COMPUTE: False 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'] WINDOWS: - COMPUTE: True + COMPUTE: False WINDOW_LENGTH: 300 # specify window length in seconds SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'max', 'min'] SRC_SCRIPT: src/features/empatica_electrodermal_activity/cr/main.py @@ -553,11 +553,11 @@ EMPATICA_BLOOD_VOLUME_PULSE: CONTAINER: BVP PROVIDERS: DBDP: - COMPUTE: True + COMPUTE: False FEATURES: ["maxbvp", "minbvp", "avgbvp", "medianbvp", "modebvp", "stdbvp", "diffmaxmodebvp", "diffminmodebvp", "entropybvp"] SRC_SCRIPT: src/features/empatica_blood_volume_pulse/dbdp/main.py CR: - COMPUTE: True + COMPUTE: False 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 WINDOWS: @@ -571,11 +571,11 @@ EMPATICA_INTER_BEAT_INTERVAL: CONTAINER: IBI PROVIDERS: DBDP: - COMPUTE: True + COMPUTE: False FEATURES: ["maxibi", "minibi", "avgibi", "medianibi", "modeibi", "stdibi", "diffmaxmodeibi", "diffminmodeibi", "entropyibi"] SRC_SCRIPT: src/features/empatica_inter_beat_interval/dbdp/main.py CR: - COMPUTE: True + COMPUTE: False 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 WINDOWS: diff --git a/src/features/empatica_accelerometer/cr/main.py b/src/features/empatica_accelerometer/cr/main.py index 9a11a752..3821de20 100644 --- a/src/features/empatica_accelerometer/cr/main.py +++ b/src/features/empatica_accelerometer/cr/main.py @@ -3,6 +3,7 @@ from scipy.stats import entropy 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 import calculate_features from cr_features_helper_methods import extract_second_order_features import sys @@ -19,21 +20,37 @@ def extract_acc_features_from_intraday_data(acc_intraday_data, features, window_ acc_intraday_features = pd.DataFrame() - # apply methods from calculate features module + # # 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 if window_length is None: 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_1'], x.shape[0]), \ convert_to2d(x['double_values_2'], x.shape[0]), \ - fs=sample_rate, featureNames=features)) + fs=sample_rate, feature_names=features)) else: 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_1'], 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) diff --git a/src/features/empatica_temperature/cr/main.py b/src/features/empatica_temperature/cr/main.py index 1eea539a..70a2567e 100644 --- a/src/features/empatica_temperature/cr/main.py +++ b/src/features/empatica_temperature/cr/main.py @@ -3,6 +3,7 @@ from scipy.stats import entropy from cr_features.helper_functions import convert_to2d, generic_features 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 import sys @@ -19,15 +20,26 @@ def extract_temp_features_from_intraday_data(temperature_intraday_data, features 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 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)) + lambda x: calculate_features(convert_to2d(x['temperature'], x.shape[0]), fs=sample_rate, feature_names=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)) + 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)