| Reference | Downloads | Github

Grating drifting

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): win 10
PsychoPy version (e.g. 1.84.x): 2021.2.1
Standard Standalone? (y/n) If not then what?:y
What are you trying to achieve?: I am trying to creat a drifting grating in the Builder mode. According to the book Building Experiments in PsychoPy from Peirce, Grating phase in PsychoPy is a little unconventional. Rather than using degrees or radians as its units, PsychoPy uses ‘cycles’ and the wave ‘starts’ in the center of the stimulus. So, when phase is set to 0.0, the grating will have a white stripe in the center, when set to 0.5 it will be 252 black in the center (the trough of the wave is a half cycle from the peak); and when it reaches 1.0 it will be back to being white. This may all seem confusing, but it allows us to make the grating drift very easily by setting the phase to be a value based on time. A phase that is set to $t will drift at 1 cycle per second (Hz), and a phase set to $2*t will drift at 2 Hz.

However, when I defined the phase as $0.5t or $2t, neither works. The Runner software give me a message, NameError: name ‘t’ is not defined

What did you try to make it work?: tried different values, $0.5t or $2t or $t, neither works, the grating do not drift.

What specifically went wrong when you tried that?:
Include pasted full error message if possible. “That didn’t work” is not enough information.

I would like to ask, if anybody have experience of drifting grating in the mode of Builder, how to set the phase?

Many thanks!


Do you have these values set to update each frame? If not then they’ll be set at the beginning of the experiment - i.e. before t is defined

The grating does drift when I set the phase to each frame other than constant. :clap:.

As the unit of phase is cycle per second (Hz). How can this unit be transformed to the unit degree per second, which is used by many literatures regarding the visual stimuli. So 1 °/sec=1/360 Hz, the speed for 12°/sec is about 0.034Hz. So the phase should be set to $0.034*t. Did I understand it well?