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"]:
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

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

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

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

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)
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])