You are here

Programming Experiments in Python

Programming Experiments in Python

December 2021 | 297 pages | SAGE Publications Ltd

Python is a free, open-source, cross-platform programming language that allows a great deal to be accomplished in very few lines of code. As well as having a powerful, flexible syntax, Python can interface easily with other libraries and hardware on any computer system, making it ideal for interacting with additional devices hardware (e.g. for fMRI, EEG, eye tracking etc.). Python has become the go-to language for a wide variety of behavioural science studies and experiments.

Aimed at advanced undergraduate students, postgraduate students and professional scientists, this textbook provides a comprehensive guide to enable readers to write experiments in Python, or using Python within PsychoPy. This text offers a more advanced guide to developing psychological experiments in Python and can be used as a guide to using software and hardware together – for example, programming a psychological experiment using eye tracking software or EEG systems.  Highly practical in nature, the book shows how to programme one full experiment and how to analyse data and scripting.


Read together with Building Experiments in PsychoPy, this text is designed to support students who are familiar with PsychoPy and how want to progress into programming in the original software package Python (on which PsychoPy is built).  It will help advanced students to programme directly in Python and support them when they use hardware in their experiments, and it particularly suited to those students programming experiments in cognitive psychology and neuroscience. 
Python Programming basics
Python for MATLAB migrants
Coding a full experiment: Posner cuing task
Improving the Posner task
Understanding your hardware
Other PsychoPy stimuli
Using Rating Scales
Connecting to hardware with ioHub
Using adaptive methods to find thresholds
Combining PsychoPy Builder experiments with code
Good coding practices
Data analysis
Using Python for all your scripting needs
Using Python for neuroimaging
Advanced Features of PsychoPy

Preview this book

Jonathan Peirce

Jonathan Peirce is Associate Professor in Psychology at the University of Nottingham, with a background in visual neuroscience and a particular interest in research methods. For his research, Jon needed precise (and dynamic) stimulus presentations. For teaching psychology undergraduates about research methods, he needed software that was intuitive enough for them to understand. The combination of these needs (and his generally geekiness) caused Jon gradually to create PsychoPy. Happily, many people have got on board with the project and it grew. When he isn’t designing experiments, writing software or trying to teach students to be... More About Author

Jeremy R. Gray

Michael MacAskill

Michael MacAskill is a Senior Research Fellow in the Department of Medicine at the University of Otago, Christchurch. He is also the Research Director at the New Zealand Brain Research Institute. His training is in experimental psychology and his research is mainly in the field of Parkinson’s disease, through projects in brain imaging, neuropsychology, and epidemiology. His main joy, however, lies in measuring fast eye movements (saccades).Looking for better ways to study them, in 2008 he discovered what Jon had achieved with PsychoPy, and has since become a passionate believer in the enabling power of open-source software.Living in a... More About Author

Purchasing options

Please select a format:

ISBN: 9781473991415
ISBN: 9781473991408