Hi Lindsey,
The gratings are out of phase because the starting_phase parameter specifies the phase at the “starting” edge of the grating (e.g. the left edge when the direction is 0), rather than at the center of the grating. John Maunsell noted ages ago that this doesn’t make much sense, but I didn’t feel comfortable changing such a basic behavior after the stimulus had already been in use.
Fortunately, I think you can get the behavior you expect by adding a computed offset to the starting phase. To do this, change the definition of opaque_grating
by replacing
starting_phase = phase_deg
with
starting_phase = phase_deg + 360 * spatial_freq_cpd * (diameter_deg / 2)
I believe this will resolve the issue. If not, please let me know!
Cheers,
Chris