Problem with Eye-Tracking Experiment
Dear OS community,
I have posted the following in the PyGaze section but maybe here is more appropriate. I apologize in advance for the repetition.
I am trying for the first time to build an eye-tracking experiment in OS. In my lab we are using Tobii Pro Fusion, that supports up to Python 3.10. Therefore I performed the following steps following the documentation attached:
- Created a virtual environment in Anaconda that works on Python 3.10 and installed OS and related packages in this environment. Documentation: https://osdoc.cogsci.nl/3.3/download#anaconda-cross-platform
- I then installed tobii_research in OS python console. Documentation:https://osdoc.cogsci.nl/3.3/manual/eyetracking/tobii/
- I started building my experiment using the available eye-tracking template (OS v4), however the pygaze_init is not working as intended. Thus I created an inline script to initialize and calibrate the tracker.
Inline Script
----------------------------
import tobii_research as tr
import time
# Find all connected eye trackers
trackers = tr.find_all_eyetrackers()
if len(trackers) > 0:
pygaze_eyetracker = trackers[0] # Use the first available tracker
print("Tobii Pro Fusion connected successfully!")
else:
print("Error: Could not find an eye tracker.")
pygaze_eyetracker = None
# Initialize calibration settings
if pygaze_eyetracker:
print("Starting calibration...")
try:
pygaze_eyetracker.calibrate()
time.sleep(5)
print("Calibration complete.")
except Exception as e:
print(f"Calibration failed: {e}")
-----------------------------------------------------------------------------------
However, when I run the experiment the following error(s) occur:
Calibration failed: 'EyeTracker' object has no attribute 'calibrate'
File "C:\Users\f-eflamprou\.conda\envs\opensesame_p3_env\lib\site-packages\opensesame_plugins\pygaze\pygaze_drift_correct\pygaze_drift_correct.py", line 52, in prepare
self.experiment.pygaze_eyetracker. \
AttributeError: 'Experiment' object has no attribute 'pygaze_eyetracker'
I was wondering if you could assist me on this matter.
Finally, my last question has to do with storing eye-tracking data. Is this implemented via inline script or incorporated within the pygaze plugins? Any reading or previous discussion suggested would be a massive help!
Specs
Operating System: Windows 10
Python version: 3.10
Pygaze version: 0.8
OS: V4
Thank you in advance or your time and consideration.
Best regards,
Efi
Comments
Hi @Effie,
I haven’t used Tobii before (I mostly work with EyeLink from SR Research), but I’ll do my best to help!
It looks like Tobii’s calibration process works differently than what you’re trying in your inline script i.e., that the Eyetracker object itself does not have a .calibrate() method, which is why you're getting that error.
Instead, you probably need to use Tobii’s ScreenBasedCalibration class to handle calibration (e.g., using calibration = tr.ScreenBasedCalibration(pygaze_eyetracker), then calibration.enter_calibration_mode(), then draw the points, etc.)
Here is the relevant documentation, to help you modify your script:
Regarding data logging, once you’ve started recording (e.g., using the pygaze_start_recording item), you should be able to log data with pygaze_log items—at least, that’s how it works with Eyelink. If you’re handling everything through inline scripts, I’d recommend checking the Tobii documentation again for specifics on data recording/storage (I think it's the bit about subscribing to gaze data events).
Hope this helps!
Claire
Check out SigmundAI.eu for our OpenSesame AI assistant! 🤖
Hi @cvanbuck,
Thank you so much for your reply. Indeed I tried Tobii's ScreenBasedCalibration class and it worked. Following the documentation I next tried to draw the points, however nothing appeared on the screen even though the status was successful. I guess I have to do a bit more research on it!
The only error I still encounter at this stage is: "Experiment" object has no attribute pygaze_eyetracker". My impression is that the error arises from the drift correction plugin, however it persists even when I deactivate it from the experimental sequence. My thought on how to solve this is to comment off the line: self.experiment.pygaze_eyetracker. \
in the File: "C:\Users\f-eflamprou\.conda\envs\opensesame_p3_env\lib\site-packages\opensesame_plugins\pygaze\pygaze_drift_correct\pygaze_drift_correct.py", line 52, in prepare
that the error points out, but I am not confident this is the right approach.
Thank you again for the detailed response and for your time.
Best,
Efi
Projektowanie wnętrz Warszawa | Projektant wnętrz Warszawa - Bitart
https://projektowanie.art/If you've already disabled the plugin and the error persists, commenting out that line could be a temporary fix, but it might be better to look into how the pygaze_eyetracker is being initialized in your experiment settings. If you're not using drift correction, maybe you don’t need that part at all.
Dear @kuba22,
Thank you for your reply. Indeed I proceeded with disabling the pygaze plugins. Instead I used inline scripts for calibration and gaze_data recording from Tobii SDK documentation.
Thank you again for your help!
Best,
Efi