psychopy.org | Reference | Downloads | Github

Mouse not saving correctly?

URL of experiment: Pavlovia
(not fully converted into JavaScript yet)

My experiment involves letter stimuli flashing onscreen with one letter every 150ms. Participants need to click the screen once per trial whenever they choose. They’re later asked which letter was onscreen when they clicked the screen.

I’m struggling to correctly save the letter that was genuinely onscreen when the participant clicked.

Here’s my mouse component:

All the ‘clickable stimuli’ are separate image components (named: P, X, D, etc) in the same routine as the mouse component.

When I have it set to save mouse state ‘on click’, I get this in the output file:

A list of all the clickable stimuli.

When I set the mouse component to save mouse state ‘final’, no name is saved, the mouse.clicked_name the column is missing.

I tried putting this code into the each frame tab:

if mouse.getPressed()[0]==1:
    clicked = mouse.clicked_name

And this in the end routine tab:

trials.addData('trialMouse', clicked)

This didn’t work, I still got a long list containing the names of all of the clickable stimuli.

I then tried just putting just this in the end routine tab:

trials.addData('trialMouse', mouse.clicked_name)

But that produced the same result.

I have a feeling that the clicked_name is saving, but it’s being overridden on each frame.

For clarity, these are all my current tabs on my code component:

How do I make this so that it saves only the stimuli onscreen when the participant makes a left mouse click?

Thank you!

I’ve made it so that the mouse component ends after a click has been made:

I did this so that the mouse can’t possibly record any extra stimuli names after the first click has happened.

Doing this now returns an empty list .

I’m now wondering if the stimuli duration is too short for the name to properly be saved? Each letter stimulus is onscreen for 150ms. Perhaps the mouse just doesn’t get a chance to save the name of the clicked stimulus?

However, this doesn’t explain why the experiment was outputting a list with all the possible clickable stimuli names before…

I’m really lost here, any help would be greatly valued - thank you! :slight_smile:

I think this is the same as a bug which was reported on GitHub:

I’ve fixed it in the Master branch on GitHub, so the fix will be in the next release. For the time being, is it possible to set “End Routine On Press” to a different value, or would that break your experiment?