Skeleton file main.py for EDA CalcFt. integration.
parent
bd5a811256
commit
2da0911d4c
18
config.yaml
18
config.yaml
|
@ -180,7 +180,7 @@ PHONE_CALLS:
|
||||||
CONTAINER: calls.csv
|
CONTAINER: calls.csv
|
||||||
PROVIDERS:
|
PROVIDERS:
|
||||||
RAPIDS:
|
RAPIDS:
|
||||||
COMPUTE: True
|
COMPUTE: False
|
||||||
FEATURES_TYPE: EPISODES # EVENTS or EPISODES
|
FEATURES_TYPE: EPISODES # EVENTS or EPISODES
|
||||||
CALL_TYPES: [missed, incoming, outgoing]
|
CALL_TYPES: [missed, incoming, outgoing]
|
||||||
FEATURES:
|
FEATURES:
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -486,7 +486,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
|
||||||
|
|
||||||
|
@ -495,7 +495,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
|
||||||
|
|
||||||
|
@ -504,16 +504,20 @@ 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:
|
||||||
|
COMPUTE: True
|
||||||
|
FEATURES: ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda", "diffminmodeeda", "entropyeda"]
|
||||||
|
SRC_SCRIPT: src/features/empatica_electrodermal_activity/cf/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: ["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
|
||||||
|
|
||||||
|
@ -522,7 +526,7 @@ 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
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
import pandas as pd
|
||||||
|
from scipy.stats import entropy
|
||||||
|
|
||||||
|
|
||||||
|
def statsFeatures(eda_data, features, eda_features):
|
||||||
|
col_name = "electrodermal_activity"
|
||||||
|
if "sumeda" in features:
|
||||||
|
eda_features["sumeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].sum()
|
||||||
|
if "maxeda" in features:
|
||||||
|
eda_features["maxeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].max()
|
||||||
|
if "mineda" in features:
|
||||||
|
eda_features["mineda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].min()
|
||||||
|
if "avgeda" in features:
|
||||||
|
eda_features["avgeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].mean()
|
||||||
|
if "medianeda" in features:
|
||||||
|
eda_features["medianeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].median()
|
||||||
|
if "modeeda" in features:
|
||||||
|
eda_features["modeeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].agg(lambda x: pd.Series.mode(x)[0])
|
||||||
|
if "stdeda" in features:
|
||||||
|
eda_features["stdeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].std()
|
||||||
|
if "diffmaxmodeeda" in features:
|
||||||
|
eda_features["diffmaxmodeeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].max() - \
|
||||||
|
eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].agg(lambda x: pd.Series.mode(x)[0])
|
||||||
|
if "diffminmodeeda" in features:
|
||||||
|
eda_features["diffminmodeeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].agg(lambda x: pd.Series.mode(x)[0]) - \
|
||||||
|
eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].min()
|
||||||
|
if "entropyeda" in features:
|
||||||
|
eda_features["entropyeda"] = eda_data[["local_segment", col_name]].groupby(["local_segment"])[
|
||||||
|
col_name].agg(entropy)
|
||||||
|
|
||||||
|
return eda_features
|
||||||
|
|
||||||
|
|
||||||
|
def extractEDAFeaturesFromIntradayData(eda_intraday_data, features, time_segment, filter_data_by_segment):
|
||||||
|
eda_intraday_features = pd.DataFrame(columns=["local_segment"] + features)
|
||||||
|
if not eda_intraday_data.empty:
|
||||||
|
eda_intraday_data = filter_data_by_segment(eda_intraday_data, time_segment)
|
||||||
|
|
||||||
|
if not eda_intraday_data.empty:
|
||||||
|
eda_intraday_features = pd.DataFrame()
|
||||||
|
|
||||||
|
# get stats of eda
|
||||||
|
eda_intraday_features = statsFeatures(eda_intraday_data, features, eda_intraday_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):
|
||||||
|
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 = ["maxeda", "mineda", "avgeda", "medianeda", "modeeda", "stdeda", "diffmaxmodeeda",
|
||||||
|
"diffminmodeeda", "entropyeda"]
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
return eda_intraday_features
|
Loading…
Reference in New Issue