integrate instructions into paradigm flow

parent 2ef9154c
......@@ -70,12 +70,6 @@ file in your clone/fork of the repository:
This will gitignore the folder locally on your machine.
# Instructions to participants
All participants should read this instruction text and should also be allowed
to perform some test trials until they have fully understood the paradigm.
see [participant_instructions](https://github.com/sappelhoff/sp_experiment/tree/master/participant_instructions)
---
# Background Literature on the Sampling Paradigm:
......
......@@ -5,6 +5,70 @@ import pandas as pd
from sp_experiment.utils import get_final_choice_outcomes
def run_instructions(kind, monitor='testMonitor', font='', lang='em'):
"""Show experiment instructions on the screen.
Parameters
----------
kind : str
Can be 'general', 'active', and 'passive'.
"""
from psychopy import visual, event
# Define monitor specific window object
win = visual.Window(color=(0, 0, 0), # Background color: RGB [-1,1]
fullscr=True, # Fullscreen for better timing
monitor=monitor,
units='deg',
winType='pyglet')
# Hide the cursor
win.mouseVisible = False
# prepare text object
txt_color = (0.45, 0.45, 0.45)
txt_stim = visual.TextStim(win,
units='deg',
color=txt_color)
txt_stim.height = 1
txt_stim.font = font
if kind == 'general':
txt_stim.text = _provide_general_instr_str(lang=lang)
txt_stim.draw()
win.flip()
event.waitKeys()
elif kind == 'active':
pass
elif kind == 'passive':
pass
win.close()
def _provide_general_instr_str(lang='en'):
"""Provide a welcome screen text."""
if lang == 'de':
welcome_str = ('Wilkommen! Sie werden zwei Aufgaben nacheinander '
'ausführen. Im Folgenden bekommen Sie Anweisungen zur '
'ersten Aufgabe. Dann dürfen Sie einen Test der '
'ersten Aufgabe durchführen. Danach wird die erste '
'Aufgabe gestartet. Wenn Sie mit dieser Aufgabe '
'fertig sind, wird die zweite Aufgabe in den selben '
'Schritten durchgeführt. Das heißt: Erst Anweisung, '
'dann Test, dann Durchführung der Aufgabe.')
elif lang == 'en':
welcome_str = ('Welcome! You will perform two tasks, one after the '
'other. In the following you will get instructions '
'for the first task. Then you are allowed to practice '
'the first task. Then you will perform the first task'
'. After you are done, the second task will be '
'started using the same procedure. That is, first '
'instructions, then practice, then execution of the '
'second task.')
return welcome_str
def provide_blockfbk_str(data_file, current_nblocks, nblocks, lang):
"""Provide a string to be displayed during block feedback.
......@@ -55,7 +119,7 @@ def provide_start_str(is_test, condition, lang):
start_str = (f'Beginn der{mod}Aufgabe {condi}. Druecken Sie eine '
'beliebige Taste um zu beginnen.')
elif lang == 'en':
start_str = (f'Starting the {mod} for task {condi}. '
start_str = (f'Starting the{mod}for task {condi}. '
'Press any key to start.')
return start_str
......
......@@ -49,7 +49,7 @@ from sp_experiment.define_instructions import (run_instructions,
provide_stop_str)
def navigation(nav='initial', bonus='', lang='en'):
def navigation(nav='initial', bonus='', lang='en', yoke_map=None):
"""Lead through a navigation GUI.
Provides the options to run the experiment, test trials, or print out the
......@@ -65,14 +65,19 @@ def navigation(nav='initial', bonus='', lang='en'):
Specify the bonus to be shown.
lang : str
Language, can be 'de' or 'en' for German or English.
yoke_map : dict
Dictionary to infer subject IDs from
Returns
-------
run : bool
"""
if yoke_map is None:
yoke_map = {i: i for i in range(100)}
run = False
auto = False
next = ''
while not nav == 'finished':
# Prepare GUI
myDlg = gui.Dlg(title='Sampling Paradigm Experiment')
......@@ -80,12 +85,13 @@ def navigation(nav='initial', bonus='', lang='en'):
myDlg.addField('What to do?:', choices=['automatic run',
'run experiment',
'run test trials',
'calculate bonus money'])
elif nav == 'testing_cond':
'calculate bonus money',
'show instructions'])
elif nav == 'inquire_condition':
myDlg.addField('Condition:', choices=['A', 'B'])
elif nav == 'calc_bonus':
myDlg.addField('ID:', choices=list(range(1, 21)))
myDlg.addField('ID:', choices=list(yoke_map.keys()))
elif nav == 'show_bonus':
myDlg.addFixedField('Bonus:', bonus)
......@@ -103,14 +109,20 @@ def navigation(nav='initial', bonus='', lang='en'):
print('running experiment now')
run = True
nav = 'finished' # quit navigattion and run experiment
elif ok_data[0] == 'run test trials':
nav = 'testing_cond'
elif nav == 'testing_cond':
elif (ok_data[0] == 'run test trials' or
ok_data[0] == 'show instructions'):
nav = 'inquire_condition'
next = 'test' if ok_data[0].startswith('r') else 'show'
elif next == 'test':
print('preparing test trials now')
# run test trials, then quit program
condition = 'active' if ok_data[0] == 'A' else 'passive'
run_test_trials(condition=condition, lang=lang)
core.quit()
elif next == 'show':
condition = 'active' if ok_data[0] == 'A' else 'passive'
run_instructions(kind=condition, lang=lang)
core.quit()
elif ok_data[0] == 'calculate bonus money':
nav = 'calc_bonus' # ask for ID
elif nav == 'calc_bonus':
......@@ -211,7 +223,7 @@ def prep_logging(yoke_map, auto=False, gui_info=None):
def run_flow(monitor='testMonitor', ser=Fake_serial(), max_ntrls=10,
max_nsamples=12, block_size=10, data_file=None, font=None,
max_nsamples=12, block_size=10, data_file=None, font='',
condition='active', yoke_to=None, is_test=False, lang='en'):
"""Run the experimental flow.
......@@ -767,7 +779,7 @@ if __name__ == '__main__':
yoke_map[i] = j
# Navigate
run, auto = navigation(lang=lang)
run, auto = navigation(lang=lang, yoke_map=yoke_map)
# Perhaps just run (no auto)
if run and not auto:
......@@ -793,13 +805,17 @@ if __name__ == '__main__':
info['sub_id'] = sub_id
# General instructions
run_instructions(kind='general', monitor=monitor, font=font)
run_instructions(kind='general', monitor=monitor, lang=lang, font=font)
# Run test for first condition
if condition == 'active':
run_instructions(kind='active', monitor=monitor, lang=lang,
font=font)
run_test_trials(monitor=monitor, condition=condition, lang=lang)
info['condition2'] = 'passive'
elif condition == 'passive':
run_instructions(kind='passive', monitor=monitor, lang=lang,
font=font)
run_test_trials(monitor=monitor, condition=condition, lang=lang)
info['condition2'] = 'active'
......@@ -816,6 +832,8 @@ if __name__ == '__main__':
font=font)
# Run test for second condition
run_instructions(kind=info['condition2'], monitor=monitor, lang=lang,
font=font)
run_test_trials(monitor=monitor, condition=info['condition2'],
lang=lang)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment