Skipping a routine

I have an experiment right now which I want the routine to be skipped if the participant does not score at least 8 out of 12 right in the practice. However, it still proceeds onto the next routine.

the current flow is as such:

  1. Instructions
  2. Practice
  3. Instructions
  4. Test
  5. End

Focusing on the instructions and test, I have given my nReps a variable name (i.e., test_game) and have the current code in the Begin Routine tab in the preceding routine (ShoworSkip). The following code is such:


if practiceLoop.thisTrialN == 11:
   if score <=5: 
      test_game = 0 
else:
test_game = 1

Do i need to add anything else to ensure that participants who are not eligible for the test routine will not be shown the test routine at all?

  • Right now, the ShowOrSkip will only happen after all of the practice trials are done, so I don’t think you need the if statement with practiceLoop.thisTrialN == 11.
  • As long as you set your test_game variable as the number of reps for the testgameLoop, I think it will do what you want.
  • However, make sure you aren’t defining important variables within testgameLoop to be used later in the experiment, as skipping the loop will mean that those variables are left undefined.

On the other hand, you may want participants to repeat the practice until they get a high enough score. If so, you’ll need to change the setup substantially. You need ShowOrSkip to occur within your practice loop, and you would need the conditional for practiceLoop.thisTrialN. You would also need to make sure that there is a way to break out of the practice loop or repeat it depending on your conditions.

Hope that helps…

Thanks for the reply!

Okay maybe to make things a bit clearer. I have a repeated practice in place within the practiceLoop. There are a total of 24 trials split into 2 x 12 trials.

in the first 12 trials, if they score at least an 8, they will move onto the test routine, else, they will move onto repeat the practice - 2nd round of 12 trials.
Likewise, If in the 2nd round of 12 trials, they score at least 8, they will move onto the test routine else they will skip the test routine and the condition and counterbalance loop will end and proceed onto the next game. Which is why i have the showorskip in place because i intentionally want them to skip the test routine if they are still not able to achieve a high enough score on the repeated practice.

So, based on what your goal is, I would recommend this organization (or something like it):

• Note that the ! is a negation. So !do_game would mean the participant had less than 8 trials correct, and cannot proceed to the game.
• To increase the number of chances participants have to do the practice, just change the number of repetitions in the outer loop.

[sorry for the many edits]

That seems great but I’m wondering if its possible to work ontop of the current flow and goal i have. Based on my flow diagram above, I have a few codes that are already in place and it seems to be working except for the goal in which i want the test routine to be skipped if they do not achieve at least 8 out of 12 in the repeated practice trial.

  • Note: all of the code are in the Begin Routine tab except for the trial routine

In the practiceLoop trial routine Begin Routine Tab:

if practiceLoop.thisTrialN == 0:
   score = 0

In the practiceLoop trial routine End Routine Tab:

if resp.corr:
    score = score + 1

if practiceLoop.thisTrialN == 11:
    if score >= 8:
        continueRoutine = False
        practiceLoop.Finished = True 
    else:
        score = 0 #reset to 0 after 12th trial
if practiceLoop.thisTrialN == 23:
    if score >= 8:
        continueRoutine = False
        practiceLoop.Finished = True

In the Instr2 Begin Routine Tab:

if practiceLoop.thisTrialN == 11:
    if score<=5:
        continueRoutine = True
    else:
        continueRoutine = False
        practiceLoop.Finished = True
elif practiceLoop.thisTrialN == 23:
    if score <=5:
        continueRoutine = False
        practiceLoop.Finished = True

else:
    continueRoutine = False

Hence, that is why my initial thought is to create a ShoworSkip routine to check if they fulfill these conditional statements and proceed onto the test routine.

Ah, this is very helpful, I understand a little better what you are doing now. :slight_smile:
A couple more questions:

  • It seems like you currently have mostly the same code in the trial and Instr2 routines. Why not just have it in Instr2, at the end of the loop?
  • Why are you looking for score <=5 in Instr2?
1 Like

Hmmm, perhaps it would help if i explain a little more.

There are a total of 24 trials in the practiceLoop. These 24 trials are split into 2 rounds of 12 trials. In the first 12 trials, all participants will have to do it. If on the 12th round, the participant scores at least 8, Instr2 will not continue and will just move onto the test routine. If the score <=5, Instr2 will show and then they will proceed onto the 2nd round of 12 trials. That is why I am looking for score <=5 in Instr2.

  • It seems like you currently have mostly the same code in the trial and Instr2 routines. Why not just have it in Instr2, at the end of the loop?

I’m not sure if the same code in Instr2 will then allow my practiceLoop.thisTrialN == 11 and score >=8 condition be fulfilled.

So, if I can summarize what I understand:

  • You want the instruction routine to appear only on trial 12, only if the participant scores less than 5
  • You want the practice loop to break after 12 trials if they got at least 8 of those 12 correct

If that’s the case:
Right now, since you have practiceLoop.Finished = True in Inst2, it will end the whole loop if they get only 5 trials correct. I would suggest taking this line out.
Further, I would suggest moving all the code except for the score incrementer together to the beginning of inst2.
It might also help to consolidate the topics you’ve opened so we can all talk about this on the same thread.

Yes, that is absolutely correct!

Right now, since you have practiceLoop.Finished = True in Inst2, it will end the whole loop if they get only 5 trials correct. I would suggest taking this line out.

With regards to this, the loop ends while that code is in place (i.e., if score <=5) especially when triaN == 11. However that is not the case when trialN ==23 and score <=5.

Sure, if that’s okay with you here are some of the issues still:

  1. With all of the code in place, Inst2 routine still shows at the end despite participants not answering all of the 24 trials correctly.
  2. I am still unable to skip the test routine if participants do not score at least 8 out of 12 correct in the repeated practice trial. It still proceeds onto the test routine which I want it to be skipped

This is my suggestion (or something similar-- I’m sure there’s a more concise way to write this):

  • Be careful about the order of things here… I think setting continueRoutine to False will immediately quit the routine and later code would not be run.

In the practiceLoop trial routine Begin Routine Tab :

if practiceLoop.thisTrialN == 0:
   score = 0

show_instr2 = False
do_game = False

In the Instr2 Begin Routine Tab :

if practiceLoop.thisTrialN == 11 and score <= 5:
    show_instr2 = True

if practiceLoop.thisTrialN == 11 or practiceLoop.thisTrialN == 23:
    if score >= 8:
        do_game = True
        practiceLoop.Finished = True
    else:
        score = 0 #reset to 0 after 12th trial

continueRoutine = show_instr2

Now, you can use do_game as the on/off switch for your next loop

The only code left in practiceLoop trial routine End Routine Tab would be :

if resp.corr:
    score = score + 1

Hi!

I’ll try it out now!! Is do_game is the variable name assigned to $nReps in my testLoop?
For show_Instr2, it’s just a command or do i have to define any variable?

Also, just one more question.

if practiceLoop.thisTrialN == 11 or practiceLoop.thisTrialN == 23:
    if score >= 8:

I have just tried this out and show_Instr2 does not show, and even if they scored at least 8 out of 12 correct, practiceLoop continues

do_game and show_instr2 are both variables that can be either true or false. See my diagram above for the game on/off loop. I don’t have time to troubleshoot further right now, sorry.

Okay thanks

I’ve discovered that my understanding was wrong about this. continueRoutine is checked at the end of the frame rather than being acted upon immediately.

1 Like

Hi asia! Thanks for all your help :slight_smile: the experiment is working smoothly as per your suggestion. I’m still using continueRoutine = False in the Begin Routine tab for Instr2 as I realised that’s the only way that the image shows when I want it to.

Hmm, continueRoutine works well for me in the Begin Routine tab still. Thanks for your help!

Perhaps it is more technically checked at the start of the frame, which is why that works.