Relating mouse response to correct answer

Hi!

I have a problem regarding the evaluation whether a response is correct or not. I read several posts in the forum, but my code seem not to work.

In my task a white 4x4 grid (16 rectangles defined as R1-R16) is presented. In a trial of the task a specific sequence of rectangles, e.g. R4, R15, R7 change their color (from white to black). The aim of the task is to remember the order the black rectangles were presented and to click (mouse) on the correct rectangles.

My problem is now that I want to check for each rectangle, whether the clicked rectangles were clicked correctly and in the right order.

Mouse component: never end routine, save mouse state on click, clickable stimuli: recallR1, recallR2, … recallR16, store params: name

In the excel file corrAns = e.g. recallR4, recallR15, recallR7

I tried several solution in the code component (each frame) with multiple variations (mouse.isPressedIn, mouse.clicked_name etc.). Here is a code example:

if mouse.isPressedIn(recallR1) and corrAns == 'recallR1':

```thisExp.addData('corrR1', 1)```

else:

```thisExp.addData('corrR1', 0)```

if mouse.isPressedIn(recallR2) and corrAns == 'recallR2':

```thisExp.addData('corrR2', 1)```

else:

```thisExp.addData('corrR2', 0)```

Can anybody help me to solve my problem?

It sounds like you are making something similar to a corsi block task is that correct? If so, please can I highlight this demo available on pavlovia to check your code against https://gitlab.pavlovia.org/demos/corsi

Secondly, please can you share the error message that you are getting or what is not going as you expect from your code.

Thanks,
Becca

Hi Becca

Thank you very much for the helpful link. Great to see how a “real” code looks like.
Yes, I have a kind of corsi task.
In my output file I see the following:

corrAns corrR1 corrR2 corrR3 corrR4 sumcorrect mouse.clicked_name
recallR1
recallR2
0 0 0 0 4 [‘recallR1’, ‘recallR2’]
recallR2
recallR4
0 0 0 0 5 [‘recallR2’, ‘recallR4’]

The table above shows the output from two test trials (2 blocks appeared in trial 1 and 2 blocks in trial 2). The problem is that even though I clicked on the right blocks (corrAns and mouse.clicked_name are the same) PsychoPy says that my answers were incorrect (null in corr1:corr4).
I tried to generate a sum score but also this score is incorrect (4 points in trial 1 and 5 in trial 2).

Here the code I used:

Begin experiment:
sumcorrAns = 0

Each frame:
if mouse.isPressedIn(recallR1) and corrAns == 'recallR1':
thisExp.addData('corrR1', 1)
sumcorrAns = sumcorrAns + 1
else:
thisExp.addData('corrR1', 0)

if mouse.isPressedIn(recallR2) and corrAns == 'recallR2':
thisExp.addData('corrR2', 1)
sumcorrAns = sumcorrAns + 1
else:
thisExp.addData('corrR2', 0)

if mouse.isPressedIn(recallR3) and corrAns == 'recallR3':
thisExp.addData('corrR3', 1)
sumcorrAns = sumcorrAns + 1
else:
thisExp.addData('corrR3', 0)

if mouse.isPressedIn(recallR4) and corrAns == 'recallR4':
thisExp.addData('corrR4', 1)
sumcorrAns = sumcorrAns + 1
else:
thisExp.addData('corrR4', 0)

Thank you very much!