psychopy.org | Reference | Downloads | Github

Adding a rest break

Hi,

I’m trying to add a rest break. It works fine on my local computer, but my experiment breaks on Pavlovia as I get to the rest break so I thought I’d check what I wrote. I put the code component in the rest break routine, set to run on each frame.

Python code:

if trials_2.thisTrialN == 150:
continueRoutine=True
else:
continueRoutine=False

JS code:

if (trials_2.thisTrialN == 150){
continueRoutine = true;
} else {
continueRoutine = false;
}

Any obvious JS error? Thanks!

I should say I used this previous thread for reference: "Take a break" works locally but not online

Two obvious errors.

  1. You have to refer to all loops as trials.
  2. continueRoutine = True is redundant since that’s the default.

Best wishes,

Wakefield

Thanks for taking a look. I’m sorry, I’m not totally sure I follow. Would the code look something like this:

Python:

if trials.thisTrialN != 150:
continueRoutine=False

JS:

if ((trials.thisTrialN !== 150)) {
continueRoutine = false;
}

That’s still not working, but possibly I misunderstood?

I should specify, I get a red box error message at the point where the rest break would appear, but it disappears too quickly to see what the error message is or I’d take a screengrab.

Check the console for errors

OK I did a wee bit more digging. First, I recorded the experiment and then rewatched which allowed me to pause and see the error - turns out it was because the images hadn’t uploaded properly to the html folder so I fixed this. Now the experiment works, but the rest break never shows. I added this code to my rest break:

console.log(trials.thisTrialN);

When I look at the console (in firefox, by going to Tools>Web developer>Console), it’s showing up as 0 each time, so somehow, the trials are not being counted which is why the rest break never runs. Any idea how to fix this?

Try trials.thisN

I’m not sure if it makes a difference.

Alternatively create your own iteration counter, e.g. loopNum = 0 the loopNum +=1 each loop

Unfortunately neither of these options didn’t work on Pavlovia although they did on Psychopy local - I tried adding an iteration (+1) at the beginning of each routine, as well as on each frame. I’m so puzzled why the trial number doesn’t seem to increment.

A few other people are also hitting a similiar issue e.g.