summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-07-20 12:11:59 +0200
committerNiclas Dobbertin <niclas.dobbertin@mailbox.org>2023-07-20 12:11:59 +0200
commit07183cd742f4cbbcad1b0770906f0adbd33f4512 (patch)
tree6b0d3300ae833265c29a03867742a6062e2e65a3
parentd62db260942bde9d22a5ecaf85ecc040742d74b6 (diff)
use frensch procedures
-rw-r--r--master_thesis/frensch_task.py90
1 files changed, 48 insertions, 42 deletions
diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py
index 0c66254..44d542f 100644
--- a/master_thesis/frensch_task.py
+++ b/master_thesis/frensch_task.py
@@ -3,6 +3,7 @@ from __future__ import annotations
from psychopy import constants, core, event, gui, visual
from collections import namedtuple
+import frensch_procedures
DisplayVariable = namedtuple("DisplayVariable", ["name", "values"])
@@ -14,7 +15,7 @@ def experiment_shutdown():
core.quit()
-WIN = visual.Window((800, 600), fullscr=True, units="pix")
+WIN = visual.Window((2560, 1440), fullscr=True, units="pix")
MONITOR_FPS = 60
# Cancel experiment anytime with Esc
@@ -70,44 +71,49 @@ def generate_procedure_display(procedure: DisplayProcedure):
return stim_procedure
-solid = DisplayVariable("SOLID", [6])
-algae = DisplayVariable("ALGAE", [8])
-lime = DisplayVariable("LIME", [3, 5, 1, 9])
-toxin = DisplayVariable("TOXIN", [4, 8, 7, 2])
-x_positions = [-600, -300, 0, 300]
-# x_positions = [-600, -300]
-
-stims = generate_variable_display([solid, algae, lime, toxin], x_positions)
-
-p1 = DisplayProcedure("Index 1 = Solid * (Lime_4 - Lime_2) = ", 1)
-p1 = generate_procedure_display(p1)
-stims.append(p1)
-
-stim_answer_box = visual.TextBox2(
- WIN,
- "",
- letterHeight=50,
- pos=(0, -200),
- size=[150, 70],
- editable=True,
- fillColor="white",
- color="black",
- alignment="center",
-)
-stims.append(stim_answer_box)
-
-not_finished = True
-answer = "not answered"
-while not_finished:
- stim_answer_box.hasFocus = True
- for stim in stims:
- stim.draw()
- WIN.flip()
- answer = stim_answer_box.text
- if "\n" in stim_answer_box.text:
- not_finished = False
-
-
-event.waitKeys(keyList=["space"])
-
-print(f"Answer: {answer}")
+def run_trial():
+ water_sample = frensch_procedures.random_WaterSample()
+ water_sample.print_all()
+
+ solid = DisplayVariable("SOLID", [water_sample.solid])
+ algae = DisplayVariable("ALGAE", [water_sample.algae])
+ lime = DisplayVariable("LIME", water_sample.lime)
+ toxin = DisplayVariable("TOXIN", water_sample.toxin)
+ x_positions = [-600, -300, 0, 300]
+
+ stims = generate_variable_display([solid, algae, lime, toxin], x_positions)
+
+ p1 = DisplayProcedure(water_sample.index1_str(), water_sample.index1())
+ p1 = generate_procedure_display(p1)
+ stims.append(p1)
+
+ stim_answer_box = visual.TextBox2(
+ WIN,
+ "",
+ letterHeight=50,
+ pos=(0, -200),
+ size=[150, 70],
+ editable=True,
+ fillColor="white",
+ color="black",
+ alignment="center",
+ )
+ stims.append(stim_answer_box)
+
+ not_finished = True
+ answer = "not answered"
+ while not_finished:
+ stim_answer_box.hasFocus = True
+ for stim in stims:
+ stim.draw()
+ WIN.flip()
+ answer = stim_answer_box.text
+ if "\n" in stim_answer_box.text:
+ not_finished = False
+
+
+ event.waitKeys(keyList=["space"])
+
+ return answer
+
+print(f"Answer: {run_trial()}")