Psychophysics task: trouble recording accuracy of hits

I’m working on a psychophysics task which requires participants to click on a moving ball as it passes behind an occluder (each trial ends when the ball is either clicked or reaches the other side of the screen). Even if participants miss, their accuracy is calculated by measuring the distance between their mouse click and the location of the ball at that time.

However, the accuracy values are not always appearing in the data output and my colleague and I think the problem lies in the following piece of code:

if mouse.getPressed()[0]:
        if firstClick ==10000:

When working on the task, we set textvalue3 to our accuracy calculation so that we could compare the accuracies recorded during trials with the accuracies we later observed in our data output. firstClick has been set to 10000 for now.

Any help would be greatly appreciated.

Where is the code to save the data?

thisExp.addData(‘variable ‘,value)

So, the piece of code I’ve shared is in ‘Each Frame’ and the pieces of code to save data are in ‘End Routine’. Here they are:

thisExp.addData('accuracy', accuracy)
thisExp.addData('nearAccuracy', nearAccuracy)
thisExp.addData('hitAccuracy', hitAccuracy)
thisExp.addData('firstClickAccuracy', firstClick)

This is presumably only a small part of your Each Frame code, since it has a missing bracket and only mentions one of the four variables.

Yes, although I didn’t notice a missing bracket; Python is not showing a syntax error for that line of code.

By this do you mean it auto translates to JS without an error or Builder doesn’t complain about this code when running because it claims the error is elsewhere?

The former.

I’m not sure you can use mouse.x online. I use

mouseloc = mouse.getPos()

which sets mouseloc to be a list

Thanks for the suggestion but we’re not planning to run this experiment online (for the time being).