PennController for IBEX › Forums › Support › Keeping track of participant accuracy
- This topic has 7 replies, 3 voices, and was last updated 4 years, 4 months ago by miriam.
-
AuthorPosts
-
August 9, 2020 at 10:40 am #5905miriamParticipant
Hello!
I’m planning a self-paced reading study and want to keep track of participants’ response accuracy on comprehension questions presented after certain trials. I’m using Template to read in the trials from a .csv file.
I have tried to keep track of accuracy by defining a global variable (newVar(“PracAcc”).settings.global()) and then updating it on every trial, but if I initialize this variable in Header, it gets reset in every trial, whereas if I initialize it outside of Template or Header, the variable cannot be accessed. How can I keep track of participant accuracy throughout the experiment?
Many thanks in advance for your help!
MiriamAugust 9, 2020 at 12:57 pm #5906JeremyKeymasterHello Miriam,
Both options should normally work. Here is an example script, switch the commenting // to test out the two options:
PennController.ResetPrefix(null) AddTable("myTable", "Correct\nYes\nNo\nYes\nNo" ) Header( // newVar("Acc", []).global() ) newTrial( "intro" , newVar("Acc", []).global(), newButton("Start").print().wait() ) Template( "myTable" , row => newTrial( "exp" , newVar("computedAcc").set(getVar("Acc")).set(v=>v.filter(a=>a===true).length/v.length), newText("accuracy").text(getVar("computedAcc")).print("left at 5px", "top at 5px") , newScale("answer", "Yes","No").button().print().wait() .test.selected(row.Correct) .success( getVar("Acc").set(v=>[...v,true]) ) .failure( getVar("Acc").set(v=>[...v,false]) ) )) newTrial( "end" , newVar("computedAcc").set(getVar("Acc")).set(v=>v.filter(a=>a===true).length/v.length), newText("accuracy").text(getVar("computedAcc")) , newText("Final accuracy: ").after(getText("accuracy")).print() , newButton().wait() )
In this example I set the global Var element to an array of true‘s and false‘s so I can then compute the current accuracy on each trial by dividing the number of true‘s by the length of the array.
Note that some Var-related bugs were fixed with PennController 1.8, so make sure to update your version of PennController if the script above does not work for you
Jeremy
August 10, 2020 at 3:38 pm #5966carlapParticipantI have a similar issue. I want to keep track of correct answers and I tried to integrate the information above but without success. I am not using a scale, I am using the arrow keys. My code to track the keys is:
newKey(“pressOnArrow”, “ArrowLeft”, “ArrowRight”) .callback( getTimer(“timeout”).stop() ).log(“all”) , newTimer(“timeout”, 5000).start().log().wait() , getKey(“pressOnArrow”) .disable() .test.pressed().success( newText(“Good job”).print() ) .failure( newText(“Too slow”).print() ))
Obviously that is not my original coding (thanks for the earlier help). Now, I want to track if the ArrowLeft or ArrowRight is the correct answer and store it in a variable to display at the end of a section of trials. I tried integrating:
.test.selected(row.Correct)
.success( getVar(“Acc”).set(v=>v+1) )But it does not seem to work. I do not need to keep track of wrong answwers. Any thoughts? Thanks!
August 10, 2020 at 3:54 pm #5967JeremyKeymasterHi,
There is no selected test for Key elements, what you are looking for is test.pressed
Example:
newTrial( newKey("test", "ArrowLeft", "ArrowRight") .wait() .test.pressed( "ArrowLeft" ) .success( newText("Left").print() ) .failure( newText("Right").print() ) , newButton().wait() )
Jeremy
August 11, 2020 at 3:20 pm #5968miriamParticipantThanks a lot Jeremy, both solutions work perfectly for me!
August 12, 2020 at 3:34 am #5971miriamParticipantHi Jeremy,
I now ran into a new problem when trying to access my accuracy variable during the experiment to provide feedback. Basically I just want to check whether the value lies between certain thresholds, but the statement below always seems to evaluate to false and print “Low accuracy”, even if I manually set accuracy to a higher value. Do you know how to fix this?
newTrial("feedback", newVar("Acc", 0.8).global() , newText("low_acc", "Low accuracy") , newText("high_acc", "High accuracy") , ( getVar("Acc") > 0.5 ? [ getText("high_acc").print() ] : [ getText("low_acc").print() ] ) , newButton("Exit") .center() .print() .wait() )
August 12, 2020 at 12:51 pm #5974JeremyKeymasterHi,
You are using a plain javascript ternary conditionals where you should be using a PennController test command. I briefly explain this point below the code in this message.
Your trial should look like this:
newTrial("feedback", newVar("Acc", 0.8).global() , newText("low_acc", "Low accuracy") , newText("high_acc", "High accuracy") , getVar("Acc").test.is( v => v > 0.5 ) .success( getText("high_acc").print() ) .failure( getText("low_acc").print() ) , newButton("Exit") .center() .print() .wait() )
Jeremy
August 14, 2020 at 12:10 pm #5998miriamParticipantAwesome, thank you! I had also tried using test.is() before but somehow it did not produce the intended results then. Now everything works 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.