Begin with stress events in the ERS script.

imputation_and_cleaning
Primoz 2022-11-08 15:53:43 +00:00
parent 0b3e9226b3
commit f3c6a66da9
2 changed files with 12 additions and 2 deletions

View File

@ -259,7 +259,8 @@ rule extract_event_information_from_esm:
stage = "extract",
pid = "{pid}"
output:
"data/raw/ers/{pid}_ers.csv"
"data/raw/ers/{pid}_ers.csv",
"data/raw/ers/{pid}_stress_event_targets.csv"
script:
"../src/features/phone_esm/straw/process_user_event_related_segments.py"

View File

@ -31,6 +31,9 @@ def extract_ers_from_file(esm_df, device_id):
config = yaml.load(stream, Loader=yaml.FullLoader)
pd.DataFrame().to_csv(snakemake.output[1]) # Create an empty stress event file either way
esm_preprocessed = clean_up_esm(preprocess_esm(esm_df))
# Take only ema_completed sessions responses
@ -69,13 +72,19 @@ def extract_ers_from_file(esm_df, device_id):
extracted_ers["shift"] = extracted_ers["diffs"].apply(lambda x: format_timestamp(x))
elif targets_method == "stress_event":
pass
pd.DataFrame().to_csv(snakemake.output[1])
# TODO: generiranje ERS datoteke za stress_events
# VV Testiranje različnih povpraševanj za VV
# print(esm_df[esm_df.questionnaire_id == 87])
# filter_esm = esm_df[(esm_df.esm_type == 7) & ((esm_df.questionnaire_id == 90.) | (esm_df.questionnaire_id == 91.))][['questionnaire_id', 'esm_user_answer', 'esm_session']]
# print(filter_esm[filter_esm.esm_user_answer == "1 - Še vedno traja"].shape)
# print(filter_esm.shape)
# TODO: generiranje stress_events_targets datoteke (dodaj tudi stolpec s pid) + dodati moraš merge metodo, ki bo združila te datoteke
# TODO: na koncu se mora v čistilni skripti ustrezno odstraniti vse targete in prilepiti nove targete zraven ustreznih segmentov (zna se zgoditi, da bodo overlap)
else:
raise Exception("Please select correct target method for the event-related segments.")
extracted_ers = pd.DataFrame(columns=["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"])