PsychoPy
Introduction
PsychoPy is an open-source, Python based software package used for creating behavioral experiments. It features and easy to use graphical user interface. PsychoPy can be used for online research in combination with Pavlovia.
Availability, support and advice
PsychoPy comes preinstalled on labcomputers in the FSW (see the Software List to check which version). PsychoPy can be requested for work PC's via the ISSC Helpdesk. For unmanaged/personal computers PsychoPy can be downloaded here. SOLO provides only very limited basic support for PsychoPy.
Markers
To send markers with PsychoPy using the UsbParMarker or EVA, the python_markers library can be used, see Github: solo-fsw/python-markers. To use the python_markers library, place the python_markers folder in the same location as your PsychoPy task, and implement the code as described in example.py in your task. The python_markers folder can be downloaded by downloading or cloning the python_markers repo.
Eye Tracking
The installation of PsychoPy on the lab PCs at SSH Leiden include the necessary libraries for eye tracking. See for more information about incorporating eye tracking in your PsychoPy experiment: Communicating with an Eyetracker — PsychoPy v2024.2.4. Note that these are general instructions, that should work for Tobii eye tracking. For EyeLink eye tracking, see below.
EyeLink
In general, make sure the EyeLink is connected properly to the Stimulus PC and that network communication configured (see How do I configure my network settings to connect to the EyeLink Host PC?), and that the EyeLink Developers Kit is installed (see EyeLink Developers Kit / API Downloads (Windows, macOS, Linux)). To arrange this on SSH lab PCs, please contact labsupport@fsw.leidenuniv.nl.
When incorporating EyeLink eye tracking in a PsychoPy task, follow the installation instructions here: Getting Started with PsychoPy / EyeLink Integration (create an SR research account to view the thread). EyeLink communication is achieved through code, or with an EyeLink plugin that has PsychoPy GUI components.
To use only code to communicate with EyeLink, see also the following video: PsychoPy Integration for EyeLink Eye Trackers.
To use the EyeLink plugin for PsychoPy with GUI components, please read the manual carefully (download manual here: Getting Started with PsychoPy / EyeLink Integration). The EyeLink plugin can be installed through the Plugin & Packages tool (see for more information: About PsychoPy Plugins — PsychoPy Plugins v0.0.1).
It is important to note that there are two SR research plugins available in PsychoPy, but that you should only install the psychopy-eyelink plugin. This plugin was created by SR research and provides access to the EyeLink eye tracking components in PsychoPy. When using the Plugin & Packages tool, the plugin is installed per user in C:\Users\%USERNAME%\AppData\Roaming\psychopy3\packages\Python38\site-packages.
![]() | ![]() |
When the psychopy-eyetracker-sr-research plugin is installed, the other, non-EyeLink eye tracking components can be used (see here for more information: GitHub - psychopy/psychopy-eyetracker-sr-research: Add support to PsychoPy for SR Reseearch eyetrackers). However, these components do not have all functionalities necessary for proper eye tracker communication, such as sending messages and thus the installation of this plugin is not advised. Moreover, installing both the psychopy-eyelink plugin and the psychopy-eyetracker-sr-research plugin may result in errors.
It is also important to note that there is an eye tracker menu in PsychoPy, that can be reached by clicking on the Experiment Setting icon (cog wheel) and going to the Eyetracking tab. An Eyetracker Device can be selected. When using the psychopy-eyelink plugin, no Eyetracker Device will become available here, and the Eyetracker Device should be set to None. When using the psychopy-eyetracker-sr-research plugin (which is not recommended), SR Research Ltd can be selected at Eyetracker Device.
Eye Tracking Errors:
Any error | In general, it may be helpful to first start PsychoPy (make sure it is the correct version, see Software list - XWiki), and then open your eye tracking task through File > Open. |
![]() | Error: "AttributeError: 'NoneType' object has no attribute 'isRecordingEnabled'" This error occurs when you are trying to run a task that was created with the psychopy-eyelink plugin, but the psychopy-eyetracker-sr-research plugin is also installed and the SR research eye tracker is selected in the Eyetracking properties. A possible solution would be to remove the psychopy-eyetracker-sr-research plugin, restart PsychoPy and make sure the Eyetracker device is set to "None". To remove the plugin, remove the folders that start with psychopy_eyetracker_sr_research in C:\Users\%USERNAME%\AppData\Roaming\ |
![]() | Error: "KeyError: 'SR Research Ltd'" This error can also occur when you are trying to run a task that was created with the psychopy-eyelink plugin, but the psychopy-eyetracker-sr-research plugin is also installed and the SR research eye tracker is selected in the Eyetracking properties. See possible solution above. |
![]() | Error: "NameError: name 'Initialize' is not defined." The task crashes on the Initialize component, which is usually the first EyeLink component in the task. At the start of the task, PsychoPy should ask the user to fill in the name of the EDF file (which is the EyeLink data file). When this does not happen, this type of error usually occurs. It seems that communication with the eye tracker is not established through the plugin. The plugin is not installed, or not recognized/interpreted correctly. Make sure the plugin is installed correctly (in C:\Users\%USERNAME%\AppData\Roaming\ |
Online
Psychopy offers the option to auto-translate your python code into JavaScript (or manually add JS), so that the experiment can be run online in combination with Pavlovia. However, you should be aware that not all features are available online, and that bugs still frequently occur. For a running overview of these issues, please consult the developer crib sheet and the forum.
Tips & Tricks
Syncing to Pavlovia from network drives.
Psychopy has the functionality to upload and sync (JavaScript compatible) experiments directly to Pavlovia.org.
Testing shows that this functionality works properly if the project files are located on the local C-drive. However, in some cases it does not work if the if the experiment folder/files are located on the network drive (e.g. in the P-drive). Throwing the following error:
By default, any project located on the P-drive will show the \\VUW\.. path when initially creating the project on Pavlovia from Builder:
There are two workarounds.
Change this default path when first syncing to the shorter P:\ or J:\ notation, e.g.:
\\VUW\Personal$\Homes\O\olferskjf\My Documents\Packaging\Psychopy\Experiments\BART
to
P:\My Documents\Packaging\Psychopy\Experiments\BART
You can do this manually, or by clicking on the "Browse" button and navigating to the desired location.- If the above does not fix the problem, move your experiment folder to the local (C) drive, and open it from there and then sync to Pavlovia.
FAQ
Topic | Question | Answer |
---|---|---|
Error when syncing to Pavlovia | when creating a new project on pavlovia from the builder (or syncing to it), an error is thrown ending with "stderr: 'fatal: remote origin already exists". | The workaround is placing your files on the local drive (instead of P or J-drive) or adjusting the default path. See here for further details. |
Blank screen when running study in local browser | Running a JS study in the local browser, using the button in the builder, only shows an empty screen in the browser. | Make sure adblockers (like Ublock origin) are disabled or set to ignore http://localhost:12002/ |
2022.2.2 not syncing to Pavlovia | After installing the 2022.2.2 version, my experiments no longer sync properly to Pavlovia. | In Experiment settings, make sure "Use PsychoPy version" is set to 2022 or 2022.2.2 |
Resources
Packaging
When | Target | Report | Comments |
10-09-2021 | Work-pc / Software Center | Syncing to pavlovia from network drives does not work by default. For solution see here. | |
30-08-2022 | Work-pc / Software Center | Adds some useful features (e.g. testing in local browser) and seems to have fixed the sync from network . |