Millisecond Forums

Count and display valid responses in data file

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

By helenr - 6/11/2016

Hi, I was wondering whether someone could help me. I'm running a very simple task in which participants tap the space bar as many times as they can within 2 minutes (this is done twice - once in a 'chocolate trial' and once in a 'grape trial'.
In the data file, I want it to give me a total number of times each participant tapped the space bar within that 2 minute period.
Please could you let me know how I can display this information in the data file ?
Thanks in advance for your help.
Here's my (abbreviated) code:

<values >
/blocklength = 120000
/tapcount_choc = 0
/tapcount_grapes = 0
/start120speriod = 0
/food = 0
</values>
*******************************DATA FILE**********************************
<data >
/file = "Tapping task.dat"
/ columns = [date, time, subject, values.tapcount_choc, values.tapcount_grapes]
/ separatefiles = false
/ format = tab
</data>
****************************************TRIALS*******************************************************8
<trial choc>
/ inputdevice = keyboard
/ validresponse = (57)
/ timeout = 120000
/ ontrialbegin = [values.trialstarttime = script.elapsedtime]
/ ontrialend = [if (trial.choc.response == 57) values.tapcount_choc=1 else values.tapcount_choc=0; values.sumtapcount_choc=values.sumtapcount_choc+values.tapcount_choc  ]
/ branch = [trial.choc]
/ recorddata = true
</trial>
<trial grapes>
/ inputdevice = keyboard
/ validresponse = (57)
/ timeout = 120000
/ ontrialbegin = [values.trialstarttime = script.elapsedtime]
/ ontrialend = [if (trial.grapes.response == 57) values.tapcount_grapes=1 else values.tapcount_grapes=0; values.sumtapcount_grapes=values.sumtapcount_grapes+values.tapcount_grapes ]
/ branch = [trial.grapes]
/ recorddata = true
</trial>
**************************************BLOCKS**************************************
<block tapping_choc>
/ bgstim = (remindertext_choc)
/ onblockbegin = [ values.start120speriod = 0; values.tapcount_choc = 0]
/ trials = [1 = choc]
/ onblockend = [values.tapcount_choc]
/timeout = 120000
</block>
<block tapping_grapes>
/ bgstim = (remindertext_grapes)
/ onblockbegin = [ values.start120speriod = 0; values.tapcount_grapes = 0]
/ trials = [1 = grapes]
/ onblockend = [values.tapcount_grapes]
/timeout = 120000
</block>

***************************EXPERIMENT***************************************

<expt >

/ preinstructions = (intro)

/ blocks = [1 = chocolate;  2=tapping_choc;

3 = grapes; 4=tapping_grapes]

</expt>

By Dave - 6/12/2016

Simply log values.sumtapcount_choc & values.sumtapcount_grapes to the data file?

<data >
/file = "Tapping task.dat"
/ columns = [date, time, subject, values.tapcount_choc, values.tapcount_grapes, values.sumtapcount_choc, values.sumtapcount_grapes]
/ separatefiles = false
/ format = tab
</data>

These values need to actually exist in your <values> element of course.

<values >
/blocklength = 120000
/tapcount_choc = 0
/tapcount_grapes = 0
/start120speriod = 0
/food = 0
/sumtapcount_choc = 0
/sumtapcount_grapes = 0
</values>
By helenr - 6/14/2016

Great, thank you so much for your help! Just another question, I was hoping to display a countdown timer while participants are doing the task (i.e. so it counts down from 2 minutes). Do you know the best way to implement this ?

Thanks!