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 }

or

/ 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.

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.

<trial myTrial>
/ stimulusTimes=[0=myText]
/ validResponse=("a", "b")
/ correctResponse=("a")
/ branch=[if (trial.myTrial.correctStreak >= 10) trial.congrats]
/ branch=[if (trial.myTrial.correctStreak < 10) trial.myTrial]
</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 greater than 500 milliseconds. When 50 trials are run, the trial no longer repeats.

<trial myTrial>
/ stimulusTimes=[0=myText]
/ validResponse=("a", "b")
/ correctResponse=("a")
/ branch=[if (trial.myTrial.count >= 50) return null;]
/ branch=[if (trial.myTrial.count < 5) trial.myTrial]
/ branch=[if (trial.myTrial.meanLatency > 500) trial.myTrial]
</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.

<block myBlock>
/ trials=[1-20=noreplace(testtrials, distractortrials)]
/ branch=[if (block.myBlock.count > 5) 0]
/ branch=[if (trial.testtrials.percentCorrect < 60) block.myBlock)
</block>

The following trial demonstrates a complex conditional statement that determines whether "testtrial" should be run.

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

Copyright Millisecond Software, LLC. All rights reserved.