add pictures for instructions, allow lang selection in GUI

parent ddf3079d
......@@ -55,10 +55,24 @@ def run_instructions(kind, monitor='testMonitor', font='', lang='em'):
for text in texts:
txt_stim.text = text
txt_stim.draw()
if '' in text:
img_stim.image = op.join(img_dir, 'bbtk_layout.png')
if 'a' in text:
img_stim.image = op.join(img_dir, 'bbox_photo.png')
img_stim.draw()
elif 'b' in text:
img_stim.image = op.join(img_dir, 'start_cropped.png')
img_stim.draw()
elif 'c' in text:
img_stim.image = op.join(img_dir, 'action_cropped.png')
img_stim.draw()
elif 'd' in text:
img_stim.image = op.join(img_dir, 'choice_cropped.png')
img_stim.draw()
elif 'e' in text:
img_stim.image = op.join(img_dir, 'error_cropped.png')
img_stim.draw()
elif 'f' in text:
img_stim.image = op.join(img_dir, 'fix_stims.png')
img_stim.draw()
win.flip()
event.waitKeys()
......@@ -76,11 +90,16 @@ def run_instructions(kind, monitor='testMonitor', font='', lang='em'):
win.close()
def _provide_active_instr_strs(lang='en'):
def _provide_active_instr_strs(lang='en', max_nsamples=12):
"""Provide active instr texts."""
texts = list()
if lang == 'de':
pass
texts.append('a')
texts.append('b')
texts.append('c')
texts.append('d')
texts.append('e')
texts.append('f')
elif lang == 'en':
pass
return texts
......
......@@ -89,9 +89,11 @@ def navigation(nav='initial', bonus='', lang='en', yoke_map=None):
'show instructions'])
elif nav == 'inquire_condition':
myDlg.addField('Condition:', choices=['A', 'B'])
myDlg.addField('Language:', choices=['de', 'en'])
elif nav == 'calc_bonus':
myDlg.addField('ID:', choices=list(yoke_map.keys()))
myDlg.addField('Language:', choices=['de', 'en'])
elif nav == 'show_bonus':
myDlg.addFixedField('Bonus:', bonus)
......@@ -117,16 +119,16 @@ def navigation(nav='initial', bonus='', lang='en', yoke_map=None):
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)
run_test_trials(condition=condition, lang=ok_data[1])
core.quit()
elif next == 'show':
condition = 'active' if ok_data[0] == 'A' else 'passive'
run_instructions(kind=condition, lang=lang)
run_instructions(kind=condition, lang=ok_data[1])
core.quit()
elif ok_data[0] == 'calculate bonus money':
nav = 'calc_bonus' # ask for ID
elif nav == 'calc_bonus':
bonus = calc_bonus_payoff(int(ok_data[0]), lang=lang)
bonus = calc_bonus_payoff(int(ok_data[0]), lang=ok_data[1])
nav = 'show_bonus'
elif nav == 'quit':
core.quit() # We have shown the bonus. Now quit program
......
......@@ -42,10 +42,10 @@ def test_calc_bonus_payoff():
"""Test bonus calculation."""
# Check for non-present data
bonus = calc_bonus_payoff(998)
assert bonus == 'did not complete "active" condition yet.'
assert bonus == 'did not yet complete task "A".'
bonus = calc_bonus_payoff(999)
assert bonus == 'did not complete "passive" condition yet.'
assert bonus == 'did not yet complete task "B".'
# present data ... temporarily copy over a test file
tmp_fpath1 = op.join(data_dir, 'sub-998_task-spactive_events.tsv')
......
......@@ -60,7 +60,11 @@ def calc_bonus_payoff(sub_id, conversion_factor=0.01, lang='en'):
fname = f'sub-{sub_id:02d}_task-sp{condition}_events.tsv' # noqa: E999
fpath = op.join(data_dir, fname)
if not op.exists(fpath):
bonus = f'did not complete "{condition}" condition yet.'
modstr = 'A' if condition == 'active' else 'B'
if lang == 'de':
bonus = f'Aufgabe "{modstr}" wurde noch nicht durchgefuehrt.'
elif lang == 'en':
bonus = f'did not yet complete task "{modstr}".'
return bonus
else:
df = pd.read_csv(fpath, sep='\t')
......
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