Welcome!

Sign in with your CogSci, Facebook, Google, or Twitter account.

Or register to create a new account.

We'll use your information only for signing in to this forum.

Supported by

Delay script while running eye tracker?

reedjireedji Posts: 1

Hi Folks,

I'm writing an experiment in which participants are rewarded if their gaze is within an specified area end the end of random-length intervals between 4 and 7 seconds.

while(True):
    delay = 3*random.random() + 4
    time.sleep(delay)
    sample = eyetracker.sample()
    inRangeBool = inRange(sample[0],sample[1]) #returns True if the gaze is in the area of interest
    if inRangeBool:
        my_sampler.play()  #plays a pleasant sound associated with the reward

I'm using the dummy mouse eyetracker. When the script gets to the time.sleep command, the mouse freezes and doesn't move until the sleep function ends, which suggests that the function puts the eyetracker to sleep as well. The sound still plays (or doesn't) at the end of the interval. How can I tell the script to wait for the specified amount of time without freezing the eyetracker?

Comments

  • sebastiaansebastiaan Posts: 2,813

    Hi,

    The eye tracker won't freeze if you sleep the experiment. That being said, you haven't specified what kind of eye tracker you're using. (But whatever it is: it won't freeze!)

    Incidentally, your script is an infinite loop, without any way to break it. I would at the very least flush the keyboard, so that you can exit it by pressing escape.

    Cheers!
    Sebastiaan

    There's much bigger issues in the world, I know. But I first have to take care of the world I know.
    cogsci.nl/smathot

Sign In or Register to comment.