Setting the Gamma Ramp Manually

Hello, I am attempting to set the gamma correction for my monitor.
Ideally I would like to manually set each value in the GammaRamp.
Currently I have had no success in altering the gamma Values or setting the gamma ramp.
Example Code:

from psychopy import core, visual, event
from psychopy.monitors import Monitor
import numpy as np

newMon= Monitor(name='test')
gammGrid=np.zeros([4,6])
gammGrid[:, 1:3]=1
#gammGrid=[[0,1, 1,0,0,0],
#                   [0,1,1,0,0,0],
#                    [0,1,1,0,0,0],
#                    [0,1,1,0,0,0]]
#
newMon.setGammGrid(gammGrid)
myWindow=visual.Window([800,600], monitor=newMon)
myGrating= visual.GratingStim(myWindow, sf=0.02, units='pix', size=(300,300))
myGrating.draw()
myWindow.flip()

#Now if I change the values in the gammaGrid
gammGrid[2,1]=0
gammGrid[3,1]=0
newMon.setGammaGrid(gammGrid)
#gammGrid=[[0,1, 1,0,0,0],
#                   [0,1,1,0,0,0],
#                    [0,0,1,0,0,0],
#                    [0,0,0,0,0]]
#
myWindow=visual.Window([800,600], monitor=newMon)
myGrating= visual.GratingStim(myWindow, sf=0.02, units='pix', size=(300,300))
myGrating.draw()
myWindow.flip()

There is no change in the appearance of the stimulus (the gamma Table seems to not
have an affect).
I do not have any Bits++ equipment.
Any suggestions on how to control the lookup table would be helpful.
Thanks!
I’m running on Ubuntu 16.04
Python 2.7
OpenGL 2.1
Graphics Card: ATI Radeon x1950

1 Like

Thanks…just corrected it

If you run the coder demo gammaMotionNulling.py do you see the screen switching brightness?

Hello, I ran the gammaMotionNulling.py script in the builder/experimental control
file.
Ran script from terminal:
python gammaMotionNullling.py
I received this set of errors:

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
12:55:05 PM: Debug: Failed to connect to session manager: SESSION_MANAGER environment variable not defined

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion 'G_IS_DBUS_CONNECTION (connection)' failed

(gammaMotionNull.py:15898): GLib-GIO-CRITICAL **: g_dbus_connection_get_unique_name: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
The program 'gammaMotionNull.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 202 error_code 2 request_code 152 minor_code 18)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

{'lowGamma': 0.8, 'observer': u'', 'highGamma': 3.0, 'contrastModNoise': 1.0, 'lumModNoise': 0.5, 'nTrials': 50, 'lumModLum': 0.1}
{'lowGamma': 0.8, 'observer': u'', 'highGamma': 3.0, 'contrastModNoise': 1.0, 'lumModNoise': 0.5, 'nTrials': 50, 'lumModLum': 0.1}

Gamma don’t seem to be working (in the sense that the settings have no effect - I don’t receive any errors) for me either, actually - neither when set when opening a window or when using gammaMotionNull.py. This is on Linux with 1.85.4.

On a different computer, I also receive the same error as @ron_miller when running gammaMotionNull.py.

Also, I don’t receive any errors if using the pygame winType - but the gamma does not change either.

I have opened an issue related to this.

1 Like