psychopy.org | Reference | Downloads | Github

Stimuli arriving at a certain time


#1

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")
mywin.update()

#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
fixation.draw()
mywin.update()

#add timer
timer = core.Clock()
timer.add(10)
while timer.getTime()<5:
    fixation.draw()
    stimuli.draw()
    mywin.update()

Am I using the right function timer ?

Thanks


#2

You probably want a CountdownTimer rather than a Clock:

http://www.psychopy.org/api/core.html#psychopy.core.CountdownTimer

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.