up Inquisit Language Reference

branch attribute

The branch command enables a script to conditionally run sequences of blocks or trials based on the subject's performance.

Member of

<block> <expt> <likert> <openended> <sliderTrial> <survey> <surveyPage> <trial>

Syntax

/ branch = { script }

Parameters

Name Type Description
script script A logical expression that determines whether to branch.

Remarks

The branch attribute can be used to create task flow that dynamically adapts based on the subject's performance or the current state of the script. You may specify multiple branch commands, in which case each condition is evaluated in the specified order. The first condition that is true determines the next element. Care must be take to avoid defining branches that result in infinite loops.

Requires an explicit 'return' statement for all possible outcomes. For example, it's safest for nested conditional branching to use a generic 'return null' at the very end of the branching commands to ensure that all possible outcomes return a value.

Examples

The following trial repeats itself until a streak of 10 correct responses in a row. If 10 correct responses are given in a row, a trial called "congrats" is run. Note that 'this' stands in for 'trial.mytrial'.

<trial myTrial>
/ stimulusTimes=[0=myText]
/ validResponse=("a", "b")
/ correctResponse=("a")
/ branch={
  if (this.correctStreak >= 10){
   return trial.congrats;
  } else {
   return this;
  }
}
</trial>

The following trial repeats itself at least 5 times. The trial is then repeated as long as the mean latency for this type of trial is smaller than 500 milliseconds. When 50 trials are run, the trial no longer repeats. Note that 'this' represents 'trial.myTrial' in this context.

<trial myTrial>
/ stimulusTimes=[0=myText]
/ validResponse=("a", "b")
/ correctResponse=("a")
/ branch={
  if (this.count < 5){
   return this;
  } else if (this.meanLatency > 500 || this.count >= 50){
   return null;
  } else {
   return this;
  }
}
</trial>

The following block runs a randomly selected order of "testtrials" and "distractortrials". It repeats until the subject responds with 60% accuracy or better on the "testtrials" only. The block repeats a maximum of 5 times before moving on to the next block. Note that 'this' represents 'block.myBlock' in this context.

<block myBlock>
/ trials=[1-20=noreplace(testtrials, distractortrials)]
/ branch={
  if (this.count > 5){
   return null;
  } else if (trial.testtrials.percentCorrect < 60){
    return this;
  } else {
   return null;
  }
}
</block>

The following trial demonstrates a complex conditional statement that determines whether "testtrial" should be run. Note that 'this' represents 'trial.myTrial' in this context.

<trial myTrial>
/ stimulusTimes=[0=myText]
/ validResponse=("a", "b")
/ correctResponse=("a")
/ branch={
  if (this.count * sqrt(text.myText.currentItemNumber) * abs(values.balance) == 4.55167){
   return trial.testtrial;
  } else {
   return null;
  }
}
</trial>

Copyright Millisecond Software, LLC. All rights reserved.