The onblockbegin attribute specifies commands to be run at the beginning of a block.
expression | One or more expressions, delimited by semi-colons. See help with expression syntax for more information. |
This parameter executes one or more specified expressions at the beginning of a block. The expressions can read and conditionally update the various properties in the script. This is useful for dynamically configuring the block and its trials based on the state of the script or the subject's performance.
The following block lengthens the timeout based on the subject's mean response time on the last block:
<block myblock>
/ trials=[1-5=practicetrial; 6-10=testtrial)]
/ onblockbegin=[if (values.lastblockreponsetimes > 1000) trial.testtrial.timeout = 950]
</block>
The following block sets the content of a text stimulus based on the percent of correct responses on previous blocks.
<block myblock>
/ trials=[1-10=noreplace(lefttrial, righttrial)]
/ onblockbegin=[if (block.practice.percentcorrect > 80) text.status.item.1 = "nice job!"]
</block>
The following block sets the volume of a sound stimulus to a randomly selected value.
<block myblock>
/ trials=[1-12=noreplace(testtrial, testtrial, distractortrial)]
/ onblockbegin=[sound.testsound.volume = rand(-10000, 0)"]
</block>
The following block updates a simple block counter before it runs.
<block myblock>
/ trials=[1,3,5,7,9 = littletrial; 2,4,6,8,10 = bigtrial)]
/ onblockbegin=[values.testblockcounter = values.testblockcounter + 1]
</block>