Integrating eye-tracking with Tobii eye-tracker

OS (e.g. Win10): Win7
PsychoPy version (e.g. 1.84.x): v.3.1.2
Standard Standalone? (y/n) Yes
What are you trying to achieve?:
I guess this is a broad question but hoping to be pointed in the right direction from others experiences.

I’m trying to now integrate eye-tracking into an existing PsychoPy Builder script that I’ve put together. We use a Tobii X3-120 eye-tracker in our lab on a Win7 system. In the past, I’ve always created my eye-tracking experimenters using E-Prime with Tobii commands. I’m now in the process of moving over to PsychoPy (hopefully forevermore!)

However, I’m struggled to figure out the best way to get started as there seem to be lots of different ways to approach this. I’m still a beginner coder and trying to figure out which method would work best for me.

I have a copy of the psychopy book and had begun working from that. However, from reading different online posts and topics here on the forum it seems there are other ways to approach this. For example:

  1. The psychopy book chapter on eye tracking
  2. Aleksander Nitka’s guide on using Tobii Eye Trackers with PsychoPy Builder
    https://github.com/aleksandernitka/EyeTracking_Tobii_PsychoPy_IOHUB
  3. Hiroyuki Sogo’s psychopy_tobii_controller module
    https://github.com/hsogo/psychopy_tobii_controller
  4. Python for eye-tracking workshop with (Sol Simpson, Michael MacAskill and Jon Peirce) materials
    http://www.psychopy.org/resources/resources.html

For those who use Tobii eye-trackers or perhaps have also recently moved from E-Prime to PsychoPy - what would you recommend? Whilst I see similarities across all guides, they all seem to vary slightly!

2 Likes

Hello all. :wave:

Just another attempt to see if there is anyone who would be willing to share their recommendations/experiences of using the above resources to integrate Tobii eye-tracking into Builder?

Many thanks in advance :grin:

Hi, you mentioned my setup above (2). I am happy to give you some advice on how I implemented eye tracking into builder.

Ps. there is another way, although I have not tested it myself, by Edwin Dalmaijer’s pygaze http://www.pygaze.org/

Any luck or advice with this? I’m also beginning to attempt to integrate PsychoPy and Tobii SDK…

I’m also very interested in how you implemented a Tobii Eyetracker into PsychoPy…

We recently created Titta, a Python (PsychoPy) and Matlab (PTB) toolbox to communicate with Tobii eye trackers.

can you also record additional variables (e.g.,current gaze position) using Titta or you can only perform calibration?

@matiasfduque and @Leidy sorry guys been busy with work and the current situation has not helped at all. Please let me know if you’re still having problems with integrating Tobii into your experiments and maybe I will skype/FT/zoom you to talk about it?

Hello all,

As part of my experiment, I want to record eye tracking data from young infants. Following this and other posts, I see that there is a way to link psychopy with eye trackers to calibrate and record data. However, I would like to further control the psychopy experiment presentation based on eye tracking data (e.g. Skip trial when participants looked away from the screen for over one second). Does anybody know if such real-time eye-tracking-driven psychopy manipulation is possible? I ve read the Titta toolbox paper and it seems possible but before I buy a new eye tracker, I would like to be sure about feasibility.

Does anybody have any experience with this? If so, are there also recommendations as to which eye tracker to purchase?

Thank you,

Juan

Hello @quino,

I was wondering if you found a way to do that in PsychoPy. I have to implement the same sort of design with young children as well. Did you end up doing it with Titta Toolbox ?

Thanks a lot !
Charlotte

Hi all,

Does anyone have any example Psychopy experiment files were they have used a Tobii eye-tracker? I have a Tobii ProX3-120 and I for several trials in my experiment I want to know which quadrant the participant looked at the most.

Thanks in advance.

Matthew

Hi @aleksandernitka, I used your eye tracking guide (on GitHub) recently. PsychoPy has moved their eye tracking component from dependency to plugin after version 2023.1.1, some of your code (e.g., expInfo[‘Eye Tracker’]) is not compatible with the current version. Do you have plan to update it or could you please point out the alternative method that I can have your code up and running, thanks a lot!

You might find this helpful, Communicating with an Eyetracker — PsychoPy v2023.2.3

Make sure to install Tobii eyetracker from the plugins (Get more → Tobii eye tracker support)

then in the setting add Tobii.

Best,

Many thanks.

I have already installed this. When trying to run calibration (at the very beginning of my experiment) I get the below issues:

Error during device creation ....
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 715, in createNewMonitoredDevice
    dev_data = self.addDeviceToMonitor(dev_cls_name, dev_conf)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 849, in addDeviceToMonitor
    _dconf = yload(open(dev_conf_pth, 'r'), Loader=yLoader)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\PsychoPy\\lib\\site-packages\\psychopy\\iohub\\devices\\eyetracker\\hw\\tobii\\default_eyetracker.yaml'
Error during device creation ....
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 715, in createNewMonitoredDevice
    dev_data = self.addDeviceToMonitor(dev_cls_name, dev_conf)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 849, in addDeviceToMonitor
    _dconf = yload(open(dev_conf_pth, 'r'), Loader=yLoader)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Program Files\\PsychoPy\\lib\\site-packages\\psychopy\\iohub\\devices\\eyetracker\\hw\\tobii\\default_eyetracker.yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 649, in _addDevices
    self.createNewMonitoredDevice(dev_cls_name, dev_conf)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 728, in createNewMonitoredDevice
    raise ioHubError('Error during device creation ....')
psychopy.iohub.errors.ioHubError: ioHubError:
Args: ('Error during device creation ....',)

GET_DEV_INTERFACE_ERROR: _getRPCInterface returned: None
Traceback (most recent call last):
  File "C:\Users\nchevali\Documents\Psychopy ET\ET example MJ.py", line 150, in <module>
    calibration.run()
  File "C:\Users\nchevali\AppData\Roaming\psychopy3\versions\psychopy\hardware\eyetracker.py", line 197, in run
    self.last = self.eyetracker.runSetupProcedure(dict(self))
  File "C:\Users\nchevali\AppData\Roaming\psychopy3\versions\psychopy\iohub\client\__init__.py", line 153, in __getattr__
    raise AttributeError(self, name)
AttributeError: (<psychopy.iohub.client.ioHubDeviceView object at 0x000001C48FE41730>, 'runSetupProcedure')
Hello from the pygame community. https://www.pygame.org/contribute.html
3.6425     WARNING     Monitor specification not found. Creating a temporary one...
################# Experiment ended with exit code 1 [pid:1080] #################

See the attached file (it is just an example file I created to test if Eye Tracking works).

Thanks
ET example MJ.psyexp (21.7 KB)

For eyetracking, the most stable release we recommend at the moment is 2022.2.5.

You can also find materials from our PsychoPy Tobii workshop here.

Hope this is helpful!

Many thanks! I have tried using the ‘reading’ experiment with my Tobii eye-tracker information but it still give me the below error. Slightly different but it looks like the same problem. I will keep trying with a different approach than the ET components but any tips for debugging this would be great!

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\client\__init__.py", line 1107, in _addDeviceView
    d = local_class(self, dev_cls_name, dev_config)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\client\keyboard.py", line 206, in __init__
    self._reporting = self.isReportingEvents()
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\client\__init__.py", line 153, in __getattr__
    raise AttributeError(self, name)
AttributeError: (<psychopy.iohub.client.keyboard.Keyboard object at 0x00000254D18E1760>, 'isReportingEvents')
Traceback (most recent call last):
  File "C:\Users\nchevali\Downloads\shared-20231117T164235Z-001\shared\experiments\reading\reading_lastrun.py", line 865, in <module>
    run(
  File "C:\Users\nchevali\Downloads\shared-20231117T164235Z-001\shared\experiments\reading\reading_lastrun.py", line 379, in run
    calibration.run()
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\hardware\eyetracker.py", line 197, in run
    self.last = self.eyetracker.runSetupProcedure(dict(self))
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\client\__init__.py", line 153, in __getattr__
    raise AttributeError(self, name)
AttributeError: (<psychopy.iohub.client.ioHubDeviceView object at 0x00000254D18FB220>, 'runSetupProcedure')
Error in ioSever.shutdown():
Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\iohub\server.py", line 1021, in shutdown
    del self._hookManager
AttributeError: _hookManager
ioHub Server Process Completed With Code:  0
################# Experiment ended with exit code 1 [pid:8360] #################

It may be something to do specifically with Tobii X3-120?

May I ask which version do you use?

I had the same issue previously, it seems like this version PsychoPy is missing the yaml file.

see [Errno 2] No such file or directory: \default_eyetracker.yaml

As pointed by Becca, 2022.2.5 is the most stable version to use, you might want to try this.

Hi, sorry for slow reply. I had been using 2022.2.5 but it still returned the above error.

However, I downloaded the files from the link in that post you shared and it seems to be (somewhat) working! I have managed to get the calibration to work and when trying to antisaccade experiment Becca shared it seems to work so far and save data regardin ROIs (link here for anyone interested)

Many thanks!! But one thing I still can’t get to work is the validation component. The screen gets stuck when revealing the results of the validation and the task doesn’t move forward. Is validation absolutely necessary and if so is there a way to get it to work?