Using Psychopy with a 10 bit display

Great!
Thanks a lot :slight_smile:

Hi there, I tried your suggestion, but I don’t see the display working at 10 bit depth.
I am attaching my code, in which I have varied the color in steps of 0.001 and haven’t found any changes in the display.

from psychopy import visual, event, core

Create a PsychoPy window with ‘rgb255’ color space

win = visual.Window(
size=(800, 600),
color=[-1,-1,-1],
colorSpace=‘rgb’,
)

Initialize gray level

gray_level = -1

Create a white box stimulus

box_stim = visual.Rect(
win=win,
width=0.5,
height=0.5,
fillColor=[gray_level, gray_level, gray_level],
lineColor=[gray_level, gray_level, gray_level],
pos=(0, 0),
)

Create a text stimulus to display the gray level

text_stim = visual.TextStim(
win=win,
text=f’Gray Level: {gray_level:.3f}',
pos=(0, -0.6),
color=‘white’,
height=0.1,
)

Draw and display the initial white box and gray level

box_stim.draw()
text_stim.draw()
win.flip()

Main event loop

while True:
keys = event.getKeys()

if 'return' in keys:  # 'return' corresponds to the 'Enter' key
    gray_level += 0.001

    # Ensure that the gray level stays within the 0 to 1 range

    # Update the box and text stimuli with the new gray level
    box_stim.fillColor = [gray_level, gray_level, gray_level]
    box_stim.lineColor = [gray_level, gray_level, gray_level]
    text_stim.text = f'Gray Level: {gray_level:.3f}'

    # Draw and display the updated white box and gray level
    box_stim.draw()
    text_stim.draw()
    win.flip()

elif 'escape' in keys:  # 'escape' key to exit the loop
    break

Close the window

win.close()
core.quit()

it would be really helpful if anyone could tell me the issue

Hi Varun, wanted to ask if you followed up with a solution to your problem? And would like to ask if necessary to set bpc=(10,10,10),depthbits=10 when creating the window since the default is 8?

Hi Varun, I am only seeing this now, I hope my response may still help a future reader.
Even a change of 1/255 in the intensity of an RGB coordinate might not be visible to the average human eye.
This visibility depends on the room’s lightning, on the display’s configuration and on the user’s eye color sensitivity. It might be harder or see such changes in some parts of the color space than in other.

In my opinion there are two ways to validate that your PsychoPy code actually uses 10 bit depth:

  1. Measure your display externally with a spectrometer while using colors which would have the same 8 bit representation, but have different 10 bit representations.
  2. Display some kind of gradient and see that it looks smoother on a 10 bit window than on an 8 bit window.

hi alon, i am going to try one of the way you mention to validate the 10 bit code (on a 10 bit display).
before the experiment, i wander ask sth about the setting, whether all i need to do is to set the visual.Window(…,winType=‘pyglet’, bpc=10, depthBits=10, colorSpace=‘rgb1’…) then a luminance pattern (such as visual.GratingStim) can be changed by 1/1023 for every step?
Thanks for any response

I am afraid I can’t help with that…
I planned to use a 10 bit display for an experiment so I thought on how to validate it, but in the end we didn’t use a 10 bit display, so I didn’t really check it out.
A swift look at pygletbackend.py makes me think that you are correct, with one small change: depthBits should be 30, not 10.

thanks a lot! i will try it later hope it will work :100: