Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,22 +41,11 @@ input_repo_path = 'datasets/emvecchi/therapy_annotation'
|
|
| 41 |
output_repo_path = 'datasets/emvecchi/therapy_annotation/pilot'
|
| 42 |
|
| 43 |
|
| 44 |
-
|
| 45 |
st.set_page_config(page_title="Therapy Session Annotation", layout="wide")
|
| 46 |
st.title("Therapy Session Annotation")
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
"""
|
| 57 |
-
|
| 58 |
to_annotate_file_name = 'to_annotate.csv' # CSV file to annotate
|
| 59 |
-
COLS_TO_SAVE = ['
|
| 60 |
|
| 61 |
agreement_labels = ['strongly disagree', 'disagree', 'neither agree no disagree', 'agree', 'strongly agree']
|
| 62 |
quality_labels = ['very poor', 'poor', 'acceptable', 'good', 'very good']
|
|
@@ -118,11 +107,11 @@ ________________________________________________________________________________
|
|
| 118 |
|
| 119 |
### Description of the research study
|
| 120 |
|
| 121 |
-
In this study, we investigate
|
| 122 |
|
| 123 |
-
The intended use of the results of this study includes
|
| 124 |
|
| 125 |
-
**Time required:** Your participation will take up to an estimated
|
| 126 |
|
| 127 |
**Risks and benefits:** The risks to your participation in this online survey are those associated with basic computer tasks, including boredom, fatigue, mild stress, or breach of confidentiality. Some of the topics discussed in the online posts to be annotated may include violence, suicide or rape. The only benefit to you is the learning experience from participating in a research study. The benefit to society is the contribution to scientific knowledge
|
| 128 |
|
|
@@ -135,7 +124,7 @@ Information that can be used to identify you. The researcher(s) will make every
|
|
| 135 |
|
| 136 |
**Contact:** If at any time you have questions about this study or would like to report any adverse effects due to this study, please contact the researcher(s).
|
| 137 |
|
| 138 |
-
**Trigger Warning:**
|
| 139 |
|
| 140 |
### Consent:
|
| 141 |
Please indicate, in the box below, that you are at least 18 years old, have read and understood this consent form, are comfortable using the English language to complete the survey, and you agree to participate in this online research survey.
|
|
@@ -209,42 +198,30 @@ end_fields: List[Field] = [
|
|
| 209 |
]
|
| 210 |
|
| 211 |
fields: List[Field] = [
|
| 212 |
-
Field(name="
|
| 213 |
Field(type="expander", title="**Preceeding Comment:** *(expand)*", children=[
|
| 214 |
-
Field(name="
|
| 215 |
]),
|
| 216 |
-
Field(name="comment", type="input_col", title="**Comment:**"),
|
| 217 |
-
Field(name="image_name", type="input_col", title=""),# "**Visualization of high contributing properties:**"),
|
| 218 |
|
| 219 |
-
Field(type="container", title="**
|
| 220 |
Field(name="to_moderate", type="y_n_radio",
|
| 221 |
-
title="
|
| 222 |
Field(name="priority_level", type="likert_radio",
|
| 223 |
-
title="
|
| 224 |
]),
|
| 225 |
|
| 226 |
-
Field(type="container", title="**
|
| 227 |
Field(name="mod_function", type="multiselect",
|
| 228 |
-
title="What type of
|
| 229 |
mandatory=False, following_mandatory_values=['Other (please specify)']),
|
| 230 |
Field(name="mod_function_other", type="text", title="*If Other, please specify:*", mandatory=False),
|
|
|
|
| 231 |
]),
|
| 232 |
|
| 233 |
-
Field(type="container", title="**
|
| 234 |
-
Field(name="relevant_properties", type="multiselect",
|
| 235 |
-
title="Which property(s) is most impactful in your assessment? *(Multiple selection possible)*",
|
| 236 |
-
other_params={'choices': property_choices}, mandatory=True, following_mandatory_values=['Other (please specify)']),
|
| 237 |
-
Field(name="relevant_properties_other", type="text", title="*If Other, please specify:*", mandatory=False),
|
| 238 |
-
]),
|
| 239 |
-
|
| 240 |
-
Field(type="container", title="**Moderator Assistance**", children=[
|
| 241 |
Field(name="helpful", type="y_n_radio",
|
| 242 |
-
title="
|
| 243 |
following_mandatory_values=[1]),
|
| 244 |
-
Field(name="mod_assistance", type="multiselect",
|
| 245 |
-
title="If yes, please motivate the benefit it would contribute to the task. *(Multiple selection possible)*",
|
| 246 |
-
other_params={'choices': assistance_choices}, mandatory=False),
|
| 247 |
-
Field(name="mod_assistance_other", type="text", title="*If Other, please specify:*", mandatory=False, skip_mandatory=True),
|
| 248 |
]),
|
| 249 |
|
| 250 |
Field(type="container", title="**Other**", children=[
|
|
@@ -310,6 +287,12 @@ def get_base_path():
|
|
| 310 |
def get_path():
|
| 311 |
return f"{get_base_path()}/{st.session_state.current_index}.json"
|
| 312 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
def display_image(image_path):
|
| 314 |
with hf_fs.open(image_path) as f:
|
| 315 |
img = Image.open(f)
|
|
@@ -334,21 +317,21 @@ def navigate(index_change):
|
|
| 334 |
# disable text input enter to submit
|
| 335 |
# https://discuss.streamlit.io/t/text-input-how-to-disable-press-enter-to-apply/14457/6
|
| 336 |
components.html(
|
| 337 |
-
|
| 338 |
<script>
|
| 339 |
const inputs = window.parent.document.querySelectorAll('input');
|
| 340 |
inputs.forEach(input => {
|
| 341 |
input.addEventListener('keydown', function(event) {
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
height=0
|
| 350 |
)
|
| 351 |
-
|
| 352 |
#st.experimental_rerun()
|
| 353 |
st.rerun()
|
| 354 |
|
|
@@ -362,6 +345,8 @@ def show_field(f: Field, index: int, data_collected):
|
|
| 362 |
st.write(f.title)
|
| 363 |
if f.name == 'image_name':
|
| 364 |
display_image(os.path.join(input_repo_path, 'images', value))
|
|
|
|
|
|
|
| 365 |
else:
|
| 366 |
st.write(value)
|
| 367 |
case 'markdown':
|
|
@@ -509,12 +494,12 @@ st.title("Moderator Intervention Prediction")
|
|
| 509 |
|
| 510 |
|
| 511 |
st.markdown(
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
, unsafe_allow_html=True)
|
| 519 |
|
| 520 |
|
|
@@ -617,11 +602,10 @@ if 0 <= st.session_state.current_index < len(st.session_state.data):
|
|
| 617 |
|
| 618 |
|
| 619 |
st.markdown(
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
| 623 |
-
|
| 624 |
-
|
| 625 |
)
|
| 626 |
|
| 627 |
-
"""
|
|
|
|
| 41 |
output_repo_path = 'datasets/emvecchi/therapy_annotation/pilot'
|
| 42 |
|
| 43 |
|
|
|
|
| 44 |
st.set_page_config(page_title="Therapy Session Annotation", layout="wide")
|
| 45 |
st.title("Therapy Session Annotation")
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
to_annotate_file_name = 'to_annotate.csv' # CSV file to annotate
|
| 48 |
+
COLS_TO_SAVE = ['dialogue_id','dialogue_name','generatedPatient']
|
| 49 |
|
| 50 |
agreement_labels = ['strongly disagree', 'disagree', 'neither agree no disagree', 'agree', 'strongly agree']
|
| 51 |
quality_labels = ['very poor', 'poor', 'acceptable', 'good', 'very good']
|
|
|
|
| 107 |
|
| 108 |
### Description of the research study
|
| 109 |
|
| 110 |
+
In this study, we investigate [...]
|
| 111 |
|
| 112 |
+
The intended use of the results of this study includes [...]
|
| 113 |
|
| 114 |
+
**Time required:** Your participation will take up to an estimated [...] hours. The time required may vary on an individual basis.
|
| 115 |
|
| 116 |
**Risks and benefits:** The risks to your participation in this online survey are those associated with basic computer tasks, including boredom, fatigue, mild stress, or breach of confidentiality. Some of the topics discussed in the online posts to be annotated may include violence, suicide or rape. The only benefit to you is the learning experience from participating in a research study. The benefit to society is the contribution to scientific knowledge
|
| 117 |
|
|
|
|
| 124 |
|
| 125 |
**Contact:** If at any time you have questions about this study or would like to report any adverse effects due to this study, please contact the researcher(s).
|
| 126 |
|
| 127 |
+
**Trigger Warning:** [...]
|
| 128 |
|
| 129 |
### Consent:
|
| 130 |
Please indicate, in the box below, that you are at least 18 years old, have read and understood this consent form, are comfortable using the English language to complete the survey, and you agree to participate in this online research survey.
|
|
|
|
| 198 |
]
|
| 199 |
|
| 200 |
fields: List[Field] = [
|
| 201 |
+
Field(name="patient", type="input_col", title="**Patient::**"),
|
| 202 |
Field(type="expander", title="**Preceeding Comment:** *(expand)*", children=[
|
| 203 |
+
Field(name="dialogue_name", type="input_col", title=""),
|
| 204 |
]),
|
|
|
|
|
|
|
| 205 |
|
| 206 |
+
Field(type="container", title="**Session-/Patient-Specific Properties**", children=[
|
| 207 |
Field(name="to_moderate", type="y_n_radio",
|
| 208 |
+
title="Explicit mention of clinical diagnosis?", mandatory=True),
|
| 209 |
Field(name="priority_level", type="likert_radio",
|
| 210 |
+
title="Emotional State", other_params={'labels': priority_labels}, mandatory=True),
|
| 211 |
]),
|
| 212 |
|
| 213 |
+
Field(type="container", title="**Rupture-Specific Properties**", children=[
|
| 214 |
Field(name="mod_function", type="multiselect",
|
| 215 |
+
title="What type of rupture markers are found? *(Multiple selection possible)*",
|
| 216 |
mandatory=False, following_mandatory_values=['Other (please specify)']),
|
| 217 |
Field(name="mod_function_other", type="text", title="*If Other, please specify:*", mandatory=False),
|
| 218 |
+
Field(name="rupture_line", type="text", title="What lines demonstrate the rupture markers you notice?", mandatory=False),
|
| 219 |
]),
|
| 220 |
|
| 221 |
+
Field(type="container", title="**True-To-Patient-Prompt Properties**", children=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 222 |
Field(name="helpful", type="y_n_radio",
|
| 223 |
+
title="Did the patient remain true to the provided patient prompt?", mandatory=True,
|
| 224 |
following_mandatory_values=[1]),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 225 |
]),
|
| 226 |
|
| 227 |
Field(type="container", title="**Other**", children=[
|
|
|
|
| 287 |
def get_path():
|
| 288 |
return f"{get_base_path()}/{st.session_state.current_index}.json"
|
| 289 |
|
| 290 |
+
def display_dialogue(dialogue_path):
|
| 291 |
+
with open(dialogue_path, "r", encoding="utf-8") as f:
|
| 292 |
+
lines = f.readlines()
|
| 293 |
+
for i, line in enumerate(lines, start=1):
|
| 294 |
+
st.write(f"{i:03d}: {line.strip()}")
|
| 295 |
+
|
| 296 |
def display_image(image_path):
|
| 297 |
with hf_fs.open(image_path) as f:
|
| 298 |
img = Image.open(f)
|
|
|
|
| 317 |
# disable text input enter to submit
|
| 318 |
# https://discuss.streamlit.io/t/text-input-how-to-disable-press-enter-to-apply/14457/6
|
| 319 |
components.html(
|
| 320 |
+
"""
|
| 321 |
<script>
|
| 322 |
const inputs = window.parent.document.querySelectorAll('input');
|
| 323 |
inputs.forEach(input => {
|
| 324 |
input.addEventListener('keydown', function(event) {
|
| 325 |
+
if (event.key === 'Enter') {
|
| 326 |
+
event.preventDefault();
|
| 327 |
+
}
|
| 328 |
+
});
|
| 329 |
+
});
|
| 330 |
+
</script>
|
| 331 |
+
""",
|
| 332 |
height=0
|
| 333 |
)
|
| 334 |
+
|
| 335 |
#st.experimental_rerun()
|
| 336 |
st.rerun()
|
| 337 |
|
|
|
|
| 345 |
st.write(f.title)
|
| 346 |
if f.name == 'image_name':
|
| 347 |
display_image(os.path.join(input_repo_path, 'images', value))
|
| 348 |
+
elif f.name == 'dialogue_name':
|
| 349 |
+
display_dialogue(os.path.join(input_repo_path, 'dialogues', value))
|
| 350 |
else:
|
| 351 |
st.write(value)
|
| 352 |
case 'markdown':
|
|
|
|
| 494 |
|
| 495 |
|
| 496 |
st.markdown(
|
| 497 |
+
"""<style>
|
| 498 |
+
div[data-testid="stMarkdownContainer"] > p {
|
| 499 |
+
font-size: 1rem;
|
| 500 |
+
}
|
| 501 |
+
section.main > div {max-width:60rem}
|
| 502 |
+
</style>"""
|
| 503 |
, unsafe_allow_html=True)
|
| 504 |
|
| 505 |
|
|
|
|
| 602 |
|
| 603 |
|
| 604 |
st.markdown(
|
| 605 |
+
"""<style>
|
| 606 |
+
div[data-testid="InputInstructions"] {
|
| 607 |
+
visibility: hidden;
|
| 608 |
+
}
|
| 609 |
+
</style>""", unsafe_allow_html=True
|
| 610 |
)
|
| 611 |
|
|
|