Thursday, 4 September 2014

Psychopy

Psychopy is a stimulus presentation program, written in Python. It is open source and cross platform and would be a replacement for ePrime or Presentation.

PsychoPy logo


There is also an excellent resource at Psych711 created by Prof. Gary Lupya.

Psychopy uses OpenGL to control presentation of stimuli on a frame by frame level. Stimuli are generated in real-time, meaning the stimuli can be modified by input from participants or data from an external sensor during the running of the experiment. Visual stimulation is synchronised to the graphics card refresh rate, which is the limit of timing precision in a computer based system.
Psychopy, being written in Python, can interact with a wide range of external hardware including USB devices like keyboards and mice, button boxes and even control of fMRI, EEG, or MEG machinery.
Psychopy can be scripted at a Python command line as well as having a graphical interface. Within the graphical interface, called Builder, Psychopy has modules for pictures, video, text as well as audio, and serial input. These modules allow basic parameters to be entered and the code is generated to achieve these requirements.

A GUI for quick construction

The Builder module in Psychopy is capable of creating standard stimuli and comes with several examples of historically significant experiments. The creation of text and basic shapes on screen is straightforward, as is collecting key presses or mouse clicks as responses.



Psychopy Builder module showing visual, sound, text and a code stimuli
the research environment 
The code behind the scenes

Behind the visual interface of the builder, the python script representing the desired elements is being created. This script can be modified if something not available in the builder is required. This seems an excellent compromise between the precise control of the command line and the ease of use of a graphical user interface, allowing even a beginner to create complex visual and auditory stimuli and gather responses from the keyboard and mouse.
The Psychopy Coder module showing the script version of the experiment.
Custom Code for anything else

There is also the custom code module within builder that allows for elements of code to be added to the GUI. This is how an Arduino connected to the serial port could be queried to gather the physiological data for an experiment. The experiment and the physiological recording could be started together and the information combined later, but the integration of the data within the experiment means the response of the participant can be used to modify the experiment. For example in a just noticeable difference (JND) analysis the participants response to each stimuli, affects the intensity of the next stimuli. This is only possible if response data is available to the experiment.
Declaring a serial object with the Pyserial library