Running faster loops while flipping for videos

Dear community,

We are coding an experiment with real-time interactions (e.g. gaze contingent) while playing a video. We intend to perform jumps in the video when certain conditions are met. The difficulty we encountered is, as the continuous playing of the video requires flipping the window each frame, our for-loop for checking for the triggering condition also got limited by the refresh rate. A simple version of our code is as follows:

video.play()
video.autoDraw = True
while core.getTime() < 10:
    boolean = check_something()
    if boolean:
        video.pause()
        video.seek(...)
        video.play()
    win.flip()

We want to run check_something() as frequently as possible while not interfering with video playback. Any suggestions on how to improve this?

Many thanks in advance!

It depends a little on what kind of condition you are working with and how the eye-tracker is set up. Basically, the ideal solution is that check_something() looks at all the samples the eye-tracker has recorded since the last time check_something() was called (i.e., checks a buffer rather than just the most recent data). Then you only need to call check_something() once per frame anyway.

There’s a solution along these lines here assuming the relevant functions still work: Retrieve Fixation Events using Iohub - #3 by sol

1 Like