Hello, I am trying to create a rectangular visual cue with a green on black moving grating. With the help of previous answers to questions I managed to get the correct colors by adding a makeGrating filter. However I don’t find any additional information on the filter and how to change its size. If I leave it how it is and only change the width and height of the grating stimulus I get an error message. Down below you find my script, I want to be able to change the grat_width and grat_height and keep the colors. Would be grateful for any help, thank you!
'''
script 7: creates rectanglular green-magenta moving grating in black window with green frame, wavelenght 508nm, saves as gif
'''
#import stuff
import numpy as np
import psychopy.visual
import psychopy.filters
import psychopy.event
import psychopy.core
#create window
win = psychopy.visual.Window(size=[800, 800],fullscr=False,units="pix",color=(-1, -1, -1))
#set size of grating
grat_height = 256
grat_width = 256
#create stimulus
stim = psychopy.visual.GratingStim(win=win,size=(grat_height,grat_width))
#create the filter with grating for color
grating = psychopy.filters.makeGrating(res=256) #cycles=?
#defines colour in HSV
hsv_tex= np.ones((grat_height, grat_width, 3)) # creates array of 1s in three dimensions 256x256x3, last dimension is rgb
#change last element to (grating+1)/2
hsv_tex[..., 2] = (grating + 1) / 2.0 #[...,2] selects every third element
#loop over hues, hue is given in degree
#start: 0 stop: 129(hue in °), in steps of 10
for angle in range(0, 130, 43): #130 because it stops at 130->129 included, 43 steps because it is biggest divider of 129->faster
hsv_tex[..., 0] = angle #changes first element to 129
stim.tex = psychopy.colors.hsv2rgb(hsv_tex) #converts from hsv to rgb
#
stim.sf = 5.0 / 256 #our grating is 256 pixels and we want 5 cycles->spacial frequency is 5/256
#creates green, rectangular frame
rect=psychopy.visual.Rect(win, width=grat_height, height=grat_width, autoLog=None, units='pix', lineWidth=5, lineColor='lime', lineColorSpace='rgb', fillColor=None, fillColorSpace='rgb', pos=(0, 0), size=None, ori=0.0, opacity=1.0, contrast=1.0, depth=0, interpolate=True, name=None, autoDraw=False)
while True: #this creates a never-ending loop
stim.setPhase(0.015, '+') # advance phase by 0.015 of a cycle-> sets speed and direction (+/-)
stim.draw()
rect.draw()
#win.getMovieFrame(buffer='back') #<-remove"#" to save
win.update()
if len(psychopy.event.getKeys())>0:#counts how many keys have been pressed-> window closes when you press a key
break#loop breaks
psychopy.event.clearEvents()
#win.saveMovieFrames('test1.gif') #<-remove"#" to save
win.close()