The onblockend attribute specifies commands to be run at the end 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 after a block of trials is complete. The expressions can read and conditionally update the various properties in the script. This is useful for dynamically configuring the experiment based on, for example, the subject's performance on that block.
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)]
/ onblockend=[if (block.myblock.meanlatency > 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)]
/ onblockend=[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)]
/ onblockend=[sound.testsound.volume = rand(-10000, 0)"]
</block>
The following block tracks the subject's best block score using a custom value.
<block myblock>
/ trials=[1,3,5,7,9 = littletrial; 2,4,6,8,10 = bigtrial)]
/ onblockend=[values.bestperformance = max(values.bestperformance, block.myblock.percentcorrect)]
</block>