Fix formatting.
parent
92a5787d62
commit
48d7be780c
|
@ -232,17 +232,19 @@ class ESM(Base, AWAREsensor):
|
||||||
esm_session = Column(Integer, nullable=False)
|
esm_session = Column(Integer, nullable=False)
|
||||||
esm_notification_id = Column(Integer, nullable=False)
|
esm_notification_id = Column(Integer, nullable=False)
|
||||||
esm_expiration_threshold = Column(SmallInteger)
|
esm_expiration_threshold = Column(SmallInteger)
|
||||||
ESM_TYPE = {'text': 1,
|
ESM_TYPE = {
|
||||||
'radio': 2,
|
"text": 1,
|
||||||
'checkbox': 3,
|
"radio": 2,
|
||||||
'likert': 4,
|
"checkbox": 3,
|
||||||
'quick_answers': 5,
|
"likert": 4,
|
||||||
'scale': 6,
|
"quick_answers": 5,
|
||||||
'datetime': 7,
|
"scale": 6,
|
||||||
'pam': 8,
|
"datetime": 7,
|
||||||
'number': 9,
|
"pam": 8,
|
||||||
'web': 10,
|
"number": 9,
|
||||||
'date': 11}
|
"web": 10,
|
||||||
|
"date": 11,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Imperfection(Base):
|
class Imperfection(Base):
|
||||||
|
|
|
@ -49,8 +49,7 @@ df_esm_PANAS_clean = clean_up_esm(df_esm_PANAS)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
df_esm_PANAS_daily_means = (
|
df_esm_PANAS_daily_means = (
|
||||||
df_esm_PANAS_clean.groupby(
|
df_esm_PANAS_clean.groupby(["participant_id", "date_lj", "questionnaire_id"])
|
||||||
["participant_id", "date_lj", "questionnaire_id"])
|
|
||||||
.esm_user_answer_numeric.agg("mean")
|
.esm_user_answer_numeric.agg("mean")
|
||||||
.reset_index()
|
.reset_index()
|
||||||
.rename(columns={"esm_user_answer_numeric": "esm_numeric_mean"})
|
.rename(columns={"esm_user_answer_numeric": "esm_numeric_mean"})
|
||||||
|
@ -81,7 +80,10 @@ sns.displot(
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
sns.displot(
|
sns.displot(
|
||||||
data=df_esm_PANAS_summary_participant, x="median", hue="PANAS_subscale", binwidth=0.2
|
data=df_esm_PANAS_summary_participant,
|
||||||
|
x="median",
|
||||||
|
hue="PANAS_subscale",
|
||||||
|
binwidth=0.2,
|
||||||
)
|
)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
|
@ -91,3 +93,31 @@ sns.displot(
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
df_esm_PANAS_summary_participant[df_esm_PANAS_summary_participant["std"] < 0.1]
|
df_esm_PANAS_summary_participant[df_esm_PANAS_summary_participant["std"] < 0.1]
|
||||||
|
|
||||||
|
# %% [markdown]
|
||||||
|
# # Stress appraisal measure
|
||||||
|
|
||||||
|
# %%
|
||||||
|
df_esm_SAM = df_esm_preprocessed[
|
||||||
|
(df_esm_preprocessed["questionnaire_id"] >= 87)
|
||||||
|
& (df_esm_preprocessed["questionnaire_id"] <= 93)
|
||||||
|
]
|
||||||
|
|
||||||
|
# %%
|
||||||
|
clean_up_esm(df_esm_SAM)[["esm_user_answer", "esm_user_answer_numeric"]].head(9)
|
||||||
|
|
||||||
|
# %%
|
||||||
|
df_esm_PANAS_clean[["esm_user_answer", "esm_user_answer_numeric"]].head(n=10)
|
||||||
|
|
||||||
|
# %%
|
||||||
|
df_esm_SAM[
|
||||||
|
[
|
||||||
|
"esm_instructions",
|
||||||
|
"question_id",
|
||||||
|
"questionnaire_id",
|
||||||
|
"esm_user_answer",
|
||||||
|
"esm_type",
|
||||||
|
]
|
||||||
|
].head(n=10)
|
||||||
|
|
||||||
|
# %%
|
||||||
|
|
|
@ -250,10 +250,14 @@ def clean_up_esm(df_esm_preprocessed: pd.DataFrame) -> pd.DataFrame:
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
df_esm_clean["esm_user_answer_numeric"] = np.nan
|
df_esm_clean["esm_user_answer_numeric"] = np.nan
|
||||||
esm_type_numeric = [ESM.ESM_TYPE.get("radio"),
|
esm_type_numeric = [
|
||||||
ESM.ESM_TYPE.get("scale"),
|
ESM.ESM_TYPE.get("radio"),
|
||||||
ESM.ESM_TYPE.get("number")]
|
ESM.ESM_TYPE.get("scale"),
|
||||||
df_esm_clean[df_esm_clean["esm_type"].isin(esm_type_numeric)] = df_esm_clean[df_esm_clean["esm_type"].isin(esm_type_numeric)].assign(
|
ESM.ESM_TYPE.get("number"),
|
||||||
|
]
|
||||||
|
df_esm_clean[df_esm_clean["esm_type"].isin(esm_type_numeric)] = df_esm_clean[
|
||||||
|
df_esm_clean["esm_type"].isin(esm_type_numeric)
|
||||||
|
].assign(
|
||||||
esm_user_answer_numeric=lambda x: x.esm_user_answer.str.slice(stop=1).astype(
|
esm_user_answer_numeric=lambda x: x.esm_user_answer.str.slice(stop=1).astype(
|
||||||
int
|
int
|
||||||
)
|
)
|
||||||
|
|
|
@ -242,8 +242,17 @@ df_session_workday[df_session_workday.time_diff_minutes < 30]
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
df_esm_preprocessed.loc[
|
df_esm_preprocessed.loc[
|
||||||
(df_esm_preprocessed.participant_id == 35) & (df_esm_preprocessed.esm_session == 7) & (df_esm_preprocessed.device_id == "62a44038-3ccb-401e-a69c-6f22152c54a6"),
|
(df_esm_preprocessed.participant_id == 35)
|
||||||
["esm_trigger", "esm_session", "datetime_lj", "esm_instructions", "device_id", "_id"],
|
& (df_esm_preprocessed.esm_session == 7)
|
||||||
|
& (df_esm_preprocessed.device_id == "62a44038-3ccb-401e-a69c-6f22152c54a6"),
|
||||||
|
[
|
||||||
|
"esm_trigger",
|
||||||
|
"esm_session",
|
||||||
|
"datetime_lj",
|
||||||
|
"esm_instructions",
|
||||||
|
"device_id",
|
||||||
|
"_id",
|
||||||
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
|
|
Loading…
Reference in New Issue