Millisecond Forums

Variable Trial Number

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

By mrg4 - 11/6/2017

Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik
By Dave - 11/7/2017

mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.
By mrg4 - 11/8/2017

Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.
By AndrewPapale - 1/17/2023

mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>





By Dave - 1/17/2023

AndrewPapale - 1/17/2023
mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>






Feedback trials obviously go towards the trial count, so what you get is the expected resutl:


By Dave - 1/17/2023

Dave - 1/17/2023
AndrewPapale - 1/17/2023
mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>






Feedback trials obviously go towards the trial count, so what you get is the expected resutl:



To do this properly, i.e. 5 "experiment" trials, each followed by a feedback trial per block, you'll want to do something like this:

<values>
/ scrfunc = ""
/ blockcount = 0
/ trialcount = 0
</values>

<parameters>
/ ntrials = 0
</parameters>

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    list.triallist.poolsize = parameters.ntrials;
    values.trialcount = 0;
    values.blockCount = values.blockCount + 1;
]
/ stop = [
    values.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ trialduration = 100

/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ ontrialbegin = [
    values.trialcount += 1;
]
/ trialduration = 100
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>

<block instructions>
/ preinstructions = (intro)
</block>

<block endscreen>
/ preinstructions = (end)
</block>

<page intro>
^intro page
</page>

<page end>
^end page
</page>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode block.experiment.trialcount values.trialcount)
</data>
By AndrewPapale - 1/17/2023

Dave - 1/17/2023
Dave - 1/17/2023
AndrewPapale - 1/17/2023
mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>






Feedback trials obviously go towards the trial count, so what you get is the expected resutl:



To do this properly, i.e. 5 "experiment" trials, each followed by a feedback trial per block, you'll want to do something like this:

<values>
/ scrfunc = ""
/ blockcount = 0
/ trialcount = 0
</values>

<parameters>
/ ntrials = 0
</parameters>

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    list.triallist.poolsize = parameters.ntrials;
    values.trialcount = 0;
    values.blockCount = values.blockCount + 1;
]
/ stop = [
    values.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ trialduration = 100

/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ ontrialbegin = [
    values.trialcount += 1;
]
/ trialduration = 100
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>

<block instructions>
/ preinstructions = (intro)
</block>

<block endscreen>
/ preinstructions = (end)
</block>

<page intro>
^intro page
</page>

<page end>
^end page
</page>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode block.experiment.trialcount values.trialcount)
</data>

Thank you, this works wonderfully. 
By AndrewPapale - 10/4/2023

Andrew Papale - 1/17/2023
Dave - 1/17/2023
Dave - 1/17/2023
AndrewPapale - 1/17/2023
mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>






Feedback trials obviously go towards the trial count, so what you get is the expected resutl:



To do this properly, i.e. 5 "experiment" trials, each followed by a feedback trial per block, you'll want to do something like this:

<values>
/ scrfunc = ""
/ blockcount = 0
/ trialcount = 0
</values>

<parameters>
/ ntrials = 0
</parameters>

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    list.triallist.poolsize = parameters.ntrials;
    values.trialcount = 0;
    values.blockCount = values.blockCount + 1;
]
/ stop = [
    values.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ trialduration = 100

/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ ontrialbegin = [
    values.trialcount += 1;
]
/ trialduration = 100
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>

<block instructions>
/ preinstructions = (intro)
</block>

<block endscreen>
/ preinstructions = (end)
</block>

<page intro>
^intro page
</page>

<page end>
^end page
</page>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode block.experiment.trialcount values.trialcount)
</data>

Thank you, this works wonderfully. 

Can this same logic work to achieve variable block numbers?  I assumed it would but am having some trouble implementing.

Thanks,
- Andre
By Dave - 10/4/2023

Andrew Papale - 10/4/2023
Andrew Papale - 1/17/2023
Dave - 1/17/2023
Dave - 1/17/2023
AndrewPapale - 1/17/2023
mrg4 - 11/9/2017
Dave - Tuesday, November 7, 2017
mrg4 - Tuesday, November 7, 2017
Hi,
I am currently working on creating templates for some standard procedures which only vary in their stimulus material and a few parameters.
One of those parameters is the number of trials within a specific block.
Is there any chance of using values within a block's trial-attribute?
Here is a example of how I imagine the ideal sultion:

<block Test>
/trials = [1-values.NumTrials = noreplace(trialA, trialB)
/...
</block>

Is this possible somehow?
Thanks in advance!

Dominik

You can achieve this by performing trial selection via a <list> and setting the <list>'s /poolsize via <parameters>:

<parameters>
/ ntrials = 10
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]

/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials

</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]

</trial>

The above will run 10 trials (5 x a; 5 x b).

Change the ntrials parameter to 20, and you'll get 10 x a and 10 x b:

<parameters>
/ ntrials = 20
</parameters>

<block myblock>
/ stop = [
    block.myblock.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/ items = (trial.a, trial.b)
/ poolsize = parameters.ntrials
</list>


<trial a>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

<trial b>
/ validresponse = (0)
/ trialduration = 10
/ branch = [
    list.triallist.nextvalue;
]
</trial>

Hope this helps.

Thank you so much for your quick response! That's the solution I was looking for! :)
Best regards.

I am trying to implement this to randomize total trial numbers, but it is not working correctly.  e.g. in the code I specified, I wanted it to run 5 trials, and Inquisit is instead running exactly 3 trials of my task.  The only difference appears to be that I branch from my trial in trial list to a feedback screen, and then from that feedback screen to list.triallist.nextvalue.  Any help would be appreciated!

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    values.blockCount = values.blockCount + 1;
    values.trialCount = values.trialCount + parameters.ntrials;
    
]
/ stop = [
    block.experiment.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>






Feedback trials obviously go towards the trial count, so what you get is the expected resutl:



To do this properly, i.e. 5 "experiment" trials, each followed by a feedback trial per block, you'll want to do something like this:

<values>
/ scrfunc = ""
/ blockcount = 0
/ trialcount = 0
</values>

<parameters>
/ ntrials = 0
</parameters>

<block experiment>
/ onblockbegin = [
    values.scrfunc = noreplace("IEV","DEV","CEV","CEVR","IEV","DEV","IEV","DEV");
    parameters.ntrials = 5;
    list.triallist.poolsize = parameters.ntrials;
    values.trialcount = 0;
    values.blockCount = values.blockCount + 1;
]
/ stop = [
    values.trialcount >= parameters.ntrials
]
/ trials = [1=list.triallist]
</block>

<list triallist>
/items = (trial.experiment)
/ poolsize = parameters.ntrials
</list>

<trial experiment>
/ trialduration = 100

/ branch = [
    return trial.dispFeedback;
]
</trial>

<trial dispFeedback>
/ ontrialbegin = [
    values.trialcount += 1;
]
/ trialduration = 100
/ branch = [
    list.triallist.nextvalue
]
</trial>

<expt main1>
/ blocks = [
    1=instructions;
    2=experiment;
    3=experiment;
    4=endscreen;
]
</expt>

<block instructions>
/ preinstructions = (intro)
</block>

<block endscreen>
/ preinstructions = (end)
</block>

<page intro>
^intro page
</page>

<page end>
^end page
</page>

<data>
/ columns = (date time subject group blocknum blockcode trialnum trialcode block.experiment.trialcount values.trialcount)
</data>

Thank you, this works wonderfully. 

Can this same logic work to achieve variable block numbers?  I assumed it would but am having some trouble implementing.

Thanks,
- Andre

Sure, you can do something similar for blocks.