| Reference | Downloads | Github

How to repeat incorrect trials only

What are you trying to achieve?:
I am running a two-alternative forced choice task where participants make judgements about a set of images. It begins with practice task, where participants need to get 100% correct to continue to the main task. I am looking to have incorrect items repeated in a random order.

What did you try to make it work?:
I created an outer loop (with the routine loop nested within it) that repeats the practice trials if less than 100% of items within the first round were incorrect, as per these instructions: Repeat trial if answers are incorrect

What specifically went wrong when you tried that?:
It worked well, but all the practice items are repeated when less than 100% accuracy is achieved, rather than just the previously incorrectly answered items.

I am new to Psychopy and have looked on loads of forums to work out a way around this but haven’t been able to make anything work.

Thanks in advance!!

I’m not entirely sure this will be possible in Builder with a random loop, but a possible route to investigate would be

  • controlling the selected rows field of the inner loop. In the first run through, all rows would be selected but afterwards, you would just select the subset of desired rows where the response was incorrect.

I’m just not sure that would really work, because if the loop is randomised, the row numbers might not correspond any more on a subsequent loop. So perhaps this would be an alternative:

  • In your conditions file, include a column number with a unique identifier per row (it could just be sequential numbers 1,2,3,…), let’s say that column is called row_id
  • At the beginning of the routine, on the very first trial (when the iteration number of both loops is zero), initialise a list like this:
if outer_loop_name.thisN == 0 and inner_loop_name.thisN == 0:
    wrong_list = []
  • On each incorrect trial, add the unique id to that list, like this:
if outer_loop_name.thisN == 0 and blah blah: # where blah blah is your check that the response was incorrect

Then also include some code like this in the "begin routine " tab for running in the second pass through the loop:

# one the second run through the loop, only run a trial if it was previously
# recorded as incorrect:
if outer_loop_name.thisN == 1:
    if row_id is not in wrong_list:
        continueRoutine = False

The above is just a sketch of what to do, and would need to be extended if there could be additional runs until the loop is completely perfectly.

Hi Michael,

That’s super helpful! Thanks so much. I am now able to get the incorrect items to be repeated.

However, after the incorrect items were repeated and answered correctly, a new set of practice questions commenced. This seems to be because the code I used to terminate the practice trials relies on a full set of items to be answered correctly.

I tried to play around with the code to change this, but it got a bit messy and did not work. Any advice for something simpler would be appreciated !!

I’ve added some screenshots incase it’s helpful.

In the “Begin routine” section, you could do something like this:

# don't run practice a third time:
if outer_loop_name.thisN == 2:
    outer_loop_name.finished = True
    inner_loop_name.finished = True
    continue_routine = False

You might also need to insert a check in the “end routine” tab so that code doesn’t run on the third rep, or work this capacity into that tab, in which case you would need to check if the outer loop was on the second iteration and the inner loop on its last iteration.

This worked. Thanks Michael!

I relied on this thread for my experiment. It works for the first round but after that, there are no iterations in the wrong_list and all the items that initially were answered incorrectly are repeated.
In our experiment, we want to repeat the incorrect trials only until everything is answered correctly.

I would really appreciate it if you could help me with this one!!