Testing files change and remove standardization from hrv sensors main files.

sociality-task
Primoz 2022-07-06 07:35:39 +00:00
parent a5480f1369
commit 2d5d23b615
4 changed files with 48 additions and 39 deletions

View File

@ -66,14 +66,8 @@ def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
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):
fo_columns = bvp_intraday_features.columns.values[2:]
fo_columns_z_score = [col + "_zscore" for col in fo_columns]
bvp_intraday_features[fo_columns_z_score] = StandardScaler().fit_transform(bvp_intraday_features[fo_columns])
so_features_names = provider["WINDOWS"]["SECOND_ORDER_FEATURES"] so_features_names = provider["WINDOWS"]["SECOND_ORDER_FEATURES"]
bvp_second_order_features = extract_second_order_features(bvp_intraday_features, so_features_names) bvp_second_order_features = extract_second_order_features(bvp_intraday_features, so_features_names)
return bvp_intraday_features, bvp_second_order_features return bvp_intraday_features, bvp_second_order_features
return bvp_intraday_features return bvp_intraday_features

View File

@ -23,7 +23,7 @@ def extract_ibi_features_from_intraday_data(ibi_intraday_data, features, window_
if not ibi_intraday_data.empty: if not ibi_intraday_data.empty:
ibi_intraday_features = pd.DataFrame() ibi_intraday_features = pd.DataFrame()
# apply methods from calculate features module # apply methods from calculate features module
if window_length is None: if window_length is None:
ibi_intraday_features = \ ibi_intraday_features = \
@ -70,12 +70,7 @@ def cr_features(sensor_data_files, time_segment, provider, filter_data_by_segmen
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):
fo_columns = ibi_intraday_features.columns.values[2:]
fo_columns_z_score = [col + "_zscore" for col in fo_columns]
ibi_intraday_features[fo_columns_z_score] = StandardScaler().fit_transform(ibi_intraday_features[fo_columns])
so_features_names = provider["WINDOWS"]["SECOND_ORDER_FEATURES"] so_features_names = provider["WINDOWS"]["SECOND_ORDER_FEATURES"]
ibi_second_order_features = extract_second_order_features(ibi_intraday_features, so_features_names) ibi_second_order_features = extract_second_order_features(ibi_intraday_features, so_features_names)

View File

@ -2,27 +2,38 @@ import pandas as pd
import seaborn as sns import seaborn as sns
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
participant = "p02" participant = "p02"
all_sensors = ["ibi", "bvp"]#["eda", "bvp", "ibi", "temp", "acc"]
# path = "/rapids/data/processed/features/all_participants/all_sensor_features.csv" # all features all participants for sensor in all_sensors:
# path = "/rapids/data/interim/p03/empatica_accelerometer_features/empatica_accelerometer_python_cr_windows.csv"
path = f"/rapids/data/interim/{participant}/empatica_electrodermal_activity_features/empatica_electrodermal_activity_python_cr_windows.csv"
# path = "/rapids/data/interim/p02/empatica_inter_beat_interval_features/empatica_inter_beat_interval_python_cr_windows.csv"
# path = "/rapids/data/interim/p02/empatica_blood_volume_pulse_features/empatica_blood_volume_pulse_python_cr_windows.csv"
# path = "/rapids/data/interim/p02/empatica_temperature_features/empatica_temperature_python_cr_windows.csv"
df = pd.read_csv(path) if sensor == "eda":
print(df) path = f"/rapids/data/interim/{participant}/empatica_electrodermal_activity_features/empatica_electrodermal_activity_python_cr_windows.csv"
is_NaN = df.isnull() elif sensor == "bvp":
row_has_NaN = is_NaN.any(axis=1) path = f"/rapids/data/interim/{participant}/empatica_blood_volume_pulse_features/empatica_blood_volume_pulse_python_cr_windows.csv"
rows_with_NaN = df[row_has_NaN] elif sensor == "ibi":
path = f"/rapids/data/interim/{participant}/empatica_inter_beat_interval_features/empatica_inter_beat_interval_python_cr_windows.csv"
print("All rows:", len(df.index)) elif sensor == "acc":
print("\nCount NaN vals:", rows_with_NaN.size) path = f"/rapids/data/interim/{participant}/empatica_accelerometer_features/empatica_accelerometer_python_cr_windows.csv"
print("\nDf mean:") elif sensor == "temp":
print(df.mean()) path = f"/rapids/data/interim/{participant}/empatica_temperature_features/empatica_temperature_python_cr_windows.csv"
else:
sns.heatmap(df.isna(), cbar=False) path = "/rapids/data/processed/features/all_participants/all_sensor_features.csv" # all features all participants
plt.savefig(f'eda_{participant}_windows_NaN.png', bbox_inches='tight')
df = pd.read_csv(path)
print(df)
is_NaN = df.isnull()
row_has_NaN = is_NaN.any(axis=1)
rows_with_NaN = df[row_has_NaN]
print("All rows:", len(df.index))
print("\nCount NaN vals:", rows_with_NaN.size)
print("\nDf mean:")
print(df.mean())
sns.heatmap(df.isna(), cbar=False)
plt.savefig(f'{sensor}_{participant}_windows_NaN.png', bbox_inches='tight')

View File

@ -3,14 +3,23 @@ import seaborn as sns
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from itertools import compress from itertools import compress
participant = "p02"
# path = "/rapids/data/processed/features/all_participants/all_sensor_features.csv" # all features all participants participant = "p031"
# path = "/rapids/data/interim/p03/empatica_accelerometer_features/empatica_accelerometer_python_cr_windows.csv" sensor = "eda"
path = f"/rapids/data/interim/{participant}/empatica_electrodermal_activity_features/empatica_electrodermal_activity_python_cr_windows.csv"
# path = "/rapids/data/interim/p02/empatica_inter_beat_interval_features/empatica_inter_beat_interval_python_cr_windows.csv" if sensor == "eda":
# path = "/rapids/data/interim/p02/empatica_blood_volume_pulse_features/empatica_blood_volume_pulse_python_cr_windows.csv" path = f"/rapids/data/interim/{participant}/empatica_electrodermal_activity_features/empatica_electrodermal_activity_python_cr_windows.csv"
# path = "/rapids/data/interim/p02/empatica_temperature_features/empatica_temperature_python_cr_windows.csv" elif sensor == "bvp":
path = f"/rapids/data/interim/{participant}/empatica_blood_volume_pulse_features/empatica_blood_volume_pulse_python_cr_windows.csv"
elif sensor == "ibi":
path = f"/rapids/data/interim/{participant}/empatica_inter_beat_interval_features/empatica_inter_beat_interval_python_cr_windows.csv"
elif sensor == "acc":
path = f"/rapids/data/interim/{participant}/empatica_accelerometer_features/empatica_accelerometer_python_cr_windows.csv"
elif sensor == "temp":
path = f"/rapids/data/interim/{participant}/empatica_temperature_features/empatica_temperature_python_cr_windows.csv"
else:
path = "/rapids/data/processed/features/all_participants/all_sensor_features.csv" # all features all participants"
df = pd.read_csv(path) df = pd.read_csv(path)
df_num_peaks_zero = df[df["empatica_electrodermal_activity_cr_numPeaks"] == 0] df_num_peaks_zero = df[df["empatica_electrodermal_activity_cr_numPeaks"] == 0]