Begin the ERS logic for 90-minutes events.

imputation_and_cleaning
Primoz 2022-11-08 11:32:05 +00:00
parent 1da72a7cbe
commit 2d83f7ddec
1 changed files with 5 additions and 4 deletions

View File

@ -39,7 +39,6 @@ def extract_ers_from_file(esm_df, device_id):
esm_df = esm_preprocessed.loc[(esm_preprocessed['device_id'].isin(esm_filtered_sessions['device_id'])) & (esm_preprocessed['esm_session'].isin(esm_filtered_sessions['esm_session']))]
# Problem ne bo ekstrahiranje posameznih začetkov in trajanj stresnih dogodkov - večji problem je pridobitev ustreznega targeta,
# tako da bo poravnan s tem dogodkom, saj se lahko zgodi, da je timestamp zabeležene intenzitete stresnega dogodka ne pade v okno stresnega dogodka.
# Edina izjema tega so, če je označen odgovor "1 - Še vedno traja" pri vprašanju appraisal_event_duration
@ -70,10 +69,12 @@ def extract_ers_from_file(esm_df, device_id):
extracted_ers['diffs'] = extracted_ers['event_timestamp'].astype('int64') - extracted_ers['end_event_timestamp'].shift(1, fill_value=0).astype('int64')
extracted_ers.loc[extracted_ers['diffs'] > time_before_questionnaire * 1000, 'diffs'] = time_before_questionnaire * 1000
extracted_ers["diffs"] = (extracted_ers["diffs"] / 1000).apply(lambda x: math.ceil(x))
# TODO: združi celotno trajanje in formatiraj v HH:MM:SS
extracted_ers["length"] = (extracted_ers["timestamp"] + extracted_ers["diffs"]).apply(lambda x: format_timestamp(x))
extracted_ers["shift"] = extracted_ers["diffs"].apply(lambda x: format_timestamp(x))
sys.exit()
elif targets_method == "stress_events":
pass
# VV Testiranje različnih povpraševanj za VV
@ -83,9 +84,9 @@ def extract_ers_from_file(esm_df, device_id):
# print(filter_esm.shape)
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"])
sys.exit()
return extracted_ers[["label", "event_timestamp", "length", "shift", "shift_direction", "device_id"]]
if snakemake.params["stage"] == "extract":