Prepare method-based logic for ERS generating.
parent
eefa9f3f4d
commit
62f46ea376
|
@ -26,7 +26,7 @@ TIME_SEGMENTS: &time_segments
|
|||
INCLUDE_PAST_PERIODIC_SEGMENTS: TRUE # Only relevant if TYPE=PERIODIC, see docs
|
||||
TAILORED_EVENTS: # Only relevant if TYPE=EVENT
|
||||
COMPUTE: True
|
||||
TARGETS_METHOD: "none"
|
||||
TARGETS_METHOD: "thirty_before"
|
||||
|
||||
# See https://www.rapids.science/latest/setup/configuration/#timezone-of-your-study
|
||||
TIMEZONE:
|
||||
|
|
|
@ -30,7 +30,6 @@ def extract_ers_from_file(esm_df, device_id):
|
|||
with open('config.yaml', 'r') as stream:
|
||||
config = yaml.load(stream, Loader=yaml.FullLoader)
|
||||
|
||||
targets_method = config["TIME_SEGMENTS"]["TAILORED_EVENTS"]["TARGETS_METHOD"]
|
||||
|
||||
esm_preprocessed = clean_up_esm(preprocess_esm(esm_df))
|
||||
|
||||
|
@ -39,9 +38,10 @@ def extract_ers_from_file(esm_df, device_id):
|
|||
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']))]
|
||||
|
||||
# Kako ugotoviti, kje je bilo vprašanje na distressed?
|
||||
|
||||
# Extract time-relevant information
|
||||
targets_method = config["TIME_SEGMENTS"]["TAILORED_EVENTS"]["TARGETS_METHOD"]
|
||||
|
||||
if targets_method == "thirty_before": # takes 30-minute peroid before the questionnaire + the duration of the questionnaire
|
||||
time_before_questionnaire = 30 * 60 # in seconds (30 minutes)
|
||||
|
||||
extracted_ers = esm_df.groupby(["device_id", "esm_session"])['timestamp'].apply(lambda x: math.ceil((x.max() - x.min()) / 1000)).reset_index() # in rounded up in seconds
|
||||
|
@ -53,6 +53,9 @@ def extract_ers_from_file(esm_df, device_id):
|
|||
extracted_ers["shift"] = extracted_ers["shift"].apply(lambda x: format_timestamp(x))
|
||||
extracted_ers["shift_direction"] = -1
|
||||
|
||||
else:
|
||||
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"]]
|
||||
|
||||
|
|
Loading…
Reference in New Issue