From d34a6ab6a2c8e386b4687c5d8e9326fc5d45be81 Mon Sep 17 00:00:00 2001 From: Niclas Dobbertin Date: Sun, 27 Aug 2023 13:16:20 +0200 Subject: add 7th proc, constrained sampling --- master_thesis/frensch_task.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'master_thesis/frensch_task.py') diff --git a/master_thesis/frensch_task.py b/master_thesis/frensch_task.py index 65f950d..ad67ee5 100644 --- a/master_thesis/frensch_task.py +++ b/master_thesis/frensch_task.py @@ -18,6 +18,10 @@ def experiment_shutdown(): WIN = visual.Window((2560, 1440), fullscr=True, units="pix") MONITOR_FPS = 60 +TRAIN_TRIALS = 1 # 75 +TEST_TRIALS = 1 # 50 +ORDER_CONDITIONS = ["fixed", "random", "blocked"] +PROCEDURE_KEYS = ["1", "2", "3", "4", "5", "6", "overall"] # Cancel experiment anytime with Esc event.globalKeys.add(key="escape", func=experiment_shutdown, name="shutdown") @@ -71,16 +75,9 @@ def generate_procedure_display(procedure: DisplayProcedure, position): ) return stim_procedure -def watersample_all_positive(water_sample): - for proc in procedure_keys: - if water_sample.procedure_dict()[proc][0]() < 0: - return False - return True def run_trial(procedure_keys: list, condition): - water_sample = frensch_procedures.random_WaterSample() - while not watersample_all_positive(water_sample): - water_sample = frensch_procedures.random_WaterSample() + water_sample = frensch_procedures.constrained_WaterSample() water_sample.print_all() if condition == "random": @@ -124,6 +121,7 @@ def run_trial(procedure_keys: list, condition): not_finished = True answer = "not answered" + start_time = core.monotonicClock.getTime() while not_finished: stim_answer_box.hasFocus = True for stim in stims: @@ -137,32 +135,32 @@ def run_trial(procedure_keys: list, condition): # answer = "" if "\n" in stim_answer_box.text: not_finished = False + answer_time = core.monotonicClock.getTime() - start_time + print(f"time to answer: {answer_time}") answers.append(answer.replace("\n", "")) event.waitKeys(keyList=["space"]) return answers + intro = visual.TextBox2(WIN, "Introduction") intro.draw() WIN.flip() event.waitKeys(keyList=["space"]) -order_conditions = ["fixed", "random", "blocked"] - -procedure_keys = ["1", "2", "3", "4", "5", "6", "overall"] -train_procedures = procedure_keys[:-1] +train_procedures = PROCEDURE_KEYS[:-1] random.shuffle(train_procedures) transfer_procedure = train_procedures[-1] train_procedures = train_procedures[:-1] -train_procedures.append(procedure_keys[-1]) +train_procedures.append(PROCEDURE_KEYS[-1]) print(train_procedures) -for _ in range(1): - print(f"Answer: {run_trial(train_procedures, order_conditions[0])}") +for _ in range(TRAIN_TRIALS): + print(f"Answer: {run_trial(train_procedures, ORDER_CONDITIONS[0])}") train_procedures[2] = transfer_procedure print(train_procedures) -for _ in range(1): - print(f"Answer: {run_trial(train_procedures, order_conditions[0])}") +for _ in range(TEST_TRIALS): + print(f"Answer: {run_trial(train_procedures, ORDER_CONDITIONS[0])}") -- cgit v1.2.3