Make small corrections in ERS file.
parent
2d83f7ddec
commit
0b3e9226b3
|
@ -37,18 +37,11 @@ def extract_ers_from_file(esm_df, device_id):
|
|||
classified = classify_sessions_by_completion_time(esm_preprocessed)
|
||||
esm_filtered_sessions = classified[classified["session_response"] == 'ema_completed'].reset_index()[['device_id', 'esm_session']]
|
||||
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
|
||||
|
||||
# Extract time-relevant information
|
||||
targets_method = config["TIME_SEGMENTS"]["TAILORED_EVENTS"]["TARGETS_METHOD"]
|
||||
|
||||
|
||||
if targets_method in ["30_before", "90_before"]: # takes 30-minute peroid before the questionnaire + the duration of the questionnaire
|
||||
|
||||
# Extract time-relevant information
|
||||
extracted_ers = esm_df.groupby(["device_id", "esm_session"])['timestamp'].apply(lambda x: math.ceil((x.max() - x.min()) / 1000)).reset_index() # is rounded up in seconds
|
||||
extracted_ers["label"] = f"straw_event_{targets_method}_" + snakemake.params["pid"] + "_" + extracted_ers.index.astype(str).str.zfill(3)
|
||||
extracted_ers[['event_timestamp', 'device_id']] = esm_df.groupby(["device_id", "esm_session"])['timestamp'].min().reset_index()[['timestamp', 'device_id']]
|
||||
|
@ -75,7 +68,7 @@ def extract_ers_from_file(esm_df, device_id):
|
|||
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))
|
||||
|
||||
elif targets_method == "stress_events":
|
||||
elif targets_method == "stress_event":
|
||||
pass
|
||||
# VV Testiranje različnih povpraševanj za VV
|
||||
# print(esm_df[esm_df.questionnaire_id == 87])
|
||||
|
|
Loading…
Reference in New Issue