According to the GratingStim documentation it is written:
NB phase has modulus 1 (rather than 360 or 2 pi) This is a little unconventional but has the nice effect that setting phase=t n drifts a stimulus at n Hz
Key question : How to convert frequency into phase
value?
I know incrementing higher value for phase
would result in higher frequency, while lower will result in a slower animation. Can someone help me to understand how this phase is measured? In particular, I would like to have several stimuli on the screen, where each stimulus has different phase
defined by a frequency value. For instance, defining 1 Hz
would animate the stimulus to shift 1 cycle per second ( 2 Hz
= 2 cycle per second). Note also that the size of each “section” is defined by the sf
when declaring visual.GratingStim
.
Sample code :
from psychopy import visual, core, event
mywin = visual.Window([800,600],monitor="testMonitor", units="deg",color='black', )
grating = visual.GratingStim(win=mywin, mask='circle', size=3, pos=[0,0], sf=1)
def freq_to_phase(freq):
phase = 0.05 # TODO: convert freq to phase
return phase
phase = freq_to_phase(10) # <-- how to calculate the phase if desired to have 10hz?
while True:
grating.phase += phase
grating.draw()
mywin.flip()
if len(event.getKeys())>0:
break
event.clearEvents()
mywin.close()
core.quit()