Running a session with multiple experiments

I discovered that in psychopy.session - for running a session with multiple experiments — PsychoPy v2024.1.4, it is possible to run a session with multiple experiments using Psychopy. However, I am unfamiliar with the code. Could someone please provide a code example to illustrate how it functions? Thank you.

Session is still pretty new so there’s a bit of polishing needed before we encourage people to use it en masse, but sure I’d be happy to give a quick walkthrough of how it works!

Since 2023.2.0, the code written by Builder has been split into functions (setupWindow, setupDevices, run, etc.) and Session essentially allows you to supply a set of .psyexp files and then call those functions independently. So for example, you may want to set up a window once and run several experiments on it.
In code, you’d create a Window (win = visual.Window(...)) then create a Session object like so:

thisSession = session.Session(
        # paths should be relative to the root folder
        'exp1': "./exp1/exp1.psyexp",
        'exp2': "./exp2/exp2.psyexp",
        'exp3': "./exp3/exp3.psyexp",

and you can then run any of those experiments (and setup the window according to its settings, setup devices defined in that experiment, etc.) using the Session object. So to run exp1 for example you’d do:


There’s a lot more it can do (particularly around asynchronous execution) but that’s kind of the basics of it :slight_smile:

1 Like