I wanted to construct a stimulus with misaligned lines that contains illusory lines (orthogonal to inducing lines, see below the code). I want to be able to control the orientation and drifting speed of the stimulus (like with regular gratings). I tried to use ElementArrayStim and Lines. However, I am not sure what would be the best way to achieve this. I am posting my current progress.
One way to do this would be to save stimuli and then use them as static images. Yet, if I want to change any parameter (eg line length), I would need to regenerate all stimuli of different orientations again. I am looking for a way to dynamically generate this stimulus.
I would appreciate any help on this.
import numpy as np import psychopy.visual import psychopy.event mon_x, mon_y = 910, 540 win = psychopy.visual.Window( size=(mon_x, mon_y), fullscr=False, units="pix", color = 1 ) # gap between x lines sf_ils_line = 300 # gap between y lines sf_inducer = 100 # fill the screen with lines x = np.arange(-1*(mon_x/2), (mon_x/2)+1, sf_ils_line) y = np.arange(-1*(mon_y/2), (mon_y/2)+1, sf_inducer) xx, yy = np.meshgrid(x, y) # add misalignment yy[:,::2] = yy[:,::2] + sf_inducer/2 n_lines = xx.shape*xx.shape xys = np.zeros((n_lines, 2)) xys[:, 0] = xx[:,:].flatten() xys[:, 1] = yy[:,:].flatten() lines = psychopy.visual.ElementArrayStim( win=win, nElements= n_lines, xys = xys, elementTex=np.ones((1, 4))*(-1), elementMask=None, sizes=(sf_ils_line, 10) ) lines.draw() win.flip() psychopy.event.waitKeys() win.close()