psychopy.org | Reference | Downloads | Github

getLastGazePosition() only gives new gaze position every 15 ms

In my experiment, I need to detect the onset of a saccade as quickly as possible. I want to do this by checking whether the current gaze position is not within a certain boundary (the fixationArea) anymore. Ideally, I would like to check the gaze position every 1 ms, as the Eyelink eye tracker uses a sampling rate of 1000 Hz. But when I use getLastGazePosition() in a while loop, I only receive a new gaze position ca. every 15 ms, which is too long is some cases.

My code snippet is as follows:

# draw objects (stationary)
…
win.flip()

# check if saccade has started
while not saccadeStarted:
    core.wait(0.010, hogCPUperiod=0.005)  # room to breathe for CPU?
    gazePos = myTracker.getLastGazePosition()
    if type(gazePos) in [list, tuple]:
        print (globalClock.getTime(), gazePos)
        if not fixationArea.contains(gazePos, units= 'pix' ):
        saccadeStarted = True

# draw new object
…
win.flip()

Without core.wait() in the while loop, python crashes completely after some time. With the core.wait() function included, it runs, but I only receive a new gaze position after around 15 ms.

For example: If I put in core.wait(0.001, hogCPUperiod=0.001), it prints a position every millisecond (a little bit more of course), but it is the same position values for around 15 prints. If I e.g. enter core.wait(0.002, hogCPUperiod=0.001) or core.wait(0.01, hogCPUperiod=0.005), the code only prints the new gaze position every 15 ms.

Why does it take so long to receive new gaze positions? Do you have any ideas on what I need to change to be able to receive gaze positions more frequently?

I am completely new to PsychoPy, so any help or suggestions would be very much appreciated.

(Working with: Windows PC, PsychoPy 1.85.1, ioHub to control Eye Link1000 eye tracker)

Btw: A similar thing also occurs when using gazePos = myMouse.getPosition() instead of gazePos = myTracker.getLastGazePosition() as a sort of simulation mode.

If anybody ever comes across the same problem:
I have solved it for my experiment by using PyLink instead of ioHub for the communication with the eye-tracker.
With PyLink I was able to receive new gaze positions a lot more frequently.
I’ve also figured out, that the while loop also works without the core.wait() time if print() is removed from it.