OS : Win10
PsychoPy version : 2021.1.4
Standard Standalone? : Yes
Hi all! I am quite new at Psychology and programming in Psychology. I am trying to run an experiment with a touchscreen and Michael’s code has solved the problem about double-click/swipe.
Writing contains(mouse) to output
In my experiment, the participants have to select one of the five choices (I used polygons here) after they saw a picture(video). There are 160 pictures(videos) and I would like to let them rest after they saw 20 pictures(videos). Since there are no right answers, all I want to know is which button the participant selects and their response time on pressing the button. However, I have no idea what I should do to collect response time.
I tried the code but “clicked_resp_time” seems quite weird (because it is much longer than the time clicked by a mouse)…
The following is my code component:
trialscounter = 1 import psychopy.event mouse = psychopy.event.Mouse(win=win) from pyschopy import iohub from psychopy import clock, core
rest = False mouseclick = False timer = core.CountdownTimer(1000) stimuli = [pressframeshita, turnframeshita, pullframeshita, slideframeshita, naiframeshita] mouse = mouse mouse.setPos(newPos=(0,0)) mouserec=mouse.getPos()
if trialscounter % 20 == 0: if mouse.isPressedIn(pressframeshita) or mouse.isPressedIn(turnframeshita) or mouse.isPressedIn(pullframeshita) or mouse.isPressedIn(slideframeshita) or mouse.isPressedIn(naiframeshita) rest = True mouseclick = True timer = core.CountdownTimer(1) else: if mouse.isPressedIn(pressframeshita) or mouse.isPressedIn(turnframeshita) or mouse.isPressedIn(pullframeshita) or mouse.isPressedIn(slideframeshita) or mouse.isPressedIn(naiframeshita) continueRoutine = False if mouseclick == True: if timer.getTime()<0: if mouse.isPressedIn(image_3): #have a rest per 20 trials continueRoutine = False mouseloc = mouse.getPos() for stimulus in stimuli: if stimulus.contains(mouse): mouserec = mouseloc mousetime = core.getTime() thisExp.addData('clicked_stimulus', stimulus.name) thisExp.addData('clicked_stimulus', mousetime) continueRoutine = False
trialscounter = trialscounter + 1
I will greatly appreciate that if anyone can tell me the solution in more detail. Thank you!