Various small changes.

sociality-task
Primoz 2022-06-15 13:57:46 +00:00
parent 212cf300f8
commit dda4554d46
7 changed files with 18 additions and 27 deletions

View File

@ -489,7 +489,7 @@ EMPATICA_ACCELEROMETER:
WINDOWS:
COMPUTE: True
WINDOW_LENGTH: 15 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest_mean', 'nsmallest_mean', 'count_windows']
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest', 'nsmallest', 'count_windows']
STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_accelerometer/cr/main.py
@ -518,7 +518,7 @@ EMPATICA_TEMPERATURE:
WINDOWS:
COMPUTE: True
WINDOW_LENGTH: 300 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest_mean', 'nsmallest_mean', 'count_windows']
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest', 'nsmallest', 'count_windows']
STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_temperature/cr/main.py
@ -536,11 +536,11 @@ EMPATICA_ELECTRODERMAL_ACTIVITY:
'sigTonicDifference', 'freqFeats','maxPeakAmplitudeChangeBefore', 'maxPeakAmplitudeChangeAfter', 'avgPeakAmplitudeChangeBefore',
'avgPeakAmplitudeChangeAfter', 'avgPeakChangeRatio', 'maxPeakIncreaseTime', 'maxPeakDecreaseTime', 'maxPeakDuration', 'maxPeakChangeRatio',
'avgPeakIncreaseTime', 'avgPeakDecreaseTime', 'avgPeakDuration', 'signalOverallChange', 'changeDuration', 'changeRate', 'significantIncrease',
'significantDecrease']
'significantDecrease', maxPeakResponseSlopeBefore, maxPeakResponseSlopeAfter]
WINDOWS:
COMPUTE: True
WINDOW_LENGTH: 60 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest_mean', 'nsmallest_mean', count_windows, eda_num_peaks_non_zero]
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest', 'nsmallest', count_windows, eda_num_peaks_non_zero]
STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_electrodermal_activity/cr/main.py
@ -559,7 +559,7 @@ EMPATICA_BLOOD_VOLUME_PULSE:
WINDOWS:
COMPUTE: True
WINDOW_LENGTH: 300 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest_mean', 'nsmallest_mean', 'count_windows', 'hrv_num_windows_non_nan']
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest', 'nsmallest', 'count_windows', 'hrv_num_windows_non_nan']
STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/cr/main.py
@ -579,7 +579,7 @@ EMPATICA_INTER_BEAT_INTERVAL:
WINDOWS:
COMPUTE: True
WINDOW_LENGTH: 300 # specify window length in seconds
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest_mean', 'nsmallest_mean', 'count_windows', 'hrv_num_windows_non_nan']
SECOND_ORDER_FEATURES: ['mean', 'median', 'sd', 'nlargest', 'nsmallest', 'count_windows', 'hrv_num_windows_non_nan']
STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_inter_beat_interval/cr/main.py

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

View File

@ -111,7 +111,7 @@ dependencies:
- biosppy==0.8.0
- cached-property==1.5.2
- configargparse==0.15.1
- cr-features==0.1.13
- cr-features==0.1.15
- cycler==0.11.0
- decorator==4.4.2
- fonttools==4.33.2
@ -131,6 +131,7 @@ dependencies:
- pyrsistent==0.15.5
- pywavelets==1.3.0
- ratelimiter==1.2.0.post0
- seaborn==0.11.2
- shortuuid==1.0.8
- snakemake==5.30.2
- toposort==1.5

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

View File

@ -22,13 +22,13 @@ def extract_second_order_features(intraday_features, so_features_names, prefix="
if "sd" in so_features_names:
so_features = pd.concat([so_features, intraday_features.drop(prefix+"level_1", axis=1).groupby(groupby_cols).std().add_suffix("_SO_sd")], axis=1)
if "nlargest_mean" in so_features_names: # largest 5 -- maybe there is a faster groupby solution?
if "nlargest" in so_features_names: # largest 5 -- maybe there is a faster groupby solution?
for column in intraday_features.loc[:, ~intraday_features.columns.isin(groupby_cols+[prefix+"level_1"])]:
so_features[column+"_SO_nlargest_mean"] = intraday_features.drop(prefix+"level_1", axis=1).groupby(groupby_cols)[column].apply(lambda x: x.nlargest(5).mean())
so_features[column+"_SO_nlargest"] = intraday_features.drop(prefix+"level_1", axis=1).groupby(groupby_cols)[column].apply(lambda x: x.nlargest(5).mean())
if "nsmallest_mean" in so_features_names: # smallest 5 -- maybe there is a faster groupby solution?
if "nsmallest" in so_features_names: # smallest 5 -- maybe there is a faster groupby solution?
for column in intraday_features.loc[:, ~intraday_features.columns.isin(groupby_cols+[prefix+"level_1"])]:
so_features[column+"_SO_nsmallest_mean"] = intraday_features.drop(prefix+"level_1", axis=1).groupby(groupby_cols)[column].apply(lambda x: x.nsmallest(5).mean())
so_features[column+"_SO_nsmallest"] = intraday_features.drop(prefix+"level_1", axis=1).groupby(groupby_cols)[column].apply(lambda x: x.nsmallest(5).mean())
if "count_windows" in so_features_names:
so_features["SO_windowsCount"] = intraday_features.groupby(groupby_cols).count()[prefix+"level_1"]

View File

@ -14,22 +14,20 @@ df = pd.read_csv(path)
df_num_peaks_zero = df[df["empatica_electrodermal_activity_cr_numPeaks"] == 0]
columns_num_peaks_zero = df_num_peaks_zero.columns[df_num_peaks_zero.isna().any()].tolist()
df_num_peaks_non_zero_t = df[df["empatica_electrodermal_activity_cr_numPeaks"] != 0]
df_num_peaks_non_zero = df_num_peaks_non_zero_t[columns_num_peaks_zero]
df_num_peaks_non_zero = df[df["empatica_electrodermal_activity_cr_numPeaks"] != 0]
df_num_peaks_non_zero = df_num_peaks_non_zero[columns_num_peaks_zero]
print(df_num_peaks_non_zero[df_num_peaks_non_zero["empatica_electrodermal_activity_cr_maxPeakAmplitudeChangeBefore"] != 0])
# row_has_NaN = is_NaN. any(axis=1)
# rows_with_NaN = df[row_has_NaN]
# print(rows_with_NaN.size)
pd.set_option('display.max_columns', None)
# # pd.set_option('display.max_rows', None)
# print(df_num_peaks_non_zero)
df_q = pd.DataFrame()
for col in df_num_peaks_non_zero:
df_q[col] = pd.to_numeric(pd.cut(df_num_peaks_non_zero[col], bins=[-1,0,0.000000000001,1000], labels=[-1,0,1], right=False))
sns.heatmap(df_q)
plt.savefig('eda_windows_p01_window_non_zero.png', bbox_inches='tight')
plt.savefig('eda_windows_p01_window_values_non_zero_peak_distribution_0thresh.png', bbox_inches='tight')
plt.close()
# Filter columns that do not contain 0
@ -39,12 +37,4 @@ zero_cols = list(set(columns_num_peaks_zero) - set(non_zero_cols))
print(non_zero_cols, "\n")
print(zero_cols)
# maxPeakAmplitudeChangeBefore
mpacb = df_num_peaks_non_zero_t\
[(df_num_peaks_non_zero_t['empatica_electrodermal_activity_cr_avgPeakAmplitudeChangeBefore'] != 0) \
& (df_num_peaks_non_zero_t['empatica_electrodermal_activity_cr_numPeaks'] != 0)]
print(mpacb['empatica_electrodermal_activity_cr_numPeaks'])
sns.heatmap(mpacb['empatica_electrodermal_activity_cr_numPeaks'])
plt.savefig('maxPeakAmplitudeChangeBefore.png', bbox_inches='tight')