You are viewing unmaintained documentation for an older version of OpenSesame. Click here to view the current documentation. Your version of OpenSesame:

Test the next generation of OpenSesame: 2.9.0 Hesitant Heisenberg!

Eyelink

The Eyelink series of eye trackers, produced by SR Research, are one of the most commonly used eye trackers in psychological research. SR Research provides Python bindings for the Eyelink, which are used by the OpenSesame Eyelink plug-ins. The license of the Eyelink Python bindings is incompatible with the license used by OpenSesame. For that reason, the Eyelink does not work out of the box with the official distribution of OpenSesame.

To use OpenSesame with the Eyelink, there are two options:

Running in dummy mode

You need to walk through the steps below only for the computer to which the Eyelink is actually attached. You can easily install the OpenSesame eyelink plug-ins on your own computer, as per step 5, without having to install anything or having to run OpenSesame from source. Obviously, you can only run the plug-in in ‘dummy mode’ in this case, but this is very convenient while developing and testing your experiment.

SR Research forum

You will need to download some software from the SR Research forum. This is a closed forum, but you can register free of charge.

System requirements

This tutorial has been written primarily for Windows XP 32-bit, for the simple reason that our own Eyelink PC uses this OS. Instructions for Ubuntu are also provided, but have not been tested extensively. You may still find this tutorial a useful resource when trying to install the OpenSesame Eyelink plug-ins on a different OS, but things will obviously work a little differently.

Step 1: Installing OpenSesame from source

Windows XP

The Windows binary of OpenSesame comes with its own Python environment and can only make use of the modules that have been included (PyGame, NumPy, etc.). Since PyLink is not included, and due to licensing restrictions probably never will be included, with OpenSesame, you will have to run OpenSesame from source. The following tutorial describes how to set-up the environment necessary for running OpenSesame from source:

  • </getting-opensesame/running-from-source>

Ubuntu

Under Linux, you can simply install OpenSesame as described here.

Step 2: Installing the Python Imaging Library

Windows XP

The Python Imaging Library is used to do some juggling between various image formats. You can download it here (make sure you download the most recent version for Python 2.6):

Ubuntu

The Python imaging library is probably installed already. If not, run the following command in a terminal:

sudo apt-get install python-imaging

Windows XP

The Eyelink display software provides the libraries that are required to communicate with the Eyelink PC. You can find it here:

Add the following directory to the Path (this may have been added to the path automatically, but check to make sure):

C:\Program Files\SR Research\EyeLink\libs

You can do this by opeing “My Computer”, clicking on “View system information”, opening the “Advanced” tab, clicking on “Environment Variables” and appending ;C:\Program Files\SR Research\EyeLink\libs to the Path variable (under System variables).

Ubuntu

There is a repository with the Eyelink display software available for Ubuntu Linux. To add this repository to your software sources, type the following in a terminal:

sudo nano /etc/apt/sources.list

This will open the software sources in a simple text editor. At the bottom of the file, add the following lines for 32 bit systems:

# Eyelink repository (32bit)
deb http://download.sr-support.com /

For 64 bit, add the following lines:

# Eyelink repository (64bit)
deb http://download.sr-support.com/x64 /

Save the file (Control+O, Enter) and exit (Control+X). Now reload the software sources, and install the Eyelink display software (the version number might vary, at the time of writing it is 1.9):

sudo apt-get update
sudo apt-get install eyelink-display-software1.9

For more information, please visit:

- <https://www.sr-support.com/showthread.php?16-Linux-Display-Software-Package>

PyLink is a Python wrapper around the display software.

Windows XP

There are two versions of PyLink: one with custom SDL and one without custom SDL. The reason that SR Research has changed some functionality in SDL (the Simple DirectMedia Layer, which is a set of libraries used to control the display etc.) is to improve timing accuracy. This is nice, but in the case of OpenSesame it is only relevant if you use the legacy (pygame) back-end: xpyriment and psycho have excellent timing regardless of which pylink version is used. The downside of pylink’s custom SDL is that you may encounter compatibility issues.

The bottom line: Initially, you may want to use the with SDL version of pylink, because this is the default version. However, if you encounter weird issues (such as sound not working), you may want to try the without SDL version of pylink.

You can find it here:

Download the pylink_win32.zip package and (assuming that you have installed Python to c:\Python26) copy the pylink26 folder in its entirety to

c:\Python26\Lib\site-packages

and rename the folder to pylink.

You can find it here:

Copy the pylink folder in its entirety to

c:\Python26\Lib\site-packages

Ubuntu

Download the correct PyLink for your distribution from here (make sure that you have the correct Python version, usually 2.7, and chipset, x64 for 64 bit and x32 for 32 bit):

Extract it to a location of your choice and rename the pylink27 folder to pylink.

All platforms

You can download the latest Eyelink plug-ins from GitHub:

Extract the archive and put all the folders (eyelink_calibrate, etc.) directly into the plugins folder of OpenSesame, as per these instructions:

Windows XP

You’re done! If you have installed the with SDL version of PyLink, you need to start OpenSesame with the --pylink command line argument (again, assuming that Python is installed in c:\Python26):

c:\Python26\python.exe opensesame --pylink

If you start OpenSesame now, you should see the Eyelink plug-ins appear as additional items in the item toolbar (as in the screenshot below). You can drag and drop these items into your experiment!

No alt text specified

Ubuntu

You can start OpenSesame in the usual way from the applications menu, or by running the following command in a terminal:

opensesame

Documentation, examples and function overview

You can find a tutorial for using the OpenSesame Eyelink plug-ins here (PDF).

The following experiment, kindly provided by Daniel Schreij, shows how to use the OpenSesame Eyelink plug-ins from the graphical interface:

Schreij, D., Owens, C., & Theeuwes, J. (2008). Abrupt onsets capture attention independent of top-down control settings. Perception & Psychophysics, 70(2), 208-218.

The example below shows how to display the trajectory of an eye movement immediately after every trial, using Python inline code. I created this as a demonstration of saccadic curvature for a class of students.

You can also access the Eyelink using python in an inline_script item. The eyelink class is a property of the experiment class, which (in an inline_script item) you can access like this:

exp.eyelink

So, for example, you can do the following:

exp.eyelink.log("Message for the EDF")
time, start_pos = exp.eyelink.wait_for_saccade_start()
time, start_pos, end_pos = exp.eyelink.wait_for_saccade_end()
x, y = exp.eyelink.sample()

Below is the full list of available functions. It is also possible to use the PyLink API directly, but I recommend using the libeyelink functions, which are considerably easier to use.

class libeyelink

Function overview:
__init__
calibrate
close
connected
drift_correction
fix_triggered_drift_correction
get_eyelink_clock_async
log
log_var
manual_drift_correction
prepare_backdrop
prepare_drift_correction
pupil_size
sample
send_command
set_backdrop
set_eye_used
start_recording
status_msg
stop_recording
wait_for_blink_end
wait_for_blink_start
wait_for_event
wait_for_fixation_end
wait_for_fixation_start
wait_for_saccade_end
wait_for_saccade_start

libeyelink.__init__(experiment, resolution, data_file=u'default.edf', fg_color=(255, 255, 255), bg_color=(0, 0, 0), saccade_velocity_threshold=35, saccade_acceleration_threshold=9500, force_drift_correct=False)
Constructor. Initializes the connection to the Eyelink.

Arguments:
experiment → The experiment object.
resolution → A (width, height) tuple.

Keyword arguments:

data_file → The name of the EDF file. (default=u'default.edf')
fg_color → The foreground color for the calibration screen. (default=255,255,255)
bg_color → The background color for the calibration screen. (default=0,0,0)
saccade_velocity_threshold → The velocity threshold used for saccade detection. (default=35)
saccade_acceleration_threshold → The acceleration threshold used for saccade detection. (default=9500)
force_drift_correct → Indicates whether drift correction should be enabled. This is useful only for Eyelink 1000 models, for which drift correction is disabled by default. (default=False)

Returns:
True on connection success and False on connection failure.
libeyelink.calibrate(beep=True, target_size=16)
Starts eyelink calibration.

Keyword arguments:
beep → Indicates whether or not the calibration target should beep when jumping. (default=True)
target_size → The size of the calibration target. (default=16)

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.close()
Closes the connection with the eyelink.
libeyelink.connected()
Returns the status of the eyelink connection.

Returns:
True if connected, False otherwise.
libeyelink.drift_correction(pos=None, fix_triggered=False)
Performs drift correction and falls back to the calibration screen if necessary. Pressing the 'escape' key during drift-correction will not immediately abort the experiment, but will ask for confirmation first.

Note: This function is simply a wrapper around `fix_triggered_drift_correction()` and `manual_drift_correction()`.

Keyword arguments:
pos → The coordinates (x,y tuple) for drift correction or None for the display center. (default=None)
fix_triggered → A boolean indicating whether drift correction should be fixation triggered, rather than spacebar triggered. (default=False)

Returns:
True on success, False on failure.

Exceptions:
Raises an exceptions.runtime_error on error.
libeyelink.fix_triggered_drift_correction(pos=None, min_samples=30, max_dev=60, reset_threshold=10)
Performs fixation triggered drift correction. You can return to the set-up screen by pressing the 'q' key. Pressing the 'escape' key during drift-correction will not immediately abort the experiment, but will ask for confirmation first.

Keyword arguments:
pos → The coordinate (x,y tuple) for drift correction or None for the display center. (default=None)
min_samples → The minimum nr of stable samples that should be acquired. (default=30)
max_dev → The maximum allowed deviation. (default=60)
reset_threshold → The maximum allowed deviation from one sample to the next (default=10)

Returns:
True on success, False on failure.

Exceptions:
Raises an exceptions.runtime_error on error or on confirming 'abort experiment'.
libeyelink.get_eyelink_clock_async()
Retrieve difference between tracker time (as found in tracker timestamps) and experiment time.

Returns:
The tracker time minus experiment time.
libeyelink.log(msg)
Writes a message to the eyelink data file.

Arguments:
msg → The message to be logged.
libeyelink.log_var(var, val)
Writes a variable to the eyelink data file. This is a shortcut for eyelink.log("var %s %s" % (var, val)).

Arguments:
var → The variable name.
val → The value.
libeyelink.manual_drift_correction(pos=None)
Performs manual (spacebar-triggered) drift correction. You can return to the set-up screen by pressing the 'q' key. Pressing the 'escape' key during drift-correction will not immediately abort the experiment, but will ask for confirmation first.

Keyword arguments:
pos → The coordinate (x,y tuple) for drift correction dot or None for the display center. (default=None)

Returns:
True on success, False on failure.

Exceptions:
Raises an exceptions.runtime_error on error or on confirming 'abort experiment'.
libeyelink.prepare_backdrop(canvas)
Converts a surface to the format required by the eyelink. WARNING: this function can take between 50-150 ms to complete, depending on the resolution of the image and the cpu power of your machine. Do not use during time critical phases of your experiment.

Arguments:
canvas → An openexp.canvas.

Returns:
A (image, width, height) tuple, where image is a pygame.surfarray.array2d.
libeyelink.prepare_drift_correction(pos)
Puts the tracker in drift-correction mode.

Arguments:
pos → The reference point.

Exceptions:
Raises an exceptions.runtime_error on error.
libeyelink.pupil_size()
Gets the most recent pupil size.

Returns:
A float corresponding to the pupil size (in arbitrary units). The value -1 indicates missing data.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.sample()
Gets the most recent gaze sample.

Returns:
A tuple (x, y) containing the coordinates of the sample. The value (-1, -1) indicates missing data.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.send_command(cmd)
Sends a command to the eyelink.

Arguments:
cmd → The eyelink command to be executed.
libeyelink.set_backdrop(backdrop)
Sets backdrop image for the EyeLink computer. For better performance, it can be useful to convert the canvas to send to the eyelink in the prepare phase using eyelink.prepare_backdrop(). If speed is not an issue, you can also directly pass a openexp.canvas object and this function will take care of the conversion.

WARNING: this function can take between 10-50 ms to complete, depending on the resolution of the image and the cpu power of your machine. Do not use during time critical phases of your experiment.

Arguments:
backdrop → An openexp.canvas or a tuple representation as returned by prepare_backdrop().

Returns:
The amount of time in ms the function took to complete.
libeyelink.set_eye_used()
Sets the eye_used variable, based on the eyelink's report, which specifies which eye is being tracked. If both eyes are being tracked, the left eye is used.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.start_recording()
Starts recording of gaze samples.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.status_msg(msg)
Sets the eyelink status message, which is displayed on the eyelink experimenter pc.

Arguments:
msg → The status message.
libeyelink.stop_recording()
Stops recording of gaze samples.
libeyelink.wait_for_blink_end()
Waits for a blink end.

Returns:
A timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_blink_start()
Waits for a blink start.

Returns:
A timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_event(event)
Waits until an event has occurred.

Arguments:
event → An EyeLink event, such as pylink.STARTSACC.

Returns:
A tuple (timestamp, event). The event is in float_data format. The timestamp is in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_fixation_end()
Waits for a fixation end.

Returns:
A (timestamp, start_pos, end_pos) tuple with timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_fixation_start()
Waits for a fixation start.

Returns:
A (timestamp, start_pos) tuple with timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_saccade_end()
Waits for a saccade end.

Returns:
A (timestamp, start_pos, end_pos) tuple with timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.
libeyelink.wait_for_saccade_start()
Waits for a saccade start.

Returns:
A (time, start_pos) tuple with timestamp in experiment time.

Exceptions:
Raises an exceptions.runtime_error on failure.