yh-luo / psychopy_tobii_infant Goto Github PK
View Code? Open in Web Editor NEWCreate infant-friendly eyetracking experiments with PsychoPy and Tobii eyetrackers.
License: GNU General Public License v3.0
Create infant-friendly eyetracking experiments with PsychoPy and Tobii eyetrackers.
License: GNU General Public License v3.0
All demos include this piece of code:
# show the relative position of the subject to the eyetracker
# Press space to exit
controller.show_status()
It says 'press space to exit'. However, on my setup (Windows 10, PsychoPy standalone v2020.2.10, running the experiment from PsychoPy Coder view), this by itself doesn't work. I first need to do a mouse click and only then can I hit space to proceed.
After the experiment has finished, I can see in the coder view that any keyboard input I entered before doing a mouse click have resulted in corresponding characters being written in the script. It appears then that for some reason, 'focus' isn't shifted to the experiment window (even though it's in the foreground and fullscreen). Instead, Windows keeps routing any keyboard input to the coder window.
Hi,
I have a question about your code from demo1_calibration. Is it designed to make a sound output when each keypress (0 - 9)? If not, is it possible to add sound?
Thanks!
Victoria
The run_calibration
and run_validation
methods currently always use a white TextStim instance for displaying calibration/validation results. It's recommended however that "[for] good performance, choose a calibration background that matches the color and brightness of your stimuli.". IIUC, this means that if a white background is used in the experiment itself, it's appropriate to use a white background for the calibration as well. But this hides the result message in this package.
One way to get around this is to simply add another argument to run_calibration/run_validation, like I did here.
Hi Yu-Han, I'm the creator of PyHab (Kominsky, 2019; https://github.com/jfkominsky/PyHab), and I was thinking about adding psychopy_tobii_infant to PyHab to make it easier for people to build eye-tracking experiments. You've done a really great job with it, and it's easy for PyHab to interface with it. I was thinking of literally just taking the module folder and adding it as a sub-folder within PyHab, giving you full credit for it of course!
Let me know if you're ok with that or have any questions.
Kominsky, J. F. (2019). PyHab: Open-source real time infant gaze coding and stimulus presentation software. Infant Behavior and Development, 54, 114-119. https://doi.org/10.1016/j.infbeh.2018.11.006
Hello,
I am just getting started on implementing eye-tracking with infants and we are using PsychoPy with the Tobii Pro SDK. Your code seemed perfect as a starting point, but I am unable to import 'infant_tobii_controller'.
I am using Windows 10. Any ideas?
Thank you!
Rather than getting an entirely 'blank' calibration results view, I'd expect that only the one point/area for which you closed your eyes would be blank, while other calibration points would have corresponding red/green lines indicating how far participant gaze was from the target.
In the package's init.py file inside of the _show_calibration_result
method, there is the following check:
if self.calibration_result.status == tr.CALIBRATION_STATUS_FAILURE:
# computeCalibration failed.
pass
This status
attribute is assigned its value through the return value of a tobii_research
function call. Tobii's documentation here is somewhat opaque, but as far as I could understand, this value is set to the constant CALIBRATION_STATUS_FAILURE
as soon as any point's calibration data collection fails (regardless of whether or not collection was successful for other points).
Simply remove the self.calibration_result.status == tr.CALIBRATION_STATUS_FAILURE
check. As far as I can tell, and from testing, this shouldn't cause any issues. The _show_calibration_result
code relies on self.calibration_result.calibration_points
, which as far as I can tell only includes points for which calibration data collection was 'successful' (ie participant gaze could be captured at all). I tried this in a branch and with the modification, the results presentation behavior is as I would expect.
In fact, now that I look at it again, it's probably possible to drop the if len(self.calibration_result.calibration_points) == 0:
check as well, since if the length is indeed 0 then for this_point in self.calibration_result.calibration_points:
loop won't do any iterations anyway. I unfortunately can't test this myself since I don't have access to an eyetracker now, but it might be worth considering, for cleaning the code.
If the solution seems appropriate, I can do a PR.
Many thanks for sharing this project. I have been using your tobii-infant-controller in an experiment, programmed in Psychopy3 and interfacing via iohub to a tobii X2-60 (running on Windows 7).
I get the following error message occasionally (copying the entire Psychopy console output for context):
Welcome to PsychoPy3!
v2021.1.2
12.8191 WARNING Couldn't connect to psychopy.org
Check internet settings (and proxy setting in PsychoPy Preferences.
28.6397 INFO Loaded monitor calibration from ['2022_01_24 11:57']
Generating PsychoPy script...Running: C:\Users\Eyetracker2\Documents\StructureEyes\StructureEyes_final\Task_pred_struct_final_lastrun.py
34.6018 INFO Loaded monitor calibration from ['2022_01_24 11:57']
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
29.0727 WARNING t of last frame was 20.48ms (=1/48)
47.1880 WARNING Monitor specification not found. Creating a temporary one...
pressed e at 0.1514297748599347 ms
1070.5146 WARNING Monitor specification not found. Creating a temporary one...
2122.6566 WARNING Monitor specification not found. Creating a temporary one...
ioHub Server Process Completed With Code: 0
Traceback (most recent call last):
File "C:\Users\Eyetracker2\Documents\StructureEyes\StructureEyes_final\Task_pred_struct_final_lastrun.py", line 2326, in
controller.run_calibration(CALIPOINTS, decision_key='a')
File "C:\Users\Eyetracker2\Documents\StructureEyes\StructureEyes_final\Task\psychopy_tobii_infant_init_.py", line 718, in run_calibration
self.calibration_result = self.calibration.compute_and_apply()
File "C:\Program Files\PsychoPy3\lib\site-packages\tobiiresearch\implementation\ScreenBasedCalibration.py", line 270, in compute_and_apply
calibration_points.append(CalibrationPoint(position, tuple(calibration_samples)))
File "C:\Program Files\PsychoPy3\lib\site-packages\tobiiresearch\implementation\ScreenBasedCalibration.py", line 87, in init
"You shouldn't create CalibrationPoint objects yourself.")
ValueError: You shouldn't create CalibrationPoint objects yourself.
Error in atexit.run_exitfuncs:
Traceback (most recent call last):
File "C:\Users\Eyetracker2\Documents\StructureEyes\StructureEyes_final\Task\psychopy_tobii_infant_init.py", line 629, in close
"Data file is not found. Use start_recording() to record and "
RuntimeWarning: Data file is not found. Use start_recording() to record and save the data.
Experiment ended.
I have been in touch with Tobii support and also posted on the Psychpy Ddiscourse forum, but no luck. I am puzzled because the issue does not happen deterministically. Tobii support think the problem is not hardware-related. Attaching the psychopy program file. Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.