Is it possible to run linux terminal commands in a psychopy script?

As with the title, I am looking to change the monitor’s gamma settings (a technical issue doesn’t allow me to use the monitor centre to do this) and I need to do this via the terminal.

I’m wondering if there is a method to insert linux terminal commands at the top of my psychopy script, or is there a way to pull a .sh script within the psychopy script itself and have it run?

Python’s subprocess calls allow this:
https://docs.python.org/3/library/subprocess.html

But for setting gamma you don’t need monitor center; you can do it from the Window class:

win.gamma = [2.2, 2.4, 2.3] # for rgb gamma vals
# or set custom ramp vals
win.gammaRamp = newRamp256x3

http://www.psychopy.org/api/visual/window.html

By doing that your experiment will remain portable across different machines (and PsychoPy will undo your change to gamma as it quits whereas a manual change at command line won’t be undone)

1 Like