def create_training_trials(config, win, trials_description): trials = [] for _, trial in trials_description.items(): t = Trial() t.info = trial t.prepare_visualisation(config, win) trials.append(t) return trials
def run_trial(win, n): trial = Trial(win, config, n) stim_time = config['CONST_TIME'] + n * config['LEVEL_TIME'] acc = 0 rt = -1 answer_type = None window.callOnFlip(response_clock.reset) event.clearEvents() trial.set_auto_draw(True) window.flip() while response_clock.getTime() < stim_time: if stim_time - response_clock.getTime() < config['SHOW_CLOCK']: clock_image.draw() window.flip() keys = event.getKeys(keyList=config["KEYS"]) if keys: rt = response_clock.getTime() idx = config["KEYS"].index(keys[0]) answer_type = trial.answers[idx].check_permutation(trial.task) acc = 1 if answer_type == 'answer' else -1 break check_exit() trial.set_auto_draw(False) window.flip() time.sleep(config['JITTER_TIME']) return acc, rt, stim_time, n, answer_type
def run_trial(n): trial = Trial(n_relations=n) trial.prepare_to_draw(win=window, main_fig_size=config['MAIN_FIG_SIZE'], main_move_y=config['MAIN_MOVE_Y'], answers_fig_size=config['ANSWERS_FIG_SIZE'], fig_offset=config['FIG_OFFSET'], answers_pos=[ config["ANSWERS_1_POS"], config["ANSWERS_2_POS"], config["ANSWERS_3_POS"] ], arrow_long=config['ARROW_LONG'], arrow_width=config['ARROW_WIDTH'], arrow_color=config['ARROW_COLOR']) stim_time = config['CONST_TIME'] + trial.n_relations * config['LEVEL_TIME'] acc = 0 rt = -1 answer_type = None window.callOnFlip(response_clock.reset) event.clearEvents() trial.set_auto_draw(True) window.flip() while response_clock.getTime() < stim_time: if stim_time - response_clock.getTime() < config['SHOW_CLOCK']: clock_image.draw() check_exit() window.flip() keys = event.getKeys(keyList=KEYS) if keys: rt = response_clock.getTime() idx = KEYS.index(keys[0]) answer_type = trial.answers[idx].name acc = 1 if answer_type == 'answer' else -1 break trial.set_auto_draw(False) window.flip() time.sleep(config['JITTER_TIME']) return acc, rt, stim_time, trial.n_relations, answer_type
def create_experiment_trials(config, win, word_bank, trials_info): trials = [] used_words = [] for trial in trials_info: t = Trial() t.prepare_info(word_bank=word_bank, n_answers=trial["N_ANSWERS"], task_length=trial["TASK_LENGTH"], trial_with_distractor=trial["DISTRACTOR"], distractor_category=trial["DISTRACTOR_CATEGORY"], task_category=trial["TASK_CATEGORY"], used_words=[y for x in used_words for y in x]) used_words = update_used_words(used_words, t, config["N_BACK"]) t.prepare_visualisation(config, win) trials.append(t) return trials