psychopy.org | Reference | Downloads | Github

Isoluminant stimuli

Following the link here, I am trying to make isoluminant stimuli: Making isoluminant stimuli — PsychoPy v2021.2

I have a stimuli such that the colors are stored in a variable.

image

dkl = np.asarray([0,0,1])

# And I try converting like this:

rgb = dkl2rgb(dkl, conversionMatrix=None)

polygon.setColor(rgb, 'rgb255')

However, the conversion yields a completely different color (from pink in dkl to black in rgb)

Psychopy version: 2020.2.10

We’ve changed quite a lot of color space stuff since 2020, if you update to 2021.2.3 then you can do this:

col = colors.Color([0, 0, 1], 'dkl')
stim.fillColor = col
stim.lineColor = col

and it will keep the same color regardless of color space, as it’s a Color object which knows its value in RGB, hex, HSL, etc.

Thank you for your answer. Unfortunately, the updated version says this is not implemented.

“Conversion from rgb to dkl is not yet implemented.”)
NotImplementedError: Conversion from rgb to dkl is not yet implemented

And the dkl2rgb method I use above also throws the same error.

Also this error is misleading, I am converting from dkl to rgb. However the error says otherwise.

I have a dkl stimulus and I change the color space via stim.colorSpace = ‘rgb255’ and the same thing happens.

What happens if you set the color space of the stimulus in builder to just be rgb and the color to be $colors.Color([0, 0, 1], 'dkl')? So that the stimulus is never in color space dkl

What you asked for works. But this throws the same error as above.

image

And I guess I need to convert from dkl to rgb.

Do you know anyother way to make isoluminant stimuli?

That makes sense - as dkl to rgb is implemented, but rgb to dkl isn’t. So when the space of the stimulus is dkl, but your color is defined in rgb, it raises a not implemented error. What you need to do is the other way around - define the color in dkl, but set the stimulus in rgb.

2 Likes

I see, thank you for your answer. Although we changed our minds about using isoluminant stimuli, it will be useful for future reference to others and myself.