Forced Response for different Buttonboxes

Hi,
I want to create a forced response so that the participants first respond to one of the boxes and then click on the next-page-box to end the routine. I know that if I would have only one box to click on I could set my mouse component to start on “condition” (instead of time) and set this condition to button.boxRating(). I used this for another component and it worked perfectly, but now I have several boxes to choose and I don’t know how to implement this.

Here you can see an example:


Do you have an idea on how to solve this problem? Thank you in advance!

When the .py file is written, PsychoPy basically sticks whatever you put in the “condition” box after an if statement when deciding whether to gather the response or not. Because it does this verbatim, if you add and, or, not, etc. it will also interpret these so long as they are valid Python expressions.

So if you want to start the “next routine” listener only after all other inputs have been received, you could try something like:
button1.boxRating() and button2.boxRating() and button3.boxRating() and button4.boxRating()

replacing button1, button2, etc. with the names of your inputs.

Thank you for your answer! I tried the solution (see picture) but unfortunately received the following error code:
AttributeError: ‘Rect’ object has no attribute ‘boxRating’

Do you know something that might help?

image

Ah, I think I see what you’re doing now - so on the first mouse click you check whether it’s on a clickable object (Deutsch or KeinDeutsch) and then on the second you check whether it’s on nexxt_2? My mistake, I thought you had button elements with a property .boxRating() which was filled in upon the component being clicked!

When you add the first mouse click component, down at the bottom where it says “Clickable stimuli”, you need to add Deutsch and KeinDeutsch (your rectangles) and choose what attribute you want to store when clicked, e.g. name. This means that, when you click one, it will store the name of that component in an attribute of the mouse called clicked_name.

So when you are doing the condition for starting the second mouse component, you need to write something that will check that mouse.clicked_name has what you would expect if both buttons had been clicked. So possibly:

Deutsch.name in mouse.clicked_name and KeinDeutsch.name in mouse.clicked_name

Let me know if that throws another error!

Now, there is no error anymore, but it isn’t possible anymore to go on to the next routine (even not after clicking to one of the boxes (Deutsch or KeinDeutsch).

So that is what I have implemented in the first mouse (called: Maussprache)


And that is what I have implemented in the second mouse:

Can you see any mistakes?

I think we’ve found a bug here - when End Routine on press is set to never, the checks for the mouse component don’t appear in the .py code at all. I’ll set about fixing this for the next version, but in the meantime I’ll find a solution which will work without needing that option. Will get back to you some time tomorrow morning!

Alright, I realise what the problem is now! It isn’t that End Routine on press is never, it’s that Save mouse state is also final. This stops it sampling each frame as it doesn’t need to listen each frame to store the click or to end the routine, so it doesn’t. If you set Save mouse state to each frame or on click then it starts listening!

After this you then get a different error - that mouuse_2 isn’t listening, even though the code is there. This is because we overlooked stopping Maussprache, but this is easily remedied! Just copy and paste whatever condition you have for mouuse_2's Start into Maussprache's Stop, so that Maussprache stops listening and mouuse_2 can start.

Hope this helps!

1 Like

This helped a lot!! Thank you so much for your help! Now it works :slight_smile:

1 Like

Hello! I’ve encountered the same problem as Hanna and I tried to follow your resolution in this post but I failed. Participants click the choice and then automatically the routine ends. Could you help me check what might be the problem?

For my experiment, participants will see three choices and I want them to choose one before they can click the “exit” to proceed. They can change their choice before they click on “exit”.

And this is the property of my first mouse (“mouse”), which is designed to choose.

This is the second mouse “mouse_1”, used to end the routine.

Do you have an idea on how to solve this problem? Thank you in advance!