psychopy.org | Reference | Downloads | Github

Repeat a loop if too many errors were made

Dear Users,

I was doing the attached experiment in the Builder, and it’s working very well. The only thing that I still need to implement is that the block of the trials shall be repeated if the red message shows up after the block (e.g., if too many errors were made; run the script on your machine and you’ll quickly get what I mean). Can you help me here?

ConditionalLoop.psyexp (17.8 KB)

Maybe using a staircase type loop?

Hi,

Spontaneously, I would tend to do something like this:

pracRepeat

  • Decide on a maximum number of times you would want your participants to repeat the practice block; enter this number as nReps for pracRepeat
  • After each block, check if they’re already good enough; if yes, break out of the loop

Dummy example attached.

Jan

repeat_loop.psyexp (7.7 KB)

Thanks for that, it perfectly worked. I now still need to implement the exact same experiment in the builder (you can use your own repeat_loop.psyexp as a template for this), just with one difference: The loop needs to be repeated if it took the subject longer than 0.8 seconds to respond for at least two stimuli.
the code to insert in the checkAcc routine would be exactly the same as proposed by you

( if condition:
break)

but the problem here is the coding of the condition. How can I access each specific reaction time of each stimulus? Then I could do sth like:

counter = 0
copy that into the Begin Experiment section of the code component of the checkAcc Routin

for x in trials.data[‘key_resp_2.rt’]:
if x > 0.8:
counter = counter + 1
else:
pass

if counter >= 2:
break
copy that into the Begin Routine Section of the code component of the checkAcc routine

But this code doesn’t work. You have an idea?

Never mind I figured out a solution actually! Let me know what you think about it!

ConditionalTiming.psyexp (20.7 KB)

1 Like