Response Accuracy Required Before Progression

Hey,

New to PsychoPy so hoping I can get a hand with this.

I’m setting up an experiment where participants need to reach a certain level of performance (let’s say, 4/5 correct responses) before they are allowed to proceed to the next routine. If this threshold is not met then it needs to loop them back to the start of that routine.

Any suggestions appreciated!

Cheers
CK

First, define your correct answer attribute in your response component and set a high number for nReps in your loop.

Then, insert a code component. In the first tab (Begin Experiment), insert:

nCorrect = 0

In the fourth tab (end routine), insert the following and substitute myTrialLoop with the name you gave your loop and key_resp with the name you gave your response component.

if key_resp.corr: # if the response was correct, increment your iterator
    nCorrect += 1

if (myTrialLoop.thisN+1)%5 and nCorrect >= 4/5: # if the subject just finished a set of 5 trials and got 4/5 or more correct, finish the loop
    myTrialLoop.finished = True
else:
    nCorrect = 0

To make more sense of the lines of code and to adapt them to your needs, compile your script and try to understand where the code is inserted and what variables it uses.

Does that help?

2 Likes

Hi Lukas,

Yes! This helps immensely! Exactly what I was looking for!

Thank you!

Great :smiley:
You could then tick the ‘solved’ option underneath my post. :+1:

1 Like

Hi Lukas!

Sorry to bring up and old post but I’m struggling with psychopy. I hope you will be able to help me!

In my experiment, participants have to reach a minimum of 75% correct responses in a recall task. To be more specific, participants are first presented with several word pairs in a memory task. In the recall task they are presented with the first word of the word pairs and then need to type in the second word pair. Since I’m using the textBox component that allows participants to type in their responses, where could I define my correct response attribute?

Sorry if it’s a stupid question, thank you in advance,

Lola

Hi,

How can we store keys and responses when we press several keys as a response to a stimulus for example in digit span task in builder and coding in Psychopy?