I’m trying to code up an eye tracking script that is able to execute a certain command when a blink has been detected.
The way I’m doing it right now (as shown below) is that when no gaze position is detected, execute the certain command.
This is not exactly ideal since saccades off the screen would also be considered as a ‘blink’ in this case. There wasn’t any explicit commands listed in the iohub guide that I thought could be use to measure pupil size live. Does anyone have an advice for this?
blinked = 0
for disptime in range(displaytime):
reopened = False #track if eyes reopened # Get the latest gaze position in display coord space. gpos=tracker.getLastGazePosition() if isinstance(gpos,(tuple,list)): # If we have a gaze position from the tracker, draw the # background image and then the gaze_cursor. gaze_dot.setPos(gpos) gaze_dot.draw() else: blinked = 1 print 'Blink occurred just before/at:', stimlist[counter] while reopened == False: gpos=tracker.getLastGazePosition() if isinstance(gpos,(tuple,list)): flip_time=win.flip() self.hub.sendMessageEvent("IMAGE_UPDATE %.3f %.3f"%(gpos,gpos),sec_time=flip_time) reopened = True else: flip_time=win.flip() self.hub.sendMessageEvent("IMAGE_UPDATE [NO GAZE]",sec_time=flip_time)