psychopy.org | Reference | Downloads | Github

Launcher.py file for running experiments one after the other?


#1

Hi there,

On the old psychopy-users group, mention is made of a script that can be used to run multiple experiments one after the other (see post from Jeremy below).

The link is now deprecated - I was wondering if a similar script exists anywhere else?


A cross-platform way to do this is to manually compile your individual Builder experiments into code, and save the code for each experiment as a .py file. (Save them all into a new clean directory–just one directory for the whole set, not a new one for each script.) Then download a short python script, launcher.py, from here: https://gist.github.com/4076435 Save it in the same directory as the .py files (and have nothing else in the directory). Then execute launcher.py, e.g., from the command line: python launcher.py

That will find and then call all of the PsychoPy experiments in order. You can name the files in such a way that it controls the order in which they will be run (they get sorted by file name). Its also easy to randomize the order instead.

Only tested on a mac (and not thoroughly tested).



#2

Hi, I’ve posted something on that topic a while ago:

I’ve wrote a command line tool to run a python module from the PsychoPy environment.
In that same post I also explain how to build a .psyexp into a .py using that tool (so no need to open the PsychoPy environment any more).

Didn’t test it with the most recent versions of PsychoPy though. Give it a try.

Hope this may help.
Cheers


#3

Tested now with PsychoPy-1.85. Here’s an example of usage (run in a terminal window), supposing that your python script is in the current directory:

python PsychoPyPython.py -r /Applications/PsychoPy2-1.85.app -w pwd -p -a experiment_lastrun.py

In this case, I use the default python interpreter installed in my system to run PsychoPyPython.py (that was the assumption). You could get the same result through a bash script (see attachment: rename as PsychoPyPython.sh and perform a chmod 766. Possibly edit to update some paths).

PsychoPyPython.csv (1.7 KB)

L.


#4

I just discovered how you can run a .py from within the PsychoPy environment. On OS X, it’s as easy as

open -W -n -a /Applications/PsychoPy2-1.85.app --args -x myexpe_lastrun.py

So to run multiple experiments, one after the other, just make a list of commands like the one above.
Cheers,
L.