I am presenting a Grating stimulus in a randomly selected color. Additionally, to mask the color of the stimulus, I am specifying a tex array that defines the proportion of color-specific pixels (e.g., red) and those that are not specified. Because of how the texture function operates, the non-specified pixels are typically presented in gray (i.e., given color value multiplied by zero = ‘gray’).
I would like to present these unspecified pixels in ‘white’ instead. Is there a way to do this?
Here is what I’m currently working with:
import numpy as np
from numpy import random
from psychopy import visual, event
win = visual.Window(size=(1200, 1080), #fullscr=True
allowGUI=True,
color="white",
units='pix',
colorSpace='rgb'
)
noiseTexture = np.zeros(300*300)
noiseTexture[:round(noiseTexture.size*0.4)] = 1 #0.4:0.2:0.8
np.random.shuffle(noiseTexture)
noiseTexture = noiseTexture.reshape(300,300)
noiseCircle = visual.GratingStim(win=win,
tex=noiseTexture,
size=(300,300),
units='pix',
interpolate=False,
mask='raisedCos',
maskParams = {'fringeWidth':1},
color = (255,0,0),
colorSpace='rgb255'
)
noiseCircle.draw()
win.flip()