Thank you so much for the quick response! I understand the logic of the code you provided, but Inquisit is throwing an error:
ERROR /ontrialbegin: ' i' Expression contains an unknown element or property name.
The error is within <trial pumpinput>, which is what controls the stimulus presentation, however the number of trials is handled through a few other blocks of code. Again, this is downloaded from Inquisit with minimal edits from me.
Here is the exact code I have that controls the entire experiment:
<trial init>
/ ontrialbegin = [
values.pumpcount = 0;
values.wantedpumps = 0;
values.explosionpoint = 0;
list.pumpresult.reset();
values.explosion = 0;
values.scalingFactor = 1;
]
/ stimulustimes = [0=clearScreen]
/ response = noresponse
/ ontrialend = [
if (trial.init.trialcount <= parameters.totalballoons) {
values.ballooncount += 1;
if (values.ballooncount < 11) {
values.ballooncount_10 += 1;
} else if (values.ballooncount <21) {
values.ballooncount_20 += 1;
} else if (values.ballooncount <31) {
values.ballooncount_30 += 1;
}
}
shape.blank.width = values.balloonwidth;
shape.blank.height = values.balloonheight;
]
/ branch = [return trial.pumpinput;]
/ recorddata = false
</trial>
Notes:
* provides the textbox to collect number of pumps that participant would like to pump the balloon
* determines the explosionpoint if parameters.fixed_explosionsequence == true
* updates summary variables
* calls trial.pump if that number > 0 otherwise calls trial.collect
<trial pumpinput>
/ stimulusframes = [1=balloon, totalearnings, pumpcount, potentialearnings, ballooncount, pumpcount, pumpinputinstruct1, wantedpumps]
/ inputdevice = mouse
/ ontrialbegin = [
trial.pumpinput.resetstimulusframes();
var i = 0;
while (i < list.buttonlist.itemcount) {
trial.pumpinput.insertstimulusframe(list.buttonlist.nextvalue, 1); // display all buttons contained in the list
i += 1;
};
]
/ ontrialend = [
list.usedbuttons.appenditem(trial.pumpinput.response); // add the clicked button to a list for response (in)validation
list.buttonlist.removeitem(list.buttonlist.indexof(trial.pumpinput.response)); // remove the button that was clicked from the list
values.wantedpumps = +trim(trial.pumpinput.response, "pump");
//values.wantedpumps = trial.pumpinput.response;
if (monkey.monkeyMode == true)
values.wantedpumps = list.monkeyresponses.nextValue;
if (parameters.fixed_explosionsequence == true)
values.explosionpoint = list.fixed_explosionpoints.nextValue;
values.timebefore1stpump = trial.pumpinput.latency;
values.total_wantedpumps += values.wantedpumps;
if (values.ballooncount < 11)
values.total_wantedpumps_10 += values.wantedpumps
else if (values.ballooncount <21 )
values.total_wantedpumps_20 += values.wantedpumps
else if (values.ballooncount <31 )
values.total_wantedpumps_30 += values.wantedpumps
;
]
/ isvalidresponse = [
list.usedbuttons.indexof(trial.pumpinput.response) == -1; // response is only valid if the button has not yet been used
]
/ branch = [
if (values.wantedpumps > 0)
return trial.pump;
else
return trial.collect;
]
/ recorddata = false
</trial>
Note:
- pumps up the balloon by increasing the balloons size and playing a pump sound
- lasts as long as indicated by parameters.pumpduration (editable value)
- determines if balloon is to pop after a pump
if yes -> calls trial.pop
if no -> determines if balloon needs to be pumped further
if yes -> calls itself again
if no -> calls trial.collect
<trial pump>
/ ontrialbegin = [
if (parameters.fixed_explosionsequence == false)
values.pumpresult = list.pumpresult.nextValue;
values.scalingFactor += parameters.balloonsizeincrement;
shape.blank.width = picture.balloon.width;
shape.blank.height = picture.balloon.height;
values.pumpcount += 1;
]
/ stimulustimes = [1= balloon, totalearnings, pumpcount, potentialearnings, ballooncount, inflatesound, wantedpumps]
/ trialduration = parameters.pumpduration
/ ontrialend = [
values.totalpumpcount += 1;
if (values.ballooncount < 11)
values.totalpumpcount _10 += 1
else if (values.ballooncount > 10 && values.ballooncount <21 )
values.totalpumpcount_20 += 1
else if (values.ballooncount > 20 && values.ballooncount <31 )
values.totalpumpcount_30 += 1
;
]
/ branch = [
if (parameters.fixed_explosionsequence == false && values.pumpresult == 1)
return trial.pop;
else if (parameters.fixed_explosionsequence == true && values.pumpcount == values.explosionpoint)
return trial.pop;
else if (values.pumpcount == values.wantedpumps)
return trial.collect;
else
return trial.pump;
]
/ recorddata = false
</trial>
Notes:
- trial explodes the balloon
- updates number of explosions
- calls trial.init for another round
<trial pop>
/ ontrialbegin = [
values.explosion = 1;
values.total_explosions += 1;
if (values.ballooncount < 11)
values.total_explosions_10 += 1
else if (values.ballooncount <21 )
values.total_explosions_20 += 1
else if (values.ballooncount <31 )
values.total_explosions_30 += 1
;
shape.blank.width = picture.balloon.width;
shape.blank.height = picture.balloon.height;
]
/ stimulustimes = [1=popsound, poppedballoon, totalearnings]
/ response = noresponse
/ ontrialend = [
values.average_wantedpumps = values.total_wantedpumps/values.ballooncount;
if (values.ballooncount < 11)
values.average_wantedpumps_10 = values.total_wantedpumps_10/values.ballooncount_10
else if (values.ballooncount <21 )
values.average_wantedpumps_20 = values.total_wantedpumps_20/values.ballooncount_20
else if (values.ballooncount <31 )
values.average_wantedpumps_30 = values.total_wantedpumps_30/values.ballooncount_30
;
values.ss_wantedpumps += (values.wantedpumps * values.wantedpumps);
values.averagepumpcount = values.totalpumpcount/values.ballooncount;
if (values.ballooncount < 11)
values.averagepumpcount_10 = values.totalpumpcount_10/values.ballooncount_10
else if (values.ballooncount <21 )
values.averagepumpcount_20 = values.totalpumpcount_20/values.ballooncount_20
else if (values.ballooncount <31 )
values.averagepumpcount_30 = values.totalpumpcount_30/values.ballooncount_30
;
values.ss_pumpcount += (values.pumpcount * values.pumpcount);
if (parameters.fixed_explosionsequence == false)
values.explosionpoint = values.pumpcount;
]
/ branch = [return trial.summary;]
/ responseinterrupt = trial
/ recorddata = false
</trial>
Note:
- trial updates the actual winnings and the number of nonexploded balloons
- if parameters.fixed_explosionsequence == true calls trial.reveal
- if parameters.fixed_explosionsequence == false calls trial.findexplosionpoint
<trial collect>
/ ontrialbegin = [
values.nonexplodedballoons += 1;
if (values.ballooncount < 11)
values.nonexplodedballoons_10 += 1
else if (values.ballooncount <21 )
values.nonexplodedballoons_20 += 1
else if (values.ballooncount <31 )
values.nonexplodedballoons_30 += 1
;
shape.blank.width = picture.balloon.width;
shape.blank.height = picture.balloon.height;
values.totalearnings = values.totalearnings + (values.pumpcount * parameters.pumpvalue);
]
/ stimulustimes = [1=collectsound, totalearnings]
/ response = noresponse
/ ontrialend = [
values.average_wantedpumps = values.total_wantedpumps/values.ballooncount;
if (values.ballooncount < 11)
values.average_wantedpumps_10 = values.total_wantedpumps_10/values.ballooncount_10
else if (values.ballooncount > 10 && values.ballooncount <21 )
values.average_wantedpumps_20 = values.total_wantedpumps_20/values.ballooncount_20
else if (values.ballooncount > 20 && values.ballooncount <31 )
values.average_wantedpumps_30 = values.total_wantedpumps_30/values.ballooncount_30
;
values.ss_wantedpumps += (values.wantedpumps * values.wantedpumps);
values.averagepumpcount = values.totalpumpcount/values.ballooncount;
if (values.ballooncount < 11)
values.averagepumpcount_10 = values.totalpumpcount_10/values.ballooncount_10
else if (values.ballooncount <21 )
values.averagepumpcount_20 = values.totalpumpcount_20/values.ballooncount_20
else if (values.ballooncount <31 )
values.averagepumpcount_30 = values.totalpumpcount_30/values.ballooncount_30
;
values.ss_pumpcount += (values.pumpcount * values.pumpcount);
values.adjustedtotalpumpcount += values.pumpcount;
if (values.ballooncount < 11)
values.adjustedtotalpumpcount_10 += values.pumpcount
else if (values.ballooncount <21 )
values.adjustedtotalpumpcount_20 += values.pumpcount
else if (values.ballooncount <31 )
values.adjustedtotalpumpcount_30 += values.pumpcount
;
values.adjustedaveragepumpcount = values.adjustedtotalpumpcount / values.nonexplodedballoons;
if (values.ballooncount < 11)
values.adjustedaveragepumpcount_10 = values.adjustedtotalpumpcount_10 / values.nonexplodedballoons_10
else if (values.ballooncount <21 )
values.adjustedaveragepumpcount_20 = values.adjustedtotalpumpcount_20 / values.nonexplodedballoons_20
else if (values.ballooncount <31 )
values.adjustedaveragepumpcount_30 = values.adjustedtotalpumpcount_30 / values.nonexplodedballoons_30
;
values.ss_adjustedpumpcount += (values.pumpcount * values.pumpcount);
]
/ branch = [
if (parameters.fixed_explosionsequence == false) {
values.explosionpoint = values.pumpcount;
return trial.findexplosionpoint;
} else {
if (parameters.revealexplosionpoint == true) {
return trial.reveal;
} else {
return trial.summary;
}
}
]
/ responseinterrupt = trial
/ recorddata = false
</trial>
Notes:
- this trial is only run if parameters.fixed_explosionsequence = false (and the balloon did not pop)
as the explosion point in this case is not known beforehand
- determines the explosionpoint by sampling from list.pumpresult as long as it takes to sample the 1
- once the explosionpoint is established, calls trial.reveal if parameters.revealexplosionpoint = true,
otherwise calls trial.summary
<trial findexplosionpoint>
/ ontrialbegin = [
values.explosionpoint += 1;
values.pumpresult = list.pumpresult.nextValue;
]
/ branch = [
if (values.pumpresult == 1) {
if (parameters.revealexplosionpoint == true) {
return trial.reveal;
} else {
return trial.summary;
}
} else {
return trial.findexplosionpoint;
}
]
/ trialduration = 0
/ recorddata = false
</trial>
Notes:
- trial is only run if balloon did not pop
- reveals the explosion point of the current balloon for a set amount of time parameters.revealduration (editable value)
<trial reveal>
/ stimulusframes = [1 = clearScreen, explosionreveal]
/ timeout = parameters.revealduration
/ branch = [return trial.summary;]
/ recorddata = false
</trial>
Notes:
- purpose of this trial is to save all relevant data to the raw data file
<trial summary>
/ recorddata = true
/ trialduration = 0
/ branch = [return trial.init;]
</trial>
*******************************************************************************************************************
*******************************************************************************************************************
BLOCKS
*******************************************************************************************************************
*******************************************************************************************************************
<block BART>
/ onblockbegin = [
values.balloonwidth = 0.3 * display.width;
values.balloonheight = 0.3 * display.height;
]
/ trials = [1-2=instructions; 3=init; 4=instructions]
/ stop = [trial.init.trialcount > parameters.totalballoons]
</block>
<block summary>
/ trials = [1= finish]
</block>
*******************************************************************************************************************
*******************************************************************************************************************
EXPERIMENT
*******************************************************************************************************************
*******************************************************************************************************************
<expt BART>
/ onexptbegin = [
if ( !parameters.showpumpcount )
text.pumpcount.hposition = 100%;
if ( !parameters.showballooncount )
text.ballooncount.hposition = 100%;
if ( !parameters.showpotentialearnings )
text.potentialearnings.hposition = 100%;
]
/ blocks = [
1=BART;
2=summary;
]
</expt>