Hero image

Vision and Haptics Laboratory: PsychoPy Demos

Introduction

The aim of these demos is to provide an introduction to how to program using PsychoPy. To get started you will have needed to have downloaded the standalone PsychoPy application or downloaded a Python distribution and installed PsychoPy and its dependancies.

We will be showing you how to code in PsychoPy, not how to use the "drag and drop" style "bulider" interface. Thus, we reccommend installing a Python distribution and code editor, rather than using the standalone application. This offers far more flexibility and utility, and is far more relevent a skill to real-world programming. We reccommend the Anaconda  Python distribution and Visual Studio Code. Details of installing PsychoPy can be found here.

Note that currently using PsychoPy with an external editor is very difficult with macOS - you can get most of it working but if you want it all working you will need to use the standalone PsychoPy application.

These demos are based upon the highly popular and widely used Psychtoolbox Demos which have been developed by the lab over many years. We are in the process of making a comparable resoure for PsychoPy. Thus, this is very much a work in progress as it will take quite some time to translate the 90+ Psychtoolbox Demos into Python and PsychoPy. 

The Psychtoolbox demos have been translated by Peter Scarfe and Max Sargent (credits stated in each peice of code). There are many differences between Psychtoolbox and PsychoPy. As such, in places a direct translation is not possible, very difficult, or simply not at all sensible due to differences in the systems. 

Please note that the demos are currently under heavy deveopment, so should be considered alpha at best for now. 

(1) The Basics

The aim of the tutorials is to assume no prior experiance of programming with PsychoPy. As such, this first set of demos starts with the complete basics to introduce you to the core principles that constitute the foundations for all that follows. If you look at the later demos you will see that virtually all of the core code is shared with these early demos. Therefore, if you have never programmed with PsyhoPy, start here. 

 

Totally Minimal Demo: This demo aims to be as minimal as possible. It opens a screen and colours it grey. Thats it. But it demonstrates pretty much the steps you will always use when starting a peice of code.

 

  

(2) Basic shapes and dots

This set of demos will show you how to draw static shapes, lines and dots. Much of the code in these demos shows the core functionality of drawing to the screen with PsychoPy so will be a valuable start-point for understanding the material covered in latter demos.

 

Single Dot Demo: This very simple demo draws a single dot on the screen in a randomly determined position.

Dot Grid Demo: Shows you how to draw multiple dots with different properties in a single line of code. In this example a uniform grid of dots with different positions, sizes and colours.

Rectangle Demo: Shows you how to draw a rectangle and position it on the screen.

Multiple Sqaures Demo: Shows you how to draw multiple rectangles (in this case squares) with different colours simultaneously.

Different Squares Demo: Shows you how to draw multiple rectangles (in this case squares) each differing in both size and colour.

Order of Drawing Demo: This demo explains about sequential drawing. This is key to drawing multiple objects to the screen e.g. overlapping objects.

Simultaneous Contrast Illusion Demo: This demo builds on "Order Of Drawing Demo" by drawing a simple simultaneous contrast illusion.

(3) Animate basic shapes and dots

Now we have mastered drawing static stimuli to the screen, we will learn how to animate these shapes. Essentially this will allow us to translate, rotate expand and shrink objects drawn to the screen. We will also learn how to change the colour and size of objects contingent upon their movement. And finally, also learn how to interact with objects on the screen with the mouse or keyboard.

 

Under construction

Instagram image Instagram image Instagram image Instagram image Instagram image Instagram image