I am trying to detect when a timer has expired in order to capture the time it takes a person to respond to a change. Using viztask, my code looks something like
Code:
# Start a timer
viz.starttimer(0, 1, viz.PERPETUAL)
# define our changing function
def changeThing():
# change the thing
thing = thing + change
# Register the timer callback
viz.callback(viz.TIMER_EVENT, changeThing)
# Define the experimental loop
def experiment():
# Initialize trial number
trial = 1
# Wait for spacebar to begin experiment
yield viztask.waitKeyDown(' ')
while trial <= numTrials:
# Update the instructions
msgbox.message('Trial ' + str(trial))
# Wait for the timer
yield viztask.waitEvent( viz.TIMER_EVENT )
# Wait for response
yield viztask.waitKeyDown(' ')
# Increment the trial number
trial = trial + 1
# Schedule the experiment
viztask.schedule( experiment() )
which I thought would work, but never gets past the waitEvent. I have tried using a timer callback and vizact.ontimer, but neither works to move the script forward (although the function that is called with the timer works fine). Am I doing something wrong, or is this not possible to do? Or do I need a different approach? This was supposed to be a simple example for class, and I don't want to cover custom events yet. Any help is appreciated.
Thanks!