Wisconsin card sorting task changing the rule

Hi, everyone! I am a beginner of Psychopy and I am currently creating a Wisconsin Card Sorting Task. Basically the task comprises of four stimulus cards and two identical packs of 64 response cards. The participant’s task is to classify cards, which differ by three criteria: color, shape, or number of the designs on the face of the cards, with the experimenter changing the rule used after the participant makes 10 consecutive correct classifications. The experiment ends when participants correctly classify cards by 6 criteria in this order: color, number, shape, color, number, shape or when participants finish 128 cards.
I created three loops: color, number and shape. How can I set the program so that it switches to the next loop after 10 consecutive correct responses? My builder view looks like this:

I noticed that Rachele posed a similar topic in the forum called ‘Changing rule when criterion is met (Wisconsin card sorting task)’ and the problem has been solved already. I know that I need to modify the code that someone else used depending on my own situation but with my poor knowledge of coding I don’t know how. The following codes (in the trial routine) are provided by Rachele:
In the begin experiment tab
key_resp.corr = 0

In the end routine tab
if key_resp.corr:
n_consecutive = n_consecutive + 1
if n_consecutive == 10:
currentLoop.finished = True
n_consecutive = 0

currentLoop.addData(‘n_consecutive’, n_consecutive)

I added a new code in the end routine tab under the trial routine called ‘tenconsecutivecode’. Because I set a click response rather than a key response, I guess I need to modify ‘key_resp.corr’. I tried to delete the word ‘key’ but the error message showed that the name ‘resp’ and ‘consecutive’ were not defined. Can anyone help me explain this problem?

Thank you in advance!


To be honest, this is a tricky issue to provide you support in, because making these kinds of edits without having a grasp of what’s going on can cause many many unexpected problems. I would recommend to start with some basics. For instance, learn a bit more about how PsychoPy works. Also, I highly recommend a set of tutorials I wrote about debugging online experiments. This threads lists them all: Debugging online - Thomas's demos

Best, Thomas