-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
89 lines (68 loc) · 2.5 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- encoding: utf-8 -*-
import os
import os.path as op
import sys
from pathlib import Path
from psychopy import core, visual
test = False
# make sure the experiment is on the PYTHONPATH
this_file = Path(__file__)
print(this_file)
if this_file == Path('run.py'):
this_dir = os.getcwd()
exp_dir = Path(this_dir)
src_dir = Path(this_dir).parents[0]
print(this_dir)
else:
exp_dir = Path(__file__).parents[0]
src_dir = Path(__file__).parents[1]
print(exp_dir)
print(src_dir)
sys.path = [str(exp_dir), str(src_dir)] + sys.path
from chainsaw.instructions import Instructions
from chainsaw.exp_utils import prepare_instructions
from exp import RefBackExp
def run(test=False):
'''Run the experiment.'''
exp = RefBackExp(exp_dir)
lang = ['pl', 'eng'] if exp.settings['language'] == 'pl' else ['eng', 'pl']
exp.get_subject_info(
age=False, gender=True,
additional={'language': lang, 'skip instructions': False,
'send_triggers': exp.send_triggers})
window = visual.Window(
monitor='testMonitor', units="height", fullscr=True)
exp.set_window(window)
exp.create_stimuli()
# make sure there is a folder for the sounds
sub = exp.subject['id']
# run main
exp.send_trigger(exp, exp.triggers['exp_start'])
core.wait(0.05)
# instructions?
text_params = dict(height=0.045, units='height')
gender_index = int(exp.subject['gender'] == 'male')
pl_ending = ['owa', 'ów'][gender_index]
this_msg = (rf'Jeśli jesteś got{pl_ending}, naciśnij dowolny przycisk.')
exp.present_break(text=this_msg, text_params=text_params)
# get ready slide
block_n = 1
exp.create_trials(block_n=block_n)
exp.show_all_trials(subject_postfix=f'_block_{block_n}')
# info - koniec treningu
this_msg = ('To koniec części treningowej.\nInformacja zwrot'
'na (kolorowe kółka) nie będzie już wyświetlana.')
exp.present_break(text=this_msg, text_params=text_params)
for block_n in range(2, 6):
exp.create_trials(block_n=block_n)
exp.show_all_trials(subject_postfix=f'_block_{block_n}',
feedback=False)
exp.present_break(text=f'Koniec {block_n} z 5 części badania.',
text_params=text_params)
# final thank you slide
exp.present_break(text='Dziękujemy za udział w badaniu!',
text_params=text_params)
# close the experiment
core.quit()
if __name__ == '__main__':
run(test=test)