Help me with connecting PsychoPy with Tobii Pro Lab

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Win10 Pro
PsychoPy version (e.g. 2024.2.4): 2024.2.4
Standard Standalone Installation? (y/n) :Yes, I guess.
Do you want it to also run online? (y/n) : No
What are you trying to achieve?: To send event triggers from PsychoPy at the exact millisecond an image is presented, routing them simultaneously to both BrainVision Recorder (via parallel port) and Tobii Pro Lab (via network communication) with zero time lag, achieving complete synchronization and recording across both systems.

Tobii version: Tobii Pro Fusion 120

Tobii Pro Lab version: 1.152.30002 (x64)

What did you try to make it work?:

I. Approach via Raw TCP/IP Socket Communication

  • Method: Used the standard socket library in Python to directly connect to port 8080 (or 9036) to send commands to Tobii Pro Lab (External Presenter project).
  • Result: Encountered port conflict errors (WinError 10048) caused by leftover zombie processes from previous crashes. Additionally, PsychoPy 2024.2.4’s internal code compilation structure triggered initialization sequence bugs (UnboundLocalError: local variable 'data' referenced before assignment), crashing the experiment program entirely at startup.

II. Approach via PsychoPy’s Built-in Eyetracking Plugin

  • Method: Enabled the [Eyetracking] tab in Experiment Settings and attempted to control the native eyetracker object.
  • Result: The plugin itself suffered from an internal error (Plugin psychopy-eyetracker-tobii specified entry point group ... does not exist or is unreachable). Although dummy success logs were printed by PsychoPy, no data actually reached Tobii Pro Lab, leaving it in a Not Connected state.

III. Approach via the Titta (TalkToProLab) Library

  • Method: Integrated the officially recommended Titta library, which supports the required WebSocket communication protocol, to connect to the External Presenter project.
  • Result:
    • Successfully achieved a “Connected” status on the Tobii Pro Lab side.
    • However, the placement of the connection code within PsychoPy’s tabs (Begin Routine or Before Experiment) conflicted with PsychoPy’s code pre-loading behavior. This caused persistent parallel-thread duplicate startup errors (threads can only be started once), variable scope loss (NameError: name 'ttl' is not defined), and host-side connection aborts (WinError 10053), preventing the system from automatically triggering the recording phase

IV. Shift to a Screen-Based Project

  • Method: Created a standard Screen-Based project (My_project) in Tobii Pro Lab to enable manual recording control.
  • Result: Discovered that by product specification, Screen-Based projects completely deactivate the remote API (port 8080 listening window). As a result, while manual recording could be started, it was physically impossible for Tobii Pro Lab to receive any incoming network triggers from PsychoPy.

Questions

  1. What is the proper tab placement or flag management strategy in PsychoPy 2024.2.4 to initialize and start an external WebSocket library (like Titta) safely during the first routine without triggering the pre-loading duplicate thread error (threads can only be started once)?
  2. Alternatively, is there a known fix for the native psychopy-eyetracker-tobii plugin error (unreachable) to allow PsychoPy’s built-in engine to correctly talk to and trigger recording in a Tobii Pro Lab External Presenter project?

If anyone has solved this specific synchronization puzzle or has a robust template for this setup, your advice would be deeply appreciated. Thank you!

Hi,

There is a template experiment showing builder code to connect the two with Titta: OSF .

The beauty of Titta is you can use newer versions of PsychoPy :slight_smile: