Programming and Automation Techniques for Psychologists

Welcome! Our mission is to teach you how to stop relying on point-and-click experiment packages and program your own experiments, script common tasks, organize your data, and in the process, become a better scientist.

In Spring, 2018 we will be meeting on Thursdays 9:00am-11:30am in Psych 634. The class is taught by Prof. Gary Lupyan (lab page), (lupyan at wisc dot edu).

Why Program?

Knowing how to program and how to automate common tasks will make your life (or at least your academic life) better. Much better. A programmatic approach will allow you to create experiments in hours that would take days or weeks of fiddling in point-and-click packages like Eprime. Programming your experiments will give you complete control overy every aspect of the procedure. You will never again need to worry about whether you can implement your experiment in some program. If you can think it, you can program it. A globally programmatic approach to behavioral research will also mean that you will never have to shuffle lists in Excel to create the proper counterbalancing or randomize things. You will never have to copy and paste data files, or gasp manually code people's (objective) responses. Changing the size of 1000 images or measuring the onset latency of a voice response becomes as simple as executing a little program, which at the end of the class, you will be able to write from scratch.

At the end of the class you'll be comfortable with creating full-blown experiments using Python and Psychopy. You will learn how to design experiments in a programmatic way (no pointing, no clicking) and be amazed with your increase in efficiency. In addition to coding experiments, by the end of the class you'll be on your way to doing all sorts of fancy schmancy things in Python and command-line tools (e.g., data massaging of all sorts, (basic) corpus linguistics, automatic image and audio processing, and collecting some data online. The world will be your oyster. Mmm, oysters.

Class philosophy

Programming, as taught by computer scientists, emphasizes lots of theory (pointers, O-notation, garbage collection) and relatively abstract problem solving (e.g., implementing sort algorithms, navigating trees, recursive functions). Although this is an excelelnt way to gain a deep understanding of computer science, we are betting that it is not the best way to teach applied programming skills in a short amount of time to non computer-scientists. In this class we'll be taking a more applied approach. Every exercise we do will introduce students to a skill relevant to solving problems commonly encountered in behavioral research. We'll learn some theory along the way, but the focus will be on practical how-to solutions. If you've never programmed before, you're in for an initially steep learning curve, but it will flatten out quickly, and your mind will be blown at what you are able to accomplish. If your only experience with programming came from data-analysis environments like R or environments specially created for scientific computing like MATLAB, you will appreciate the power and elegance of Python. If you have some experience programming in languages like Java and C, you will find the transition to Python itself quite easy, and will learn a lot about how to make efficient use of Python and various open-source tools for quickly moving from an experiment idea to analyzable data.

What now?

  • Begin by following the download and install instructions above to set up your Python environment.

  • If you are in the class, make sure you've joined the Github repository, installed Slack, and joined the class channel (check for invite in your mailbox or email me if you don't see one). For those using this site as a tutorial: I have taken down the posted solutions in preparation for the Spring semester, but if you need a solution (or any code that's not posted), please email me (lupyan at wisc dot edu).

  • Watch the What is Python and how do I run it screencast

The GitHub repository for the Jupyter Notebooks and scripts that generate these pages is here.



If you are currently enrolled in the class, please use the Slack channel. If you are browsing these resources and have a comment/question, please email: lupyan at wisc dot edu.


Gary Lupyan is an Associate Professor of Psychology at University of Wisconsin-Madison. See the lab webpage for info on research and lab openings.