Perceptual VBLSyncTest - Color Code Grey

Hey guys,

in a script I am using the same procedure as in Perceptual VBLSyncTest, so I flip the background between white and black for every frame. The SyncTest works perfectly on my system (Mac Catatalina, CRT Monitor, 120 HZ) now, I see a nice grayish background. I would like to present stimuli on this background now, having exactly the same color as the background. I thought that due to the fact that the background switches between white (255) and black (0) the whole time, the gray background should have a color code of 127.5. However, this is not the fact. Is there any way to find out the right color code? If I run a for loop to find out the color, it only gives me 0 255 0 255 0 255 0 255 the whole time.

Appreciate your help! :slight_smile:

Technically, you cannot use a decimal value if you are using [0 - 255] to specify your colours. So 127.5 would be rounded up to 128. It is often better to set PTB to use [0 - 1], using PsychDefaultSetup(2) at the start of your code, then specify colour like [1 1 1] for white, [0.5 0.5 0.5] for grey etc. This is the first part, ensuring your colours are specified as precisely as possible, but this by itself doesn’t explain your result.

Now if you haven’t corrected your display gamma, then your display has a non-linear relationship between black and white and 0.5 is much closer to black than white:


You will need to correct your gamma (using a photometer to measure your display lumiance), or guess-timate the grey value that most closely approximates it (in the figure assuming a gamma of 2.2, grey should be around [0.72 0.72 0.72])


Wow, that is an amazing hint, thank you! I will check that

Fwiw., help PsychGamma shows various helper functions that help with computing a good fitting gamma function from mesurement data and explain how to apply it, and for manual gamma measurement there is help CalibrateMonitorPhotometer with references to automated procedures - the latter however with very sparse documentation and a bit dusted.


1 Like

Thanks Mario, I appreciate! If I see correctly this is to fit measurements after data collection, however I would like to find out the right color setting in advance,

Without any measurements, how can you know what is the right setting? The gamma is different for different operating systems, and can be affected by your monitor settings. As I said, you could “guess” by trying to match a grey level (use keyboard to change grey until it “disappears”), but that is only valid for one point, and some reviewers would not be satisfied with such a hack. Measuring and correcting gamma is a basic fundamental of most vision research…

1 Like