April 7, 2020 at 11:28 am #5008kaylacParticipant
I used selector in my experiment but found that I only get the element I chose recorded under the column “value” and not the reaction time I took to choose it. Is there a way to include reaction times? If the only way is to calculate reaction times from values in the “EventTime” column (by the EventTime of selection minus the EventTime of the starting point), which starting point I should refer to?
Thanks so much for your help!!
KaylaApril 7, 2020 at 12:35 pm #5009JeremyKeymaster
The reason why there is no ‘reaction time’ column by default is precisely because the starting point is arbitrary: which event do you consider relevant to start measuring how fast your participants are to answer?
By default PennController logs when the trial starts, so if that’s what you want, you can use that EventTime to subtract from the selection’s EventTime. If you’d rather refer to, say, the display of an image as your starting point, then you can use the .log command on the Image element (or its containing Canvas) and you’ll have a line in your results file reporting when the image was printed on the screen.
The very last page of the tutorial includes an R script that illustrates how to calculate reaction times using the EventTime column (with the beginning of the trial as the starting point).
Yet another option is to calculate the RTs upon runtime, and add a “ReactionTime” column to your trials using .log on newTrial. For that, you need to use a Var element, like this:
Template( row => newTrial( newButton("Start the trial").print().wait().remove() , newSelector("choice").once() , defaultImage.size(200,200).selector("choice") , newCanvas( 400 , 200 ) .add( 0 , 0 , newImage( row.target ) ) .add( 200 , 0 , newImage( row.competitor ) ) .print() , newVar("RT").global().set( v => Date.now() ) , getSelector("choice").shuffle().wait() , getVar("RT").set( v => Date.now() - v ) , newTimer(500).start().wait() ) .log( "ReactionTime" , getVar("RT") ) )
JeremyApril 8, 2020 at 6:07 am #5013kaylacParticipant
Thanks, Jeremy! This helps a lot!
KaylaApril 20, 2020 at 5:43 pm #5091glossaphileParticipant
How might I print a reaction time (or any numerical information) to the screen during the experiment? The “print()” command doesn’t work on a Var element or even on a Text element created by “newText(getVar(“VarName”)).” In the former case I get nothing, and in the latter case I get “undefined.”
April 20, 2020 at 5:53 pm #5093JeremyKeymaster
- This reply was modified 3 years, 7 months ago by glossaphile.
As you found out, you cannot pass a Var element to initiate another element. This is because all the new* commands (but not their corresponding blocks of commands) are evaluated at the very beginning of the experiment, at which point the Var elements have not been set in the yet-to-come flow of trial events.
What you can do instead is use the .text command of the Text element, like this:
newVar("RT").set( v=>Date.now() ) , newButton("Click!").print().wait() , getVar("RT").set( v=>Date.now()-v ) , newText().text( getVar("RT") ).print()
- You must be logged in to reply to this topic.