Building Robust Neuroscience Experiments with Python and PsychoPy
Learn to build modular experiments with Python and PsychoPy using software engineering best practices like automated testing, data validation, and continuous integration.
Authors
This course provides an introduction to building and designing experiments with Python and the PsychoPy library. Going beyond mere scripting, you’ll learn how to create modular applications that are easy to understand, maintain and reuse. The course explores tools and best practices from sofware engineering like automated testing with PyTest, data validation with Pydantic, and continuous integration with GitHub Actions. While exploring several advanced topics, you don’t have to be a seasoned programmer or experimenter to get a lot out of this course!
Credits
Installation
To run the course materials on your own machine, it is recommended that you:
- Install VSCode as your editor
- Install pixi or alternatively conda to create virtual Python environments (see the lessons on environment and package management)
- Create a dedicated folder for this course and install the virtual environment:
Download the pixi.toml file and install the environment:
pixi install --manifest-path pixi.toml
pixi shellDownload the environment.yml file and install the environment:
conda env create -f environment.yml
conda activate psychopyNote that this environment only installs the basic Python dependencies and NOT Psychopy itself. For instructions on how to install Psychopy, the official website is the best resource: https://www.psychopy.org/download.html.
On Windows, you should be able to simply install the psychopy package from PyPI.
On Linux however, there are a few additional steps required.
Course Contents
Python Fundamentals for Creating Experiments
Experimental Flow Control with Loops and Conditionals
Python Fundamentals for Creating Experiments
Storing and Modifying Different Kinds of Data
An introduction to the basic data types and operators in Python
Python Fundamentals for Creating Experiments
Configuring Experiments via Command Line Interfaces
introduction to command line interfaces
Separating Code and Parameters using Configuration Files
Creating Configurable Experiments