I am trying to create a stimulus using a numpy array as the image argument given to the ImageStim class constructor. The array is 2 dimensional with values ranging from -1 to +1, and the dtype is numpy.float64. The stimulus renders as expected; however, when I close the window, I receive this exact error message :
“<timestamp> ERROR numpy arrays used as textures should be in the range -1(black):1(white)”
I have tried duplicating the array along a 3rd dimension giving it all three channels, but the error message persists. I also tried making the array contiguous as suggested in this post, but that did not work either.
Here is a minimal example of the code I am using, and I tried to upload a npy file (file extension not permitted), then a csv file (file to large), so I’m kind of at a loss for how to attach an example image to this post.
# make a dummy array within the range of (-1, 1) image = np.random.uniform(-1, 1, [480, 720]).astype(np.float64) # create the window from psychopy import visual window = visual.Window(size=[720,480]) # create the stimulus stim = visual.ImageStim(window, image=image) # draw and render stim.draw() window.flip() # close the window window.close() # error is raised when the window is closed
I am using PsychoPy version 2020.2.1