PsychoPy Recording Multiple Mouse Clicks

770 views Asked by At

I'm creating an experiment using the PsychoPy coder and am not sure how to implement multiple mouse clicks. In the experiment, there are multiple targets and distractors and during a response period, individuals are to select the targets. However, I currently have it where if you click on one of the targets, you get a correct message, otherwise you get an incorrect message. I also have a function that will wait for a mouse click to find the reaction time and will give the response after the mouse click. How do I add multiple mouse clicks for multiple targets?

def waitForMouse(mouse):
    mouse.clickReset()
    buttons = mouse.getPressed()
    while buttons[0] == False:   #wait for mouse click
    buttons, times = mouse.getPressed(getTime=True) #get reaction time when mouse clicked
    return times[0]

if clock.getTime() >= stimDuration:  #start of response period
    ResponsePrompt.draw()            #indicate to participant to select targets
    win.flip()
    rt = waitForMouse(myMouse)
    if myMouse.isPressedIn(target[0]) or myMouse.isPressedIn(target[1]):
        CorrectResp.draw()   #selected one of the correct targets
        win.flip()
        core.wait(2)         #allow them to read it 
    else:
        IncorrectResp.draw()  #answered incorrectly
        win.flip()
        core.wait(2) 
1

There are 1 answers

0
brittAnderson On

Presumably you have some way of knowing that the participant is "done." You could just do a while loop until exit condition was met. You would just cycle through your mouse function collecting data and appending it to some list that you will later save until the exit condition is met. The basic pseudo-code approach would be something like:

while 1:
   catchData = getMouseClickStuff()
   <append catchData to whatever list it should be stored to>
   if <endConditionMet>:
      break