Ending a staircase after a maximum number of trials

Hi! I am trying to interleave two simple staircases that each end once they have exceeded a set number of reversals; however, this requires I set nReps to 0 because the staircase only terminates when nReps AND nReversals are both exceeded.

The trouble is that I want to include a maximum number of trials upon which a staircase will terminate, regardless of if it has reached the target number of reversals or not - and if the other staircase has not reached its maximum trials or reversals, it will continue to run trials.

OS: MacOS
PsychoPy version: 2023.1.2

What did you try to make it work?: I have tried using break, continue, and continueRoutine = False in a number of ways and defined a variable to track the number of trials completed for each staircase; however, these have since either led to crashes or one of the two staircases ending incomplete.

Anything helps! Thank you so much.

I found that when testing it locally in my browser, setting “nReps” in the builder window for the staircase loop was equivalent to setting the maximum number of Trials (the documentation is misleading)
When testing it online (piloting with Pavlovia), “nReps” no longer had this effect. That is because of this inconsistency I found in the psychojs files (psychojs-24.2.1.js in my case)
Local version:

var StairHandler = class  extends TrialHandler{
    constructor({psychoJS, varName, startVal, minVal, maxVal, nTrials, nReversals, nUp, nDown, applyInitialRule, stepSizes, stepType, name, autoLog, fromMultiStair, extraArgs}={})
    {
        super({
            psychoJS,
            name,
            autoLog,
            method: TrialHandler.Method.SEQUENTIAL,
            trialList: Array(nTrials),
            nReps: 1
        });

Pavolvia version:

var StairHandler = class  extends TrialHandler{
    constructor({psychoJS, varName, startVal, minVal, maxVal, nTrials, maxTrials=200, nReversals, nUp, nDown, applyInitialRule, stepSizes, stepType, name, autoLog, fromMultiStair, extraArgs}={})
    {
        super({
            psychoJS,
            name,
            autoLog,
            method: TrialHandler.Method.SEQUENTIAL,
            trialList: Array(maxTrials),
            nReps: 1
        });

setting nReps in the builder window for the loop had the effect of setting nTrials, which limited the number of trials when running locally but not on Pavlovia.

To set the maximum number of trials in Pavlovia, I went into the code in my Exp.js file and added the maxTrials line to this section:

mixed_FV_PV_trials = new data.MultiStairHandler({stairType:MultiStairHandler.StaircaseType.simple, 
      psychoJS: psychoJS,
      name: 'mixed_FV_PV_trials',
      varName: 'intensity',
      nTrials: 4.0,
      **maxTrials: 4.0,**
      conditions: mixed_FV_PV_trialsConditions,
      method: TrialHandler.Method.RANDOM
    });

Alternatively, from the Builder when I click on the trials loop to configure it, in the box for entering nReps I entered 4.0, maxTrials: 4.0

1 Like