Start with ERS logic integration within Snakemake.

notes
Primoz 2022-10-14 14:46:28 +00:00
parent 797aa98f4f
commit f3ca56cdbf
3 changed files with 43 additions and 0 deletions

View File

@ -24,6 +24,9 @@ TIME_SEGMENTS: &time_segments
TYPE: EVENT # FREQUENCY, PERIODIC, EVENT TYPE: EVENT # FREQUENCY, PERIODIC, EVENT
FILE: "data/external/straw_events.csv" FILE: "data/external/straw_events.csv"
INCLUDE_PAST_PERIODIC_SEGMENTS: TRUE # Only relevant if TYPE=PERIODIC, see docs INCLUDE_PAST_PERIODIC_SEGMENTS: TRUE # Only relevant if TYPE=PERIODIC, see docs
TAILORED_EVENTS: # Only relevant if TYPE=EVENT
COMPUTE: True
PARAMETER_ONE: "something"
# See https://www.rapids.science/latest/setup/configuration/#timezone-of-your-study # See https://www.rapids.science/latest/setup/configuration/#timezone-of-your-study
TIMEZONE: TIMEZONE:

View File

@ -249,3 +249,24 @@ rule empatica_readable_datetime:
"data/raw/{pid}/empatica_{sensor}_with_datetime.csv" "data/raw/{pid}/empatica_{sensor}_with_datetime.csv"
script: script:
"../src/data/datetime/readable_datetime.R" "../src/data/datetime/readable_datetime.R"
rule extract_event_information_from_esm:
input:
esm_raw_input = "data/raw/{pid}/phone_esm_raw.csv"
params:
stage = "extract"
output:
"data/raw/ers/{pid}_ers.csv"
script:
"../src/data/process_user_event_related_segments.py"
rule create_event_related_segments_file:
input:
ers_files = expand("data/raw/{pid}_ers.csv", pid=config["PIDS"])
params:
stage = "merge"
output:
"data/external/straw_events.csv"
script:
"../src/data/process_user_event_related_segments.py"

View File

@ -0,0 +1,19 @@
import pandas as pd
import numpy as np
import sys
input_data_files = dict(snakemake.input)
# TODO: potrebno preveriti kako se izvaja iskanje prek device_id -> na tem temelji tudi proces ekstrahiranja ERS
if snakemake.params["stage"] == "extract": # TODO: najprej preveri ustreznost umeščenosti v RAPIDS pipelineu
extracted_ers = extract_ers_from_file(input_data_files[0])
extracted_ers.to_csv(snakemake.output[0], index=False)
elif snakemake.params["stage"] == "merge":
pass # TODO: morda ta del raje naredi v drugi skripti (po principu utils/merge_sensor_features_for_all_participants.R)
def extract_ers_from_file(esm_file): # TODO: kako se bodo pridobili device_id? Bo torej potreben tudi p0??.yaml?
return None