Hi Everyone,
This is a weird issue and I can’t make head or tail or it, so if anyone has even an incomplete suggestion as to what on earth is going on I would be very very grateful!
The issue: Once an rgb array has been converted into dkl space and then back again it no longer displays correctly. It displays nine smaller versions of itself in a 3x3 shape.
I’ve checked the conversion code and a whole bunch of other stuff and in the end established that according to numpy.array_equal the array is the same when it goes in as when it comes out. However, it clearly isn’t the same because visual.GratingStim does not display the same thing. I haven’t got the first idea what is different about the two arrays because as I say they are - as far as I can tell identical. To make it even weirder this didn’t used to be an issue in earlier iterations of PsychoPy. As far as I can tell it seems to have cropped up somewhere between 1.77.01 and 1.81.00. I’ve looked at the changelog and I can’t see anything that looks obviously related, but honestly I’m not even sure what I would be looking for. See below for a minimal code example - you can see that testGrating displays correctly whereas rgbTestGrating does not.
So - when are two identical variables not identical?
Thanks so much,
Becky
from psychopy import visual, misc, event
import numpy as np
import copy
myWin = visual.Window((800,600), units = 'pix', monitor = 'testMonitor', fullscr = True)
temp = np.ones([512,512])
temp[:255] *= -1
testGrating = np.empty((512,512,3))
testGrating[:,:,0] = copy.copy(temp)
testGrating[:,:,1] = copy.copy(temp)
testGrating[:,:,2] = copy.copy(temp)
dklTestGrating = rgb2dklCart(testGrating, conversionMatrix = None)
rgbTestGrating = misc.dklCart2rgb(dklTestGrating[:,:,0], dklTestGrating[:,:,1], dklTestGrating[:,:,2], conversionMatrix = None)
print np.array_equal(testGrating, rgbTestGrating)
patch = visual.GratingStim(myWin, tex = rgbTestGrating, size = (512,512))
patch.draw()
myWin.flip()
event.waitKeys()