-
-
Save neklektyk/4b48ea0241e77644d855 to your computer and use it in GitHub Desktop.
inline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from psychopy import core | |
from pyglet.window import key | |
win = self.experiment.window | |
canvas = self.copy_sketchpad('vezba_stimulusi') | |
response = key.KeyStateHandler() | |
self.experiment.window.winHandle.push_handlers(response) | |
t_show = canvas.show() | |
clock = core.Clock() | |
start_time = clock.getTime() | |
duration = 20 | |
# info = visual.TextStim(win, pos=(0,0), text='Pritisnite odgovarajuci taster') | |
time_a_only_pressed = 0 | |
time_l_only_pressed = 0 | |
time_al_pressed = 0 | |
while clock.getTime() - start_time < duration: | |
# Wait while some button not pressed | |
print 'outer loop' | |
while not (response[key.A] or response[key.L]): | |
if clock.getTime() - start_time > duration: | |
break | |
t_show = canvas.show() | |
# win.flip() | |
print 'pritisnuto a ili l' | |
time_first_press = clock.getTime() # some button pressed | |
# Button A pressed | |
if response[key.A]: | |
print 'pritisnuto a %s' % time_first_press | |
while response[key.A] and not response[key.L]: | |
if clock.getTime() - start_time > duration: | |
break | |
t_show = canvas.show() | |
# win.flip() | |
print 'ceka se na ne A ili L' | |
time_second = clock.getTime() | |
if not response[key.A]: | |
time_a_only_pressed += time_second - time_first_press | |
print 'pustio a %s' % time_a_only_pressed | |
else: | |
# Both A and L pressed | |
print 'pritisnuto a i l' | |
time_a_only_pressed += time_second - time_first_press | |
print 'a only was pressed %s' % time_a_only_pressed | |
time_first_press = time_second | |
while response[key.A] and response[key.L]: | |
if clock.getTime() - start_time > duration: | |
break | |
t_show = canvas.show() | |
# win.flip() | |
print 'pustio nesto' | |
time_second = clock.getTime() | |
time_al_pressed += time_second - time_first_press | |
print 'time_al_pressed %s' % time_al_pressed | |
elif response[key.L]: | |
print 'pritisnuto L %s' % time_first_press | |
while response[key.L] and not response[key.A]: | |
if clock.getTime() - start_time > duration: | |
break | |
t_show = canvas.show() | |
# win.flip() | |
time_second = clock.getTime() | |
if not response[key.L]: | |
print 'pustio l %s' % time_second | |
time_l_only_pressed += time_second - time_first_press | |
else: | |
# Both A and L pressed | |
time_l_only_pressed += time_second - time_first_press | |
time_first_press = time_second | |
print 'pritisnuta oba %s' % time_first_press | |
while response[key.A] and response[key.L]: | |
if clock.getTime() - start_time > duration: | |
break | |
t_show = canvas.show() | |
# win.flip() | |
time_second = clock.getTime() | |
print 'pustio nesto %s' % time_second | |
time_al_pressed += time_second - time_first_press | |
print 'zavrsio posaoooo' | |
exp.set('time_a_only_pressed', time_a_only_pressed) | |
exp.set('time_l_only_pressed', time_l_only_pressed) | |
exp.set('time_al_pressed', time_al_pressed) | |
print 'zapisao rezultate' | |
print 'vreme izvrsavanja %s' % (clock.getTime() - start_time) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment