I’m trying to design a stimulus that consists of multiple overlaid (somewhat transparent) square gratings of different sizes. They will look like visual noise. The overall shape of the stimulus will be a square (128 x 128 pixels).
The overlaid gratings differ in orientation, there are 6 overlaid gratings ranging in steps of 30°, i.e.,
orientations = range(0,180,30).
There are also different sized gratings (128x128; 64x64; 32x32x; 16x16 pixels), which are ‘tiled up’ side by side to form the final visual noise (128x128 pixels, as above). These are a 1x1, 2x2, 4x4, and 8x8 2D matrix respectively.
Here is the challenge I have found: changing the orientation of the default square grating orients the entire shape, but what I need to be able to do is to maintain the default orientation of the square shape (i.e., horizontal and vertical edges at 0° and 90°) and instead only change the orientation of the grating:
Any help here would be appreciated. Here is the code I’ve been using:
from psychopy import visual,event from psychopy.tools import imagetools import numpy as np import math import random imageSize = 128 winHeight = 256 winLength = 256 win = visual.Window( size=[winLength, winHeight], units="pix", fullscr=False, allowGUI=False, blendMode='add', useFBO=True, color=[0, 0, 0] ) grating = visual.GratingStim( win=win, units='pix', tex='sin', interpolate=True, size=[imageSize, imageSize] ) grating_hpos = 0 grating_vpos = 0 orientations = range(0,180,30)*2 for i in range(6): grating.sf = 2.0 / imageSize grating.contrast = np.random.uniform(-1,1) grating.ori = orientations[i] grating.opacity = 1/6.0 grating.pos = [grating_hpos,grating_vpos] grating.draw() win.flip() event.waitKeys()` win.close()