Retrieve Fixation Events using Iohub

Got it! Thanks for the advice. I like the N samples in a row outside of the fixation region approach. This is the algorithm I came up with (open to better faster versions):

import numpy as np
#
N=4
ones = np.ones(N)
for i in range(15):
    samples = et.getEvents(event_type_id=EventConstants.MONOCULAR_EYE_SAMPLE)
    not_in_region = []
    eyeInRegion = True
    if len(samples) > N: #length of samples array ~33 on average, sampling at 2000Hz
        for s in samples:
            not_in_region.append(not self.eye.gazeOkayRegion.contains(*[s.gaze_x, s.gaze_y]))
        not_in_region = np.convolve(np.array(not_in_region), ones, "valid")
        eyeInRegion = False if any(not_in_region == N) else True
    if not eyeInRegion:
        #present text indicating broken fixation
        win.flip() 
        break
    #code to draw stimuli presented for 250ms if eyeInRegion True over 15 iterations of code in loop
    win.flip()

I’m just not sure if this is the fastest approach to avoid dropping of frames because the timing to loop through all events in samples in addition to the overhead of drawing stimuli afterwards before calling win.flip() may be greater than 16.77777ms (60Hz) in some instances (depending on the sampling rate of the eyetracker).