Merge branch 'labels' into run_test_participant

labels
junos 2022-03-16 17:56:07 +01:00
commit 8ed7d23348
5 changed files with 42 additions and 52 deletions

View File

@ -168,7 +168,8 @@ for provider in config["PHONE_ESM"]["PROVIDERS"].keys():
if config["PHONE_ESM"]["PROVIDERS"][provider]["COMPUTE"]: 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_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/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.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") #files_to_compute.append("data/processed/features/all_participants/all_sensor_features.csv")

View File

@ -239,7 +239,7 @@ PHONE_ESM:
PROVIDERS: PROVIDERS:
STRAW: STRAW:
COMPUTE: True COMPUTE: True
FEATURES: FEATURES: ["PANAS_positive_affect", "PANAS_negative_affect"]
SRC_SCRIPT: src/features/phone_esm/rapids/main.py SRC_SCRIPT: src/features/phone_esm/rapids/main.py
# See https://www.rapids.science/latest/features/phone-keyboard/ # See https://www.rapids.science/latest/features/phone-keyboard/

View File

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

View File

@ -19,48 +19,32 @@ ESM_TYPE = {
QUESTIONNAIRE_IDS = { QUESTIONNAIRE_IDS = {
"sleep_quality": 1, "sleep_quality": 1,
"PANAS": { "PANAS_positive_affect": 8,
"positive_affect": 8, "PANAS_negative_affect": 9,
"negative_affect": 9 "JCQ_job_demand": 10,
}, "JCQ_job_control": 11,
"job_content_questionnaire": { "JCQ_supervisor_support": 12,
"job_demand": 10, "JCQ_coworker_support": 13,
"job_control": 11, "PFITS_supervisor": 14,
"supervisor_support": 12, "PFITS_coworkers": 15,
"coworker_support": 13, "UWES_vigor": 16,
}, "UWES_dedication": 17,
"PFITS": { "UWES_absorption": 18,
"supervisor": 14, "COPE_active": 19,
"coworkers": 15 "COPE_support": 20,
}, "COPE_emotions": 21,
"UWES": { "balance_life_work": 22,
"vigor": 16, "balance_work_life": 23,
"dedication": 17, "recovery_experience_detachment": 24,
"absorption": 18 "recovery_experience_relaxation": 25,
},
"COPE": {
"active": 19,
"support": 20,
"emotions": 21
},
"work_life_balance": {
"life_work": 22,
"work_life": 23
},
"recovery_experience": {
"detachment": 24,
"relaxation": 25
},
"symptoms": 26, "symptoms": 26,
"stress_appraisal": { "appraisal_stressfulness_event": 87,
"stressfulness_event": 87, "appraisal_threat": 88,
"threat": 88, "appraisal_challenge": 89,
"challenge": 89, "appraisal_event_time": 90,
"event_time": 90, "appraisal_event_duration": 91,
"event_duration": 91, "appraisal_event_work_related": 92,
"event_work_related": 92, "appraisal_stressfulness_period": 93,
"stressfulness_period": 93,
},
"late_work": 94, "late_work": 94,
"work_hours": 95, "work_hours": 95,
"left_work": 96, "left_work": 96,

View File

@ -1,12 +1,17 @@
from esm_preprocess import * from esm_preprocess import *
questionnaire_names = snakemake.params["questionnaire_names"]
df_esm = pd.read_csv(snakemake.input[0]) df_esm = pd.read_csv(snakemake.input[0])
df_esm_preprocessed = preprocess_esm(df_esm) 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)
df_esm_clean.to_csv(snakemake.output[0]) 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])