Programming Psychological Experiments using python and OpenSesame (academic year 2022-2023)
Programming Psychological Experiments using python and OpenSesame (academic year 2022-2023)¶
Welcome to this JupyterBook, which provides the course material covered partially in the course Experimentation I: Programming Psychological Experiments. This course is part of the research master program in Psychology at Leiden University in the Netherlands.
Using this material, you can learn how to code in python, build experiments using OpenSesame, and do basic data preprocessing in python. Like the software packages we will be using, all of the material in this course is open and freely available. Please note that the compiled JupyterBook is a collection of teaching material from various sources, and it heavily relies on and integrates earlier work generously provided by others online. We always acknowledge the work of these contributors whenever we use their material. The major contributors are mentioned below.
How to use this material?
Make sure you save your work in a well-organized folder structure. Some of the later exercises build on work you did earlier during the course.
We have provided solutions to all exercises here. Just keep in mind that there are often multiple ways to solve a problem, so if you come up with a different solution, that doesn’t necessarily mean you’re wrong. Don’t forget that figuring out how to solve a problem on your own is an important part of the learning process and can be incredibly fulfilling. Embrace the challenge and take pride in your ability to find solutions independently!
If you’re taking this course in-person at Leiden University: This course material is partially covered in an intensive eight-week course at Leiden University, where you will participate in practical sessions to receive live feedback and help. No prior programming knowledge is assumed. We expect that you have read/watched the lessons at home. During the practical sessions, you will then work through the python exercises, the OpenSesame tutorials, and the subsequent exercises in class.
If you’re teaching yourself: We understand that it can be challenging to self-teach python and OpenSesame, and you may need help from a more experienced classmate or colleague, particularly during the exercises. If you are interested in having a similar course organized by us at your institute, please feel free to contact us to discuss possibilities.
Our course is a renewed version of an earlier course that Henk led at Leiden University for over a decade. This course focused on E-Prime and accompanied the book The E-Primer, which was written together with Michiel Spape, Rinus Verdonschot, and Saskia van Dantzig, my esteemed colleagues at Leiden University in the early days. Although the current course is much more focused on coding than the previous course, we still owe a lot of inspiration from the earlier book and even have reused parts of this book in the current course. Our initial discussions with Dirk van Morselaar (VU Amsterdam) were also really influential and helped us to make python coding a central part of this course.
Additionally, many of the lessons and python exercises in this course are based on the “Python for Everyone” course provided by Charles R. Severance. We are grateful for the opportunity to integrate his open material into this course.
Some of the OpenSesame tutorials in this course directly come from the OpenSesame website developed and maintained by Sebastian Mathot and his colleagues. We thank Sebastian for his help and the useful advice he provided.
We would like to express our gratitude to the authors whose tutorials we were able to include in this course, especially James E. Bartlett and Todd M. Gureckis, as well as all the other researchers who have generously made their material available online for us to use in our course.
Finally, we are grateful to the teaching team at Leiden University who have contributed to this course and provided helpful feedback on the materials, including Xaver Funk, Selin Topel, Samarth Varma, and Jin Yan. We would also like to thank Anne Urai, Guido Band, Sander Nieuwenhuis, Ili Ma, the technicians of the SOLO lab support team, members of the research master committee, and members of the Open Science Community Leiden for their contributions and support.
Last but not least, we are grateful to the board of the faculty of Social and Behavioral Sciences at Leiden University for awarding us a Grass shoots grant, which allowed us to develop the teaching material for this course.
Leiden, January 2023
Jeshua Tromp, PhD student
author and workgroup instructor
Dr. Henk van Steenbergen, Associate Professor and PI at the Affect, Motivation and Action lab
author and course coordinator