psychopy.org | Reference | Downloads | Github

Creating Plaids

Hello,

I am trying to make a plaid (two overlaid drifting gratings at different angles) in psychopy (trying to recreate stimulii like found in figure 1 of https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4489988/). Because gratings are centered around 0, when they are added together, there is interference. However, in most papers I see that plaids are added in a way such that it looks like black bars superimposed on eachother instead of interfering waves. Is there an easy way to do this?

I;ve been playing around with blendmodes and the plaids demo included in psychopy but have no succeeded yet.

from psychopy import visual, core, event

#create a window to draw in
myWin = visual.Window((600,600), allowGUI=False)

#INITIALISE SOME STIMULI
grating1 = visual.GratingStim(myWin, mask="gauss",
                              color=[1.0, 1.0, 1.0],
                              opacity=1.0,
                              size=(1.0, 1.0),
                              sf=(4,0), ori=45)

grating2 = visual.GratingStim(myWin, mask="gauss",
                              color=[1.0, 1.0, 1.0],
                              opacity=0.5,
                              size=(1.0, 1.0),
                              sf=(4,0), ori=135)

trialClock = core.Clock()
t = 0
while t < 20:    # quits after 20 secs

    t = trialClock.getTime()

    grating1.setPhase(1*t)  # drift at 1Hz
    grating1.draw()  #redraw it

    grating2.setPhase(2*t)    #drift at 2Hz
    grating2.draw()  #redraw it

    myWin.flip()          #update the screen

    #handle key presses each frame
    for keys in event.getKeys():
        if keys in ['escape','q']:
            core.quit()

Thanks,
Adam

I’ve edited your post so that the code is readable: please always surround your code in 3 back-ticks (```) so that it gets correctly spaced as code.

If you genuinely want a sinusoidal plaid then the code you’ve got there is correct. The image in Figure one of the linked article is just a schematic of a plaid but not a sinusoidal plaid. I’m sure the genuine stimuli they used did not look like that (if it did then there are some mathematical problems in their stimulus!)

best wishes,
Jon