2009-10-31 06:38:33 PDT
Hi Andrej:
I'm sorry that I did not respond earlier because there is a much easier way to solve this problem. The .present() methods are just convenience functions for displaying a stimulus, but I actually rarely use them in more complex situations and use the core display functions instead that allow me to update the screen when I please.
Here's some code (modify to suit):
#!/usr/bin/python
# get access to pyepl objects & functions
from pyepl.locals import *
# create an experiment object:
# parse command-line arguments
# & initialize pyepl subsystems
exp = Experiment()
exp.setBreak()
# Create a VideoTrack object for interfacing
# with monitor, and a KeyTrack object for
# interfacing with keyboard
vt = VideoTrack("video")
kt = KeyTrack("key")
at = AudioTrack("audio")
# reset the display to black
vt.clear("black")
# create a PresentationClock object
# for timing
clock = PresentationClock()
def fixed_stim_with_response(stim,duration,bc,clock):
"""Present stim for fixed duration, but getting response anytime in
that time range."""
feedback = Text('Pressed!!!')
shown = vt.showProportional(stim,.5,.3)
onTime = vt.updateScreen(clock)
# keep it up for desired time
startTime = clock.get()
endTime = startTime + duration
# get response
kret,timestamp = bc.waitWithTime(maxDuration = duration,
clock=clock)
# give feedback
fshown = vt.showProportional(feedback,.5,.7)
vt.updateScreen() # no clock needed b/c we want it now
if timestamp[0] < endTime:
# must still delay a bit
clock.delay(endTime-timestamp[0])
# remove the stims
vt.unshow(shown,fshown)
vt.updateScreen(clock)
# return button time and what key
return (kret,timestamp)
# set up a key chooser for the responses
respChooser = kt.keyChooser('SPACE')
# set up the stim
stim = Text('Press Space!!!')
for dur in [1000,2000,3000]:
fixed_stim_with_response(stim,dur,respChooser,clock)
clock.delay(1000)
Text("Done").present(clk=clock,duration=2000)
Where I added that feedback you can play sounds or whatever you like...
Best,
Per