PsychoPy is a powerful Python library for creating the type of stimuli that are frequently used in psychological and neuroscientific experiments. I use it all the time, mostly from within OpenSesame, but I remember that I initially found working with PsychoPy quite daunting. This is because PsychoPy takes a very different approach to stimulus generation than most people are used to. You have to think in terms of patches, textures, and, masks, rather than in conventional drawing primitives, such as rectangles and lines (although newer versions of PsychoPy also support these drawing primitives). Therefore, I decided to write a short tutorial that explains the basics of working with PsychoPy.
In this tutorial, I will explain how to use textures and masks from the ground up. I will assume very little prior knowledge, except a basic understanding of Python. I will assume that you are running OpenSesame, which you can download from here, and comes bundled with all necessary Python libraries. The code snippets below can be pasted directly into an OpenSesame inline_script
item. You will probably want to insert a keyboard_response
after the inline_script
item that contains the code, so you that have the chance to see your stimuli before the experiment finishes!
For your convenience, you can download an OpenSesame template for this tutorial from here:
- Download OpenSesame template (Follow the link, click on download, and save as
.opensesame
file)