| Reference | Downloads | Github

Stimuli arriving at a certain time

Hi every one, I’m new on PsychoPy and I have to create many tasks for my phd.

First, I’m trying to do a task where I will ask the participant to fixe a fixation even if there is distractions.

So, I did a first fixation and now I want to add stimuli on the side of the window every let say 5 seconds, the stimuli would come for 1 sec and disappear after.

#create a window
mywin = visual.Window([800,600], monitor="testMonitor", units="deg")

#create a fixation and a stimuli
fixation = visual.GratingStim(win=mywin, size=0.7, pos=[0,0], sf=0, rgb=-1)
stimuli = visual.GratingStim(win=mywin, size=0.3, pos=[-11,0], sf=0, rgb=-1)

#draw the fixation and update the window

#add timer
timer = core.Clock()
while timer.getTime()<5:

Am I using the right function timer ?


You probably want a CountdownTimer rather than a Clock:

i.e. the code above would draw your stimuli for approximately 15 seconds.

You might be using some very old examples to base this work: you should use win.flip() rather than win.update(). You should prroabaly check out the demos menu from the Coder view and work through the timing examples. In particular, come to understand timing by counting frames as compared to timing using clocks.

1 Like