branch attribute

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

Applies to

<block> <trial> <likert> <openended> <namingtrial>

Syntax

/ branch = (type.name.property, operator, value, next)

Parameters

type.name.property Specifies the property that is evaluated by the condition, where type is the type of element, name is the name of the element on which performance should be evaluated, and property is the performance measure (e.g., "trial.practicerun.meanlatency" or "block.testblock.numcorrect").
operator Specifies the operator for comparing the type.name.property and value parameters. The operator must be one of the following:

Operator Definition
EQ Equal to
GE Greater than or equal to
GT Greater than
LE Less than or equal to
LT Less than
NE Not equal to

value Specifies the value against which property is compared.
next Specifies which element to run next if the condition expressed in the first three arguments is true. The type of element specified here must be the same as the containing element. If a value of "0" is specified for the next element, then nothing is run if the condition is true. Specifying "0" is useful if you wish to define a condition in which a sequence of trials or blocks is stopped (the stop attribute provides the equivalent functionality).

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=(trial.mytrial.correctstreak, GE, 10, congrats)
/ next=(trial.mytrial.correctstreak, LT, 10, 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=(trial.mytrial.count, GE, 50, 0)
/ branch=(trial.mytrial.count, LT, 5, mytrial)
/ branch=(trial.mytrial.meanlatency, GT, 500, 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=(block.myblock.count, GE, 5, 0)
/ branch=(trial.testtrials.percentcorrect, LT, 60, myblock)
</block>


Send comments on this topic.
1999-2006 Millisecond Software, LLC. All rights reserved.