psychopy.org | Reference | Downloads | Github

Eye-tracking with EyeLink 1000 plus

PsychoPy version: 2020.2.10

Hi, I´m trying to use the implement eye-tracking in my script. However, something does not seem to work. Every time Psychopy reaches the code where the eye-tracker is started, it crashes and I have to reboot the system.

In Begin Routine I have the following code:

from psychopy.iohub import launchHubServer
from psychopy.core import getTime, wait

iohub_config = {'eyetracker.hw.sr_research.eyelink.EyeTracker':
                {'name': 'tracker',
                 'model_name': 'EYELINK 1000 DESKTOP',
                 'runtime_settings': {'sampling_rate': 500,
                                      'track_eyes': 'BINOCULAR'}
                 }
                }

io = launchHubServer(**iohub_config)

# Get the eye tracker device.
tracker = io.devices.tracker 

# run eyetracker calibration
r = tracker.runSetupProcedure()  

Is there something additional I need to do, to make this script work?

When it crashes, do you mean that you get an error or just a grey screen which you can’t exit? If the latter that’s probably that ioHub has taken control of the PsychoPy window, but hasn’t initialised its keyboard successfully, so can’t recognise the Escape key to close it…

Using the same setup as you have here in Builder, the following code is generated:

# Setup eyetracking
ioDevice = 'eyetracker.hw.sr_research.eyelink.EyeTracker'
ioConfig = {
    ioDevice: {
        'name': 'tracker',
        'model_name': 'EYELINK 1000 DESKTOP',
        'simulation_mode': False,
        'network_settings': '100.1.1.1',
        'default_native_data_file_name': 'EXPFILE',
        'runtime_settings': {
            'sampling_rate': 500.0,
            'track_eyes': 'BOTH',
            'sample_filtering': {
                'sample_filtering': 'FILTER_LEVEL_OFF',
                'elLiveFiltering': 'FILTER_LEVEL_2',
            },
            'vog_settings': {
                'pupil_measure_types': 'PUPIL_AREA',
                'tracking_mode': 'PUPIL_CR_TRACKING',
                'pupil_center_algorithm': 'ELLIPSE_FIT',
            }
        }
    }
}
ioSession = '1'
if 'session' in expInfo:
    ioSession = str(expInfo['session'])
ioServer = io.launchHubServer(window=win, **ioConfig)
eyetracker = ioServer.getDevice('tracker')

# -------Run Routine 'calibration'-------

# define target for calibration
calibrationTarget = visual.TargetStim(win, 
    name='calibrationTarget',
    radius=0.01, fillColor='', borderColor='black', lineWidth=2.0,
    innerRadius=0.0035, innerFillColor='green', innerBorderColor='black', innerLineWidth=2.0,
    colorSpace='rgb', units=None
)
# define parameters for calibration
calibration = hardware.eyetracker.EyetrackerCalibration(win, 
    eyetracker, calibrationTarget,
    units=None, colorSpace='rgb',
    progressMode='time', targetDur=1.5, expandScale=1.5,
    targetLayout='NINE_POINTS', randomisePos=True,
    movementAnimation=True, targetDelay=1.0
)
# run calibration
calibration.run()
# clear any keypresses from during calibration so they don't interfere with the experiment
defaultKeyboard.clearEvents()

I’m guessing the problem is missing parameters in iohub_confg - what happens if you copy the dict used here in its place?

Thank you very much for the tip. I used to get a grey screen which I couldn’t exit. Now I copy-pasted this code and replaced the other but still I get some errors.

Initially I got this error

   ioServer = io.launchHubServer(window=win, **ioConfig)
NameError: name 'io' is not defined

So I just added an import io statement at Begin Experiment. However, this raised the following error

    ioServer = io.launchHubServer(window=win, **ioConfig)
AttributeError: module 'io' has no attribute 'launchHubServer'

What could be a solution to this problem?


I also tried another way. I removed the import io statement and added

io = launchHubServer(window=win; **ioConfig)

before

ioServer = io.launchHubServer(window=win, **ioConfig).

I’m not sure how much sense it makes, but I get the following error anyway:

TypeError: Object of type "Window" is not JSON serializable

I’ve just noticed your version number, we made pretty substantial changes to eyetracking in 2021.2 so I think that first error will be fixed if you update to the latest version. The one about widow being a JSON I’m not so sure about, but it’s worth updating and seeing what happens

Thanks for the help :slight_smile:

I just tried using the original script using PsychoPy v. 2021.1.3.

The script doesn’t get stuck anymore, but I still get many attribute errors, such as

AttributeError: module 'pylink' has no attribute 'EyeLink'
** EyeLink Error: could not connect to EyeLink Eye Tracker.
EyeLink Eye tracker device will run in 'dummy' mode.

I’ll ask the IT to install the 2021.2 version and I’ll let you know if it works or not!

1 Like