Mouse clicks sometimes do not respond

URL of experiment:

Description of the problem:
I made an online experiment which is working memory task similar to the Corsi Blocks. In this version I do not used color blocks but images of animals. It is a grid of 9 covered shapes in which photos of animals appear on the screen. When participants need to give their response about which animals were presented, where and in which order, participants need to click on one of nine different shapes create din Psychopy builder. When they click on any of these shapes, a dialogue box appears in which they need to type the name of the animal and its order of presentation.

Everything works well, however, the reaction of the mouse is sometimes very slow. Sometimes I need to click several times on the figures to make one of these boxes show on screen. Furthermore, sometimes the screen freezes a bit while typing in the dialogue boxes.

I think this is because a lot of resources are being consumed every frame for keeping track of the mouse and its interaction with all the different figures on screen.

Is there a way to fix this?

Best,
Miguel

Hi Miguel,

How about having one static routine which gives the display and waits for a mouse click and then a second which moves the display based on the position of the mouse? Then loop back to the first. It sounds like the issue is that the routine is trying to do too much every frame.

Another option is to only do stuff every n frames.

Best wishes,

Wakefield

@wakecarter,

Thank very much for the suggestion. I did not know there was an option to have static routines in Psychopy. I made the experiment in the builder and then adjusted the code into a JavaScript version. I have very little experience with PsychoPY and PsychoJS. How can make a routine be static instead of dynamic? I guess I’ll need some extra command that refreshes the content of the widow when a mouse click is received instead of having it refreshed every frame.

Best,

Miguel

Hi,

I’ve not tested this, but I downloaded your experiment file to work through what I mean.

My suggestion is to remove the code components from wmTest and have both the keyboard and mouse components end the routine.

The Begin Experiment and Begin Routine code is in wmTest_setup
The Each Frame code is in Begin Routine code of wmTest_code and has trials.finished=1 instead of continueRoutine=False

In principle I think this should work. The display should be static until the mouse is clicked. It’s possible that mouse testing in the code should then be based on contains rather than clicked.

The End Routine code is in wmTest_save

Best wishes,

Wakefield

working memory task static.psyexp (213.0 KB)

1 Like

@wakecarter

Thank you for the suggestion. It is a very interesting idea approach. I worked on it during the whole day to implement it in Python and JavaScript. The clicks of the mouse are right now more responsible, although from time to time the display still freezes a bit. Checking the activity of the RAM memory of my computer, I can still notice that running the experiment online consumes a lot of resources. I guess there is no easy way to solve this issue but to ask participants to close their browser and open it again with only using a single tab of the test before taking it.

I had some trouble with the repository in GitLab so I had to deleted and create a new one. This is the link of the new repository of the updated task:

Leaven the consumption of memory resources aside, I still have one problem that I hope you can help me with. When people click on a figure, the borders of that figure are supposed to thicken to let people know that they have clicked on them. After they typed some information in the dialogue box that appears, the rectangular shape beneath the squared figures is supposed to change color. I have made a mess with conditionals trying to control when the borders and fill of the figures change of color. It is not working very well. My intuition was that after every loop the display should update to show the changes on the figures, but it seems this is not the case.

Is there a command in PsychoPY and and PsychoJS to force the display to update with the new changes in the figures whenever it is called?

Thank you in advance!

Try using polygon.setFillColor(a) and polygon.setLineColor(b) where polygon is the name of the figure and a and b are variables for colours defined earlier in both Python and Javascript. You should also be able to use polygon.setLineWidth(x).

1 Like

@wakecarter

Thank you very much for your help!! The commands for changing the fill color and line width of polygons that you gave me worked very well. I will copy them in a code snippet below for clarity in case some one is interested in it. The experiment is working much better now. You were a great great help. I appreciate it a lot.


Code for both Python and JavaScript to modify the color of shape components, the color of their border line and its width. You need to define first the variables to be used as color. To know how to do that please consult this great code sheet made by @wakecarter: https://docs.google.com/document/d/13jp0QAqQeFlYSjeZS0fDInvgaDzBXjGQNe4VNKbbNHQ/edit?pli=1#


myPolygon.setFillColor(black)
myPolygon.setLineColor(white)
myPolygon.setLineWidth(4)

Best!!