Hello everyone, how you all doing?
I have a (perhaps) simple question but I cannot find a solution!
I am coding a task similar to Posner, and I need to control not only the presentation of stimuli ( cue and target for example) by frames but also time intervals between these stimuli. This precise control is for a EEG experiment.
I just know how to do it by using a loop (using FOR or WHILE) frame by frame. But that means that if I put functions like clock or a mouse.reset or mouse.getpressed it will reset every frame (I think that is obvious). And I need to reset the mouse in the beginning of a stimulus presentation and to get the time of a button press from that presentation, without resetting every frame.
Can anybody help me?
(Just an observation: a function “core.wait(number of frames)” would be amazing if anyone feels like coding ;))
Here is the code for an one trial example:
from __future__ import print_function
from psychopy import visual, core, event, monitors
meuMonitor = monitors.Monitor('testMonitor')
win = visual.Window(meuMonitor.getSizePix(), monitor=meuMonitor,units='deg',fullscr=True,color=(-1, -1, -1))
mouse = event.Mouse(visible=False, win=win)
fixpoint = visual.Circle(win, fillColor=(1, 1, 1), units='deg', radius=0.1, pos=(0, 0))
grat1 = visual.GratingStim(win, tex='sqr', units='deg', pos=(11.5, -3.5), size=5,
sf=(1/0.53,0), phase = 0.50, color=(1.0, 1.0, 1.0), contrast=1.0, opacity=1.0)
grat2 = visual.GratingStim(win, tex='sqr', units='deg', pos=(-11.5, -3.5), size=5,
sf=(1/0.59,0), phase = 1, color=(1.0, 1.0, 1.0), contrast=1.0, opacity=1.0)
CueR = visual.Rect(win, fillColor=(1,1,1),width=1, height=1, pos=(0, 1)) #cue to indicate right
CueL = visual.Polygon(win, edges=3, radius=0.5, fillColor=(1,1,1), pos=(0, 1)) #cue to indicate left
StimDict = {
'1': grat1,
'2': grat2,
'3': CueL,
'4': CueR
}
# start trial
frameN = 0
press= False
while frameN <=250 and not press:
#for frameN in range(250):
if 5<=frameN<250:#present fixation point for all frames
fixpoint.draw()
if 50<=frameN<100: #present cue for a different subset
mouse.clickReset()
StimDict['4'].draw()
button = mouse.getPressed()
if button != [0, 0, 0]:
press = True # finish trial
if 150<=frameN<200: #present target for a different subset
mouse.clickReset()
StimDict['1'].draw()
button,tresp = mouse.getPressed(getTime = True)
if button != [0, 0, 0]:
press = True
print(tresp) #only gets time from current frame!!!
win.flip()#flip the screen every frame
frameN+=1
win.close()
Thank you!!