Millisecond Forums

Messing With Branch/ontrialend/stop attributes

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

By cgoetz - 10/3/2012

Hi,


So i'm currently trying to write a script for a test in which I present a pattern image with a missing square, and subjects pick the right square which completes the pattern. I've gotten the images to load with the proper positioning and mouse click responses displaying correct/incorrect.


The trick here, however, is that I need to code the stop cue, which occurs when the subject gets 3 out of the last 5 answers incorrect. 


Here's how I have it set up:


Each trial is one question with 5 different answer options. There's currently one block which dictates all these trials to run in order, and the experiment dictates the one block to run. 


To try and solve the scoring issue, I've tried several things:



  1. Coding /branch [if (trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2) trial.endtrial] into trials. This should theoretically count the last 5 answers (#25-29), and if the subject gets only 2 or less right (3 wrong), it would branch to the last trial trial.endtrial. No good.

  2. Coding /ontrialend [if (trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2) trial.endtrial] into trials. Similar result.

  3. Coding /stop [trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2] into block. I believe this similarly didn't stop the block. 

  4. Coding /stop [trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2] into expt. This simply stopped the experiment before a single trial was run.

  5. Coding /branch [if (trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2) page.end] to see if it would jump to an end page after catching the branch, but no good.

  6. Coding /branch [if (trial.a25.correct + trial.a26.correct +trial.a27.correct + trial.a28.correct + trial.a29.correct <= 2) block.endblock] to see if it would jump to an end block after catching the branch, but no good.


Any advice would be lovely, as I'm at my wit's end here trying to figure out how to make this work. I've considered the possibility of creating some sort of vector measurement that would automatically take the last 5 recorded answers and check if percent correct is less than 40%, but I don't know how to code that.



Here are some example codes:



<expt exptest3>


/preinstructions = (intro, getready)


/postinstructions = (end)


/blocks = [1=block1]   


</expt>



<block block1>


/ trials = [1=A20,A21,A22,A23,A24,A25,A26,A27,A28,A29]


</block>



<trial A25>


/ showmousecursor = true


/validresponse = (A25.1,A25.2,A25.3,A25.4,A25.5,A25.6)


/correctresponse = (A25.5)


/ stimulusframes = [1=A25.big; 2=A25.1,A25.2,A25.3,A25.4,A25.5,A25.6]


/errormessage = true(error, 300)


</trial>




Thanks!


Calvin



By Dave - 10/3/2012

Simply create a <values> entry and add 1 to it for every correct response. After x amount of trials, check said value and either /stop or continue. You can find many examples among the scripts available via the Task Library, e.g., the Corsi Block Tapping Task.


Regards,


~Dave

By cgoetz - 10/3/2012

Hey Dave,


Would that address the issue of needing a rolling evaluation? For example, on trial 25 it would need to evaluate trials 21-25, then on trial 26 trials 22-26 etc. If I'm just adding up correct responses, it would never be less than 3 for any given set of 5 responses. 


I've been looking at Corsi Block Tapping Task for a while, and it's a tough one to wrap my head around



Thanks,


Calvin

By Dave - 10/3/2012

Would that address the issue of needing a rolling evaluation? For example, on trial 25 it would need to evaluate trials 21-25, then on trial 26 trials 22-26 etc. If I'm just adding up correct responses, it would never be less than 3 for any given set of 5 responses. 


Yes. You simply need to reset the respective <values> entry to 0 after every chunk of 5 trials.

By cgoetz - 10/3/2012

Well, if I reset the <values> entry to 0 on every chunk of 5 trials, then, for example, a subject could continue if they only get 2 wrong out of every chunk of 5:


Ex: Responsetrial1 [0,0,0,1,1] wouldn't trigger a /stop. However, if [0,0,0,1,1] were followed by [1,1,0,0,0], there would be 4 wrong in a row, but it would not trigger the end sequence still.

By Dave - 10/3/2012

Ah, I see. I mistakenly thought you wanted to consider fixed *sets* of 5 (i.e, 1-5, 6-10, 11-15). Regardless, you can still build this with conditional logic (think about how you would go about it using paper and pencil instead of a computer) or simply use the built-in errorstreak property.

By Dave - 10/3/2012

And here's a quick example of one way to do it via a bit of conditional logic (there are many more options):


<values>
/ responsevector = ""
</values>

<block myblock>
/ stop = [contains(values.responsevector, "0000")]
/ trials = [1-20=mytrial]
</block>

<trial mytrial>
/ ontrialend = [values.responsevector=concat(values.responsevector,trial.mytrial.correct)]
/ stimulusframes = [1=debug]
/ validresponse = ("d", "k")
/ correctresponse = ("d")
</trial>

<text debug>
/ items = ("<%values.responsevector%>")
</text>


And, as an extension of the above, let's consider only the 5 most recent trials and check if incorrect responses occurred in 3 or more:


<values>
/ responsevector = "-----"
</values>

<block myblock>
/ stop = [length(values.responsevector)-length(replaceall(values.responsevector, "0", ""))>=3]
/ trials = [1-20=mytrial]
</block>

<trial mytrial>
/ ontrialend = [values.responsevector=concat(values.responsevector,trial.mytrial.correct);
    values.responsevector=substring(values.responsevector, length(values.responsevector)-5, length(values.responsevector))]
/ stimulusframes = [1=debug]
/ validresponse = ("d", "k")
/ correctresponse = ("d")
</trial>

<text debug>
/ items = ("<%values.responsevector%>")
</text>


Regards,


~Dave