Gamma correction
Background
Typical screens have nonlinear outputs. This means that if your psychtoolbox or python script gives a command to show luminance values in liner steps, e.g. 0, 0.25, 0.5, 0.75, 1.0, the measured monitor light emittance will not be linearly spaced. For details, see e.g. https://www.eizo.com/library/basics/lcd_display_gamma/
In visual psychophysics, we want to have a linear mapping between the input and output, and therefore we “linearize” monitors. This page describes how we do it in the lab.
You will need
Light meter device, like PCA-L335 (can be found in PTA’s office). There are other similar devices available1.
A computer with two independent screens, one output screen and one experimenter screen (can be a laptop with an external screen) running psychtoolbox. For this procedure it does not have to be a linux computer, since timing is not important.
General info
For luminance measurement on a certain screen (output screen), two monitors and a spectrophotometer are required. The Psychtoolbox script is run on the primary display monitor, while the luminance of the output secondary screen is being measured. For the measurement, you need to stabilize the photometer on chinrest or anywhere in front of the output screen. In the worst case, a second person can hold the photometer at a constant distance.
With the saveReadings.m script, 17 different levels of brightness for each of the three colors (R, G, B) and for all three colors together (grey), respectively, are displayed on the output screen. The light measures shown on the lux meter can be typed into the command window.
However, it is better to note them on paper or - even better - in a spreadsheet of another computer. This is because in case you mistype something in the script, you will have to redo everything from the beginning, which can be annoying.
When the script is run without an error, it automatically saves the 17 values into a mat-file (but it is better to note them on paper as well, as mentioned above). Importantly, if you care about the absolute lux values, the room in which brightness is measured has to be as dark as possible. Thus, the primary display monitor ideally should be covered with dark tissue during the procedure if it is not isolated.
Operation
open
saveReadings.m
and edit the general info. If you want to customize the measurement, you may change the parameters as well.run
saveReadings.m
(alternatively, you may call directly the functionvals = saveMonitorPhotometerReadings(17, 'red')
)then, call the function to create gamma tables
[displayBaseline, displayRange, displayGamma, maxLevel] = createGammaFromSavedReadings(labName, screenName, 'plot', 0)
The script will fit a gamma curve to the brightness readings you recorded.
Two gamma tables and two spline tables will be saved: one with RGB and one with gray. You need to decide which one is used (default for experiments: rgb_gamma). If you want to make further customization please dig into the scripts.
Link to our GitHub repo containing relevant scripts
Link to saved values and Gamma lookup tables for VPixx/3D
Link to saved values and Gamma lookup tables for MRI display devices
Usage
In Psychtoolbox, you can load a saved gamma table
http://psychtoolbox.org/docs/Screen-LoadNormalizedGammaTable
or simply indicate a gamma value
In PsychoPy, you can indicate a gamma value in Monitor Center
Footnotes
There are also fancy spectrometers ranging from 200 to 20000 Euros in price, which can be connected to the computer via a USB. This allows to store the color spectra automatically. For simple gamma correction a lux meter is enough though.↩︎