How to make routine stop when subjects eyes are looking at a target using Eyelink 1000

Hi
I am looking for assistance with a visual search task linked with Eyelink 1000. My task involves a target appearing on a screen and when a participant looks at the target I want the routine to end. I have adapted a very similar task where the routine ended when the joystick moving a cursor was over the target. I have included below the code (added to builder) I have adapted to try and achieve this and also included the error message that I get.

Code
Begin routine
''TargetTimer = core.Clock()
inTarget = False
outTarget = True

Each frame
eyeinfo = eyetracker.getLastSample()
stimulus = outer_target
print(eyeinfo)

outer_target.tStop = t # local t and not account for scr refresh
outer_target.tStopRefresh = tThisFlipGlobal # on global time
win.timeOnFlip(outer_target, ‘tStopRefresh’) # time at next scr refres

#each frame-----
if stimulus.contains(eyeinfo) and not inTarget:
TargetTimer.reset()
inTarget = True
outTarget = False

#exits quad
if not stimulus.contains(eyeinfo) and inTarget:
inTarget = False
outTarget = True

if inTarget:
if TargetTimer.getTime() > 0.5:
continueRoutine = False’’

error message
File “\adf\storage\D\M\DXM986\Motor task\Beth’sTask\visual search task_lastrun.py”, line 647, in
if stimulus.contains(eyeinfo) and not inTarget:
File “C:\Users\dxm986\AppData\Local\Programs\PsychoPy4\lib\site-packages\psychopy\visual\basevisual.py”, line 879, in contains
xy = convertToPix(xy, pos=(0, 0), units=units, win=self.win)
File “C:\Users\dxm986\AppData\Local\Programs\PsychoPy4\lib\site-packages\psychopy\tools\monitorunittools.py”, line 94, in convertToPix
return unit2pixFunc(vertices, pos, win)
File “C:\Users\dxm986\AppData\Local\Programs\PsychoPy4\lib\site-packages\psychopy\tools\monitorunittools.py”, line 32, in _cm2pix
return cm2pix(pos + vertices, win.monitor)
ValueError: operands could not be broadcast together with shapes (2,) (32,)
displayAPI: init_net() start use_tcp_only=0

Any help with this will be gratefully received

Dave

Hi There,

Making gaze contingent tasks in PsychoPy actually no longer required code at all. Use the Eyetracking > ROI component and set the End Routine On to “look at” - you can then set a look duration threshold and that will mean the routine ends after the participant has looked at the region of interest.

Hope this helps,

Becca