PyGaze and OpenSesame

Last modified by Iris Spruit on 2022/02/11 16:54

Introduction

PyGaze is a Python library that is used for eye tracking. PyGaze is easily used within OpenSesame and comes preinstalled in the Windows version of OpenSesame.

Logging variables

There are several options when it comes to logging variables in the eye tracker data file with PyGaze. Below, some options and recommendations are given.

Log time

It is advised to add and Inline script at the start and end of the task in which the current OpenSesame time is logged:

# Log the current OpenSesame time in the eye tracker data file
eyetracker.log_var('cur_os_time', clock.time())

By logging the OpenSesame time in the eye tracking data file, it is possible to adjust the timestamp of the time variables logged during the pygaze_log item to the eye tracker system time.

Start recording and stop recording

It is possible to send a message with the pygaze_start_recording and pygaze_stop_recording items. For example, these items can be used to send trial meta data information to the eye tracker data file. When you want to send a variable of which the value is not known yet at the start of the trial, this variable can be sent at the end of the trial at pygaze_stop_recording. See example below.

pygaze-stop-recording.PNG

Other logging options

pygaze_log

With the pygaze_log item you can log OpenSesame variables.

When you want to log all variables, just check the box Automatically log all variables. When you want to log specific variables, you can specify them in the control window.

The Pause between messages allows you to set the time interval between logging each variable. Note that when you have a lot of variables, logging can take some time (also dependent on the Pause between messages setting).

It is advised to place the pygaze_log item after the pygaze_stop_recording item. When the pygaze_log item is placed before the pygaze_stop_recording item, the eye tracker is still recording during logging, which could create a messy data file with eye tracking data samples in between the logged variables.

eyetracker.log and eyetracker.log_var

Another possibility is to use an Inline script and the eyetracker.log or eyetracker.log_var function. With the eyetracker.log function you can log a message only eyetracker.log(msg), with the eyetracker.log_var you can log a variable-value pair eyetracker.log_var(var, val), see the PyGaze OpenSesame documentation for more information.