Enable selecting any questionnaire as target.

labels
junos 2022-03-16 17:55:44 +01:00
parent 1374eda171
commit 679f00dc19
3 changed files with 16 additions and 10 deletions

View File

@ -168,7 +168,8 @@ for provider in config["PHONE_ESM"]["PROVIDERS"].keys():
if config["PHONE_ESM"]["PROVIDERS"][provider]["COMPUTE"]:
files_to_compute.extend(expand("data/raw/{pid}/phone_esm_raw.csv",pid=config["PIDS"]))
files_to_compute.extend(expand("data/raw/{pid}/phone_esm_with_datetime.csv",pid=config["PIDS"]))
files_to_compute.extend(expand("data/interim/{pid}/phone_esm_clean.csv",pid=config["PIDS"]))
for feature in config["PHONE_ESM"]["PROVIDERS"][provider]["FEATURES"]:
files_to_compute.extend(expand("data/interim/{pid}/phone_esm_{feature}_clean.csv",pid=config["PIDS"],feature=feature))
#files_to_compute.extend(expand("data/processed/features/{pid}/all_sensor_features.csv",pid=config["PIDS"]))
#files_to_compute.append("data/processed/features/all_participants/all_sensor_features.csv")

View File

@ -327,8 +327,8 @@ rule conversation_r_features:
rule preprocess_esm:
input: "data/raw/{pid}/phone_esm_with_datetime.csv"
params:
questionnaire_ids = [8,9]
output: "data/interim/{pid}/phone_esm_clean.csv"
questionnaire_names = lambda wildcards: config["PHONE_ESM"]["PROVIDERS"][wildcards.feature]["FEATURES"]
output: "data/interim/{pid}/phone_esm_{feature}_clean.csv"
script:
"../src/features/phone_esm/straw/preprocess.py"

View File

@ -1,12 +1,17 @@
from esm_preprocess import *
questionnaire_names = snakemake.params["questionnaire_names"]
df_esm = pd.read_csv(snakemake.input[0])
df_esm_preprocessed = preprocess_esm(df_esm)
# TODO Enable getting the right questionnaire here.
df_esm_PANAS = df_esm_preprocessed[
(df_esm_preprocessed["questionnaire_id"] == 8)
| (df_esm_preprocessed["questionnaire_id"] == 9)
]
df_esm_clean = clean_up_esm(df_esm_PANAS)
for questionnaire_name in questionnaire_names:
try:
questionnaire_id = QUESTIONNAIRE_IDS[questionnaire_name]
except ValueError:
print("The requested questionnaire name should be one of the following:")
print(QUESTIONNAIRE_IDS.keys())
else:
df_esm_selected = df_esm_preprocessed[df_esm_preprocessed["questionnaire_id"] == questionnaire_id]
df_esm_clean = clean_up_esm(df_esm_selected)
df_esm_clean.to_csv(snakemake.output[0])