Oriented noisy patch stimulus
By request, here is some code to generate a noisy oriented patch stimulus, such as used for example in Lamme & Roelfsema (2000, TINS):
ExampleGDN
ScriptGDN
from psychopy import visual
import numpy as np
import random
size = 128 # Size of the patch
ori = 45 # Orientation of the patch
# The minimum and maximum number of consecutive pixels of the same colour. Higher
# values give a more pronounced orientation
minD = 1
maxD = 8
# Create a texture, which is a 2D size*size numpy array
tex = np.empty( [size, size] )
# Create a view onto this array, which is just a long 1D array
a = tex.view()
a.shape = size**2
# Fill the view with random values. Crucially, do not fill random values one pixel
# at a time, but fill a stroke of pixels to get the oriented effect
i = 0
while i < size**2:
val = random.random()*2-1 # Random colour value (-1 = black, 1 = white)
j = i + random.randint(minD, maxD) # Random range of pixels
a[i:j] = val # Fill it!
i = j # Advance pointer
# Create the GratingStim and show it. For old versions of PsychoPy, you need to
# use PatchStim() instead.
# See http://www.psychopy.org/api/visual/gratingstim.html
p = visual.GratingStim(win, tex=tex, mask='circle', ori=ori, size=size)
p.draw()
win.flip()
This script uses PsychoPy, so it requires the Psycho back-end.
Cheers!