24  PsychoPy basics

In this lab, you will start to create our own experiments using PsychoPy, a piece of software developed by Jon Peirce here at the University of Nottingham. With PsychoPy, the most important thing will be that you try things out. Remember that you cannot break PsychoPy1, so nothing can go wrong!

Assessment

Your knowledge of PsychoPy will be assessed by a summative PsychoPy assignment and by PsychoPy questions in the exam in January.

24.1 Why learn PsychoPy?

We think learning how to use PsychoPy is important for four key reasons: The first reason is that we would of course like you to be able to create experiments. However, we would argue that using PsychoPy also teaches you other fundamental skills:

  • Attention to detail: When creating experiments, small things matter. E.g., a period or space in the wrong location could stop an experiment from running or make data not interpretable. Practising this attention to detail is not only relevant for creating experiments, but also for any type of data analysis you will perform during your studies.
  • Staying organised: Creating experiments in PsychoPy involves keeping track of multiple files (and likely multiple versions of the same file) and making sure you are using the correct ones when running your experiment. Learning how to keep things organised on your computer is an important transferable skill that is important for other more complex tasks (such as working on a lab report or a final-year project).
  • Problem solving skills: No one is born a master and when you start using PsychoPy, things might not work right away. You will likely need to hone your problem solving skills to find solutions to the problems you encounter.

We would argue that the strategies you can use to solve PsychoPy problems are ones that can be helpful in many other contexts. These strategies include:

  • Breaking complex tasks down into smaller steps.
  • Manipulating only one thing at a time.
  • Simplifying things (e.g., by creating a simpler version of the experiment that focuses only on what is not working).
  • Using feedback (or, in the case of PsychoPy, error messages) for working out what is going wrong.
  • Resilience. Persisting when things don’t work is really important. And it’s a great feeling if they eventually do!

The remaining sections in this chapter will describe five basic PsychoPy operations:

  • Launching PsychoPy.
  • Opening experiments.
  • Running experiments.
  • Quitting experiments.
  • Saving experiments.

24.2 Launch PsychoPy

To launch PsychoPy, click on the PsychoPy icon:

The PsychoPy icon.

Try it out

Launch PsychoPy.

Depending on your operating system and hardware, PsychoPy can take a while to launch (potentially up to a minute or so).

Once Psychopy has launched, make sure the Builder window is in the foreground:

The PsychoPy Builder window.

Note that the next chapter will cover the Builder in more detail.

Download and unzip a flanker experiment

By default, the file will probably end up in your Downloads folder. If you use one of the iMacs in the School, we would recommend to move the file to the Desktop. If you use your own laptop, we would recommend to move the file to a suitable location on your hard drive, e.g.:

Year1
├── PSGY1001
│   ├── Lab5

When you have moved the ZIP file to a suitable location, unzip the ZIP file. Once you have unzipped the file, open the folder that was created when you unzipped the file. In that folder, you should be seeing something similar to this (the exact display will of course vary depending on your operating system and settings):

The unzipped folder contains an input file, a picture with instructions and the actual PsychoPy experiment.

Please note:

  • Input files will be explained in more detail in a later chapter.
  • How the instruction picture is used is further explained in Section 26.2.
  • The .psyexp file is the PsychoPy experiment. This is the file you want to open in PsychoPy.

All three files must be present in the same folder for the experiment to run successfully.

24.3 Open an experiment

We recommend the following way to open a PsychoPy experiment file:

  1. Open PsychoPy.
  2. Drag and drop the .psyexp file onto the Builder window.

There are other options (double-click or right-click), but in our experience drag and drop works best.

macOS users

For the double-click to work under macOS, you first need to tell macOS that it should open .psyexp files using PsychoPy. Here is how to do this (if you follow these steps exactly, you will need to do this only once):

  1. Right-click on the .psyexp file → Get Info → Open with → Choose… → PsychoPy.
  2. You must then make sure to click on “Change all” and “OK” to confirm.
Try it out

Open the flanker experiment.

24.4 Run an experiment

The simplest way to run an experiment is to click on the “Run” icon:

Green run icon.

The colour of the run icon depends on the setting for Pilot vs. Run:

Pilot vs. run setting.

If the toggle switch is set to “Pilot”, the run icon will be orange. When set to “Run”, it is green.

For now, the key difference between these options is that Pilot mode will not run an experiment in full screen. This can make it easier to quit the experiment when something goes wrong.

Try it out

Switch to “Run” mode (so the “Run” button turns green) and run the flanker experiment.

24.5 Quit an experiment

You can press the Escape key at any time to quit a running experiment.

If you are running macOS and pressing Escape has no effect, try Cmd + Alt + Escape.

Try it out

Quit the flanker experiment.

24.6 Save an experiment

To save a new or modified experiment, click on the “Save” icon or the “Save as” icon in the toolbar.

Alternatively, you can press Cmd + S (macOS) or Ctrl + S (Windows).

Develop and run locally, then save online

When working on experiments and running them, we would recommend to always save PsychoPy experiments locally (i.e., not on OneDrive). Once you’re finished with an experiment, make sure to save a copy on OneDrive though, so you have a back-up copy and can also access it from another computer if necessary.

If you are using one of the iMacs in the school, we would recommend to initially save your experiments in separate folders on the Desktop and to copy them to OneDrive at the end of the session. You can copy experiments to OneDrive by opening OneDrive in a browser window, navigating to the folder where you want to save the experiment, and dragging and dropping the experiment onto the browser window.


  1. And even if you did: You could simply download and install it again!↩︎