Added SO feature for sum all rows that are non zero for BVP and IBI sensors.

sociality-task
Primoz 2022-06-13 10:51:22 +00:00
parent e1d7607de4
commit 094743244d
5 changed files with 14 additions and 10 deletions

View File

@ -3,7 +3,7 @@
######################################################################################################################## ########################################################################################################################
# See https://www.rapids.science/latest/setup/configuration/#participant-files # See https://www.rapids.science/latest/setup/configuration/#participant-files
PIDS: [p03] #p01, p02, p03] PIDS: [p01] #p01, p02, p03]
# See https://www.rapids.science/latest/setup/configuration/#automatic-creation-of-participant-files # See https://www.rapids.science/latest/setup/configuration/#automatic-creation-of-participant-files
CREATE_PARTICIPANT_FILES: CREATE_PARTICIPANT_FILES:
@ -559,7 +559,7 @@ EMPATICA_BLOOD_VOLUME_PULSE:
WINDOWS: WINDOWS:
COMPUTE: True COMPUTE: True
WINDOW_LENGTH: 300 # specify window length in seconds 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_mean', 'nsmallest_mean', 'count_windows', 'hrv_num_windows_non_zero']
STANDARDIZE_FEATURES: False STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_blood_volume_pulse/cr/main.py SRC_SCRIPT: src/features/empatica_blood_volume_pulse/cr/main.py
@ -575,11 +575,11 @@ EMPATICA_INTER_BEAT_INTERVAL:
COMPUTE: True COMPUTE: True
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
PATCH_WITH_BVP: True PATCH_WITH_BVP: False
WINDOWS: WINDOWS:
COMPUTE: True COMPUTE: True
WINDOW_LENGTH: 300 # specify window length in seconds 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_mean', 'nsmallest_mean', 'count_windows', 'hrv_num_windows_non_zero']
STANDARDIZE_FEATURES: False STANDARDIZE_FEATURES: False
SRC_SCRIPT: src/features/empatica_inter_beat_interval/cr/main.py SRC_SCRIPT: src/features/empatica_inter_beat_interval/cr/main.py

View File

@ -26,6 +26,10 @@ def extract_second_order_features(intraday_features, so_features_names):
if "eda_num_peaks_non_zero" in so_features_names and "numPeaks" in intraday_features.columns: if "eda_num_peaks_non_zero" in so_features_names and "numPeaks" in intraday_features.columns:
so_features["SO_numPeaksNonZero"] = intraday_features.groupby("local_segment")["numPeaks"].apply(lambda x: (x!=0).sum()) so_features["SO_numPeaksNonZero"] = intraday_features.groupby("local_segment")["numPeaks"].apply(lambda x: (x!=0).sum())
# numWindowsNonZero specialized for BVP and IBI sensors
if "hrv_num_windows_non_zero" in so_features_names and "meanHr" in intraday_features.columns:
so_features["SO_numWindowsNonZero"] = intraday_features.groupby("local_segment")["meanHr"].apply(lambda x: (x!=0).sum())
so_features.reset_index(inplace=True) so_features.reset_index(inplace=True)
else: else:

View File

@ -30,11 +30,11 @@ def extract_eda_features_from_intraday_data(eda_intraday_data, features, window_
if window_length is None: if window_length is None:
eda_intraday_features = \ eda_intraday_features = \
eda_intraday_data.groupby('local_segment').apply(\ eda_intraday_data.groupby('local_segment').apply(\
lambda x: extractGsrFeatures2D(convert_to2d(x['electrodermal_activity'], x.shape[0]), sampleRate=sample_rate, threshold=0, featureNames=features)) lambda x: extractGsrFeatures2D(convert_to2d(x['electrodermal_activity'], x.shape[0]), sampleRate=sample_rate, featureNames=features))
else: else:
eda_intraday_features = \ eda_intraday_features = \
eda_intraday_data.groupby('local_segment').apply(\ eda_intraday_data.groupby('local_segment').apply(\
lambda x: extractGsrFeatures2D(convert_to2d(x['electrodermal_activity'], window_length*sample_rate), sampleRate=sample_rate, threshold=0, featureNames=features)) lambda x: extractGsrFeatures2D(convert_to2d(x['electrodermal_activity'], window_length*sample_rate), sampleRate=sample_rate, featureNames=features))
eda_intraday_features.reset_index(inplace=True) eda_intraday_features.reset_index(inplace=True)

View File

@ -69,6 +69,7 @@ def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
# extract features from intraday data # extract features from intraday data
ibi_intraday_features = extract_ibi_features_from_intraday_data(ibi_intraday_data, intraday_features_to_compute, ibi_intraday_features = extract_ibi_features_from_intraday_data(ibi_intraday_data, intraday_features_to_compute,
requested_window_length, time_segment, filter_data_by_segment) requested_window_length, time_segment, filter_data_by_segment)
if calc_windows: if calc_windows:
if provider["WINDOWS"].get("STANDARDIZE_FEATURES", False): if provider["WINDOWS"].get("STANDARDIZE_FEATURES", False):
fo_columns = ibi_intraday_features.columns.values[2:] fo_columns = ibi_intraday_features.columns.values[2:]
@ -80,5 +81,4 @@ def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
return ibi_intraday_features, ibi_second_order_features return ibi_intraday_features, ibi_second_order_features
return ibi_intraday_features return ibi_intraday_features