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> <likert> <openended> <survey> <surveypage> <trial>

Syntax

/ branch = [if expression then event]

Parameters

expression A logical expression that determines whether to branch.
event The full name of the event (i.e., trial, block, etc.) to run if the expression is true. If nothing should be run, specify "notrial", "noblock", or "noexpt" for trials, blocks, and expts respectively.

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>
/ stimulusframes=[1=sometext]
/ 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>
/ stimulusframes=[1=sometext]
/ validresponse=("a", "b")
/ correctresponse=("a")
/ branch=[if (trial.mytrial.count >= 50) notrial]
/ 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>
/ stimulusframes=[1=sometext]
/ validresponse=("a", "b")
/ correctresponse=("a")
/ branch=[if (trial.mytrial.count * sqrt(text.sometext.currentitemnumber) * abs(values.balance) == 4.55167) trial.testtrial]
</trial>

Send comments on this topic:
Copyright Millisecond Software, LLC. All rights reserved.