Repeat trial immediately if answer is incorrect

Hi,

I’m new to PsychoPy and don’t have any experience with Python either.
I’m trying to immediately repeat a trial if the answer was wrong. I read some other posts in the forum but I can’t figure out how to implement this although it’s probably very easy.

I have a training routine with the stimulus etc, and then a feedback routine where it displays the feedback for 1 s, within a trials loop (random).

In the training routine, I have the following code at “end routine”:

check if correct

corr = resp_1.corr
rt = resp_1.rt

thisExp.addData(‘rt’, rt)
thisExp.addData(‘corr’, corr)

in the feedback routine, I have the following code at “begin routine”:
if corr==0:
msg=“wrong”
else:
msg="+"

Now I would like to repeat the trial with the incorrectly answered stimulus until the participant answered correctly.

I would appreciate any help! Thanks a lot & happy new year :slight_smile:

Hi,

you could add an additional loop around the trial and feedback routine, inside the trial loop (e.g. “answer_loop”). Set the repetition of the loop to a high number (e.g. 99) and made it sequential. In the feedback routine add something like that into the code component:

if corr==0:
   msg=“wrong”
else:
   msg="+"
   answer_loop.finished = True

tandy

3 Likes

Hi tandy, thank you! That works.

The other issue is that now I’m saving the reaction time for each trial separately, but I need them to be added up, i.e. rt incorrect + rt incorrect + rt correct = total rt. Do you know a way to do that? Or do I need to do it manually when analyzing the data?

Zora

in the training routine I have the following code to save the rt:
corr = resp_1.corr
rt = resp_1.rt

thisExp.addData(‘rt’, rt)
thisExp.addData(‘corr’, corr)

What do you mean by that it’s saving the reaction time for each trial separately? How is it different from before?

tandy

if trial x is repeated because the answer was incorrect, it saves the rt of x1, x2, …, xn separately, whereas I need them to be summed up.

Actually, nevermind, I decided to do it in a different way. Thank you for your help!