Millisecond Forums

Counting Errors

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

By Gaurav Krishnamoorthy - 5/9/2017

Hi !
We are looking for an expression that would start counting the participant's errors only after the first error. It would be great if you could help us code this.
Thank you for your help!

Here is a segment of our script...
...
<item b0>
/1="Blackrectangle.jpg"
</item>

<item b1>
/1="block1.001.jpg"
</item>

<item b2>
/1="block1.002.jpg"
</item>

<picture b0>
/items=b0
/position=(50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b1>
/items= b1
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b2>
/items=b2
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<trial b1>
/ stimulustimes = [0=b1; 500=b0]
/inputdevice=keyboard
/correctresponse=("a")
/validresponse = ("a","l")
/timeout=2200
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b1.correct) values.earnings +=1 else values.losses -=1]
</trial>

<trial b2> 
/stimulustimes = [0=b2; 500=b0]
/inputdevice= keyboard
/correctresponse= ("l")
/validresponse = ("a","l")
/timeout=2100
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b2.correct) values.earnings +=1 else values.losses -=1]
</trial>

<block practice>
/trials= [1=sequence (startpractice,b1,b2)]
/ screencolor  = (0, 0, 0)
/ recorddata = false
/ postinstructions = (practiceSummary)
</block>

<values >
/earnings=0
/losses=0
/earningstest=0
/lossestest=0
</values>

<page Summary>
^^    FEEDBACK
^^
^^    Total = $<%(values.earningstest+values.lossestest)%>
</page>

<expt>
/blocks=[1=practice]
</expt>
By Dave - 5/9/2017

Gaurav Krishnamoorthy - Tuesday, May 9, 2017
Hi !
We are looking for an expression that would start counting the participant's errors only after the first error. It would be great if you could help us code this.
Thank you for your help!

Here is a segment of our script...
...
<item b0>
/1="Blackrectangle.jpg"
</item>

<item b1>
/1="block1.001.jpg"
</item>

<item b2>
/1="block1.002.jpg"
</item>

<picture b0>
/items=b0
/position=(50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b1>
/items= b1
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b2>
/items=b2
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<trial b1>
/ stimulustimes = [0=b1; 500=b0]
/inputdevice=keyboard
/correctresponse=("a")
/validresponse = ("a","l")
/timeout=2200
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b1.correct) values.earnings +=1 else values.losses -=1]
</trial>

<trial b2> 
/stimulustimes = [0=b2; 500=b0]
/inputdevice= keyboard
/correctresponse= ("l")
/validresponse = ("a","l")
/timeout=2100
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b2.correct) values.earnings +=1 else values.losses -=1]
</trial>

<block practice>
/trials= [1=sequence (startpractice,b1,b2)]
/ screencolor  = (0, 0, 0)
/ recorddata = false
/ postinstructions = (practiceSummary)
</block>

<values >
/earnings=0
/losses=0
/earningstest=0
/lossestest=0
</values>

<page Summary>
^^    FEEDBACK
^^
^^    Total = $<%(values.earningstest+values.lossestest)%>
</page>

<expt>
/blocks=[1=practice]
</expt>

Where do you count errors specifically? And -- if you count them -- why can't you just subtract one from the final count?
By Dave - 5/9/2017

Dave - Tuesday, May 9, 2017
Gaurav Krishnamoorthy - Tuesday, May 9, 2017
Hi !
We are looking for an expression that would start counting the participant's errors only after the first error. It would be great if you could help us code this.
Thank you for your help!

Here is a segment of our script...
...
<item b0>
/1="Blackrectangle.jpg"
</item>

<item b1>
/1="block1.001.jpg"
</item>

<item b2>
/1="block1.002.jpg"
</item>

<picture b0>
/items=b0
/position=(50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b1>
/items= b1
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<picture b2>
/items=b2
/position= (50,50)
/size= (100%, 100%)
/erase=false
</picture>

<trial b1>
/ stimulustimes = [0=b1; 500=b0]
/inputdevice=keyboard
/correctresponse=("a")
/validresponse = ("a","l")
/timeout=2200
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b1.correct) values.earnings +=1 else values.losses -=1]
</trial>

<trial b2> 
/stimulustimes = [0=b2; 500=b0]
/inputdevice= keyboard
/correctresponse= ("l")
/validresponse = ("a","l")
/timeout=2100
/beginresponsetime=0
/recorddata = true
/ontrialend=[ if (trial.b2.correct) values.earnings +=1 else values.losses -=1]
</trial>

<block practice>
/trials= [1=sequence (startpractice,b1,b2)]
/ screencolor  = (0, 0, 0)
/ recorddata = false
/ postinstructions = (practiceSummary)
</block>

<values >
/earnings=0
/losses=0
/earningstest=0
/lossestest=0
</values>

<page Summary>
^^    FEEDBACK
^^
^^    Total = $<%(values.earningstest+values.lossestest)%>
</page>

<expt>
/blocks=[1=practice]
</expt>

Where do you count errors specifically? And -- if you count them -- why can't you just subtract one from the final count?

Working of a guess / incomplete understanding: My assumptions are:
(1) You always want to increase values.earnings in case of a correct response.
(2) You want to decrease values.losses in case of a wrong response, but only if the participant has already made at least one error.

If so:

Introduce a new variable where you explicitly count the errors

<values>
/ errorcounter = 0
...
</values>

Always increase that counter in case of an error and decrease values.losses only if the errorcounter is greater than 1.

<trial b1>
/ stimulustimes = [0=b1; 500=b0]
/inputdevice=keyboard
/correctresponse=("a")
/validresponse = ("a","l")
/timeout=2200
/beginresponsetime=0
/recorddata = true
/ ontrialend = [ if (trial.b1.correct) values.earnings +=1]
/ ontrialend = [ if (trial.b1.error) values.errorcounter += 1]
/ ontrialend = [ if (trial.b1.error && values.errorcounter > 1) values.losses -= 1]
</trial>

<trial b2> 
/stimulustimes = [0=b2; 500=b0]
/inputdevice= keyboard
/correctresponse= ("l")
/validresponse = ("a","l")
/timeout=2100
/beginresponsetime=0
/recorddata = true
/ ontrialend = [ if (trial.b2.correct) values.earnings +=1]
/ ontrialend = [ if (trial.b2.error) values.errorcounter += 1]
/ ontrialend = [ if (trial.b2.error && values.errorcounter > 1) values.losses -= 1]
</trial>