Millisecond Forums

Branch syntax

https://forums.millisecond.com/Topic16585.aspx

By nakayama - 6/24/2015

Hi, Mr Dave,
May I ask a question about Branch syntax? I grouped three trials into a block, and I made several of these blocks. I wonder if I can let inquisit to start
blocks depending on how participants performed on the previous block? it seems branch can only do this on trials level.
Like:
<trial 1>
</trial>
<trial 2>
</trial>
<trial 3>
</trial>
<block 1>
trials=[1;2;3]
</block>
<trial 4>
</trial>
<trial 5>
</trial>
<trial 6>
</trial>
<block 1>
trials=[4;5;6]
</block>
...
Best Wishes,
Nakayama

By Dave - 6/24/2015

Of course you can /branch at the <block> level. The respective /branch ought to reside at the <block> level, i.e.

<block a>
...
/ branch = [if (condition) block.b]
</block>
By nakayama - 6/25/2015

Thank you for your reply.
That is the past I can't get.
Participants make responses at "instruction1" trial, "practice1" and "practice2" just for stimulus presentation.
How can I choose the block I want to perform depending on whether participants make a correct response in "instruction1" trial?
<block 1>
/ trials = [1= practice1;2=practice2;3=instruction1]
/ postinstructions = (practiceend)
/ branch=[if (block.1.?) block.2]
</block>
Best Wishes,
Nakayama
By Dave - 6/25/2015

<block 1>
/ trials = [1= practice1;2=practice2;3=instruction1]
/ postinstructions = (practiceend)
/ branch=[if (trial.instruction1.correct) block.2]
</block>
By nakayama - 6/26/2015

It works! Thank you!
By nakayama - 6/26/2015

Hi, Dave,
I almost got the concept of branch syntax, but still not very skillful. Would you help me with this?
I am doing an adaptive method on temporal stimulus, since the variable is "timeout', I guess I can't do it on trial level. 
The rule is like this:
Once subject makes a wrong response in "question", the timeout of "target" goes up by 100ms, else goes down by 100ms.
The block keeps running until the "timeout" of target is equals to the "timeout" of standard.
I tried to write syntax like this, but it just stopped by one run.


<trial standard>
/ stimulustimes = [1=fixation;2000=target;]
/ recorddata = true
/ timeout = 2200
</trial>

<trial target>
/ stimulustimes = [1=fixation;2000=target;]
/ recorddata = true
/ timeout = values.timeout
</trial>

<values>
/timeout=3000
/block=10
</values>

<block 1>
/ onblockbegin = [if (values.block>10)values.timeout+=100 else values.timeout-=100 ]
/ trials = [1= standard;2=target;3=question]
/ branch = [if(trial.question.correct) values.block-=1 && block.1 else values.block+=1 && block.1]
/ onblockend = [values.block=1]
/postinstructions = (practiceend)
</block>

<expt>
/preinstructions = (instruction)
/postinstructions = (result)
/blocks = [1 = 1;]
</expt>   

Best Wishes,
nakayama
By Dave - 6/28/2015

Of course you can do it on the <trial>-level:

<trial question>
...
/ ontrialend = [if (trial.question.error) values.timeout += 100 else values.timeout -= 100]
...
</trial>

<block 1>
/ stop = [values.timeout == 2200]
...
</block>
By nakayama - 6/28/2015

[Post mistakenly edited, resulting in loss of contents. Apologies. -Dave]
By Dave - 6/29/2015

Apologies, I mistakenly edited your last post. Intended response is below:

You run <block 1> a single time via your <expt>:

<expt>
/preinstructions = (instruction)
/postinstructions = (result)
/blocks = [1 = 1;]
</expt>

Since there is no /branch or the like in the <block> or anywhere else

<block 1>
/ trials = [1= practice1;2=practice2;3=question]
/ stop = [values.timeout==2200]
/ postinstructions = (practiceend)
</block>

the script then terminates as expected. If you want to run <block 1> again, use /branch as discussed previously.
By nakayama - 6/29/2015

Thank you for your help ! Dave.
I am sorry I am little bit confused. So would you show me how to run block 1 again using branch? 
Best,
Nakayama

By Dave - 6/29/2015

<block 1>
...
/ branch=[if (condition) block.1]
</block>                               

where condition could be something like

<block 1>
...
/ branch=[if (values.timeout < 2200) block.1]
</block>                               

or nothing at all

<block 1>
...
/ branch=[block.1]
</block>                               

etc.
By nakayama - 6/29/2015

Thank you Dave, I got it!