I need to make participants touch a big sensor screen when they hear a sound. I tried the code on the fig. 1 so that participant touch the screen once only. But for some reason the time and the coordinates of the touch do not appear in the data file. What should I do to make the data store correctly?
Hello,
What I would do is create a list that stores the position and time for each time the participant presses the screen (each click would be a dictionary that stores the timestamp and position).
So you already check whenever the participant presses the screen, so it should be easy to implement.
# Begin Routine
clickHistory = []
# Each Frame
if condition:
clickHistory.append({"timeStamp": core.getTime(), "position": mouserec})
# End Routine
thisExp.addData('clickHistory', clickHistory)
if you only want to store 1 position and timestamp for each routine, I’ll do the following:
# Begin Routine
clickPosition = (0, 0)
clickTimestamp = 0
# Each Frame
if condition:
clickPosition = mouserec
clickTimestamp = core.getTime()
# End Routine
thisExp.addData('clickPosition', clickPosition)
thisExp.addData('clickTimestamp', clickTimestamp)
the output is “name ‘condition’ is not defined” maybe something else is needed to be added.
the condition
is a placeholder. You can to write the condition of whenever you want to save the current position and timestamp.
For example:
# Each Frame
mouseloc = mouse.getPos()
if mouseloc[0]==mouserec[0] and mouseloc[1]==mouserec[1]:
pass
elif rec.contains(mouse):
clickHistory.append({"timeStamp": core.getTime(), "position": mouserec})
if t>minRT:
continueRoutine=False
else:
mouserec=mouse.getPos()