Building in Breaks After N Trials

Description of the problem: Trying to build breaks into my loop after a specific trial number. I have been following the recommendations per: ["Take a break" works locally but not online] but have not had success. The condition does not seem to be acknowledged and the trials continue without a break.

Below is a permutation of the code I have also tried:

I am a bit dumbfounded particularly because the code in the above image reportedly works for a colleague on their Mac, but not on my PC (not sure if that matters?).

Thanks for any help!

Hi there,

I see what you mean, as was able to replicate this. I want to look a bit more into this, but for now a solution is to instead create a trial count variable as well as a list of trials where you want the breaks. So,

In your “Begin Experiment” tab:

trialCount=0
breakTrials = [3, 6, 9]

then at in the “Begin Routine” tab of your trial
trialCount = trialCount+1

then in your “Each Frame” tab:

if trialCount not in breakTrials:
    continueRoutine = False

To assist I made a demo called “simpleTrialBreaks”, you can download this from the repository here https://gitlab.pavlovia.org/lpxrh6/simpletrialbreaks and take a look at the code components to copy them over to your task.

Hope this helps,
Becca

Hi Becca,

Thank you for the suggested code and demo. This works fine locally but when I export to pavlovia the same problem I have been having continues. I read in the linked post above that the “not in” operator does not translate well to javascript. I have been fiddling with other permutations of your suggested code without success. If you have other suggestions I would be very grateful to hear them.

Thank you!
Brandon

Hi there,

That is curious, it seemed ok on pavlovia for me - did this simple demo work if you pushed it to pavlovia and ran it as it was? or was it when you implemented the method in your main experiment that it seemed to fail? If the latter could you possibly share your experiment URL so we could take a look?

Some things to try if you suspect the ‘not in’ operator is the issue, use the include function on the JS side or something you may have already tried

if trialCount in breakTrials:
    continueRoutine = True
else:
    continueRoutine = False

Let me know how you get on,
Becca

Hi Becca,

I think I have it working now. My problem seems to stem from the fact that I had practice loops built into the experiment before my experimental loops began. Both loops were using the same trial routine; I wonder if this was somehow affecting the loop count that was being used to track when to trigger the break broke…? I went back and created separate routines for the practice loops, and used your original suggestion using the trial count and list of trials for my experimental routines/loops. It is not working as intended.

Here is a link to the pilot experimental URL if that is useful to you: https://run.pavlovia.org/bmmerritt/gdi2/html/?__pilotToken=98f13708210194c475687be6106a3b84&__oauthToken=0229de606d4d911350c579ae341db512af3a65844389182b4d09c4bcc2c944dc

Thank you again for your help!
Brandon

This suggestion works!