Reply To: Setting accuracy and RT thresholds for practice block

PennController for IBEX Forums Support Setting accuracy and RT thresholds for practice block Reply To: Setting accuracy and RT thresholds for practice block

#6057
Jeremy
Keymaster

Hi Agnes,

The partial code you posted will launch the timewindow timer and wait that it has elapsed entirely before proceeding past its wait command, at which point it will reach the LD Key block containing the callback command, which will be ineffective since the timer will have already ended at that point. That’s why the callback that makes it possible to end the timer prematurely must come before the wait command on the timer, as in my code above.

I presume that you declare newVar("RT") before the timewindow timer and set it to Date.now() at that point. Because your getVar("RT") comes after the wait on your timer (and because, as we saw, the Key element cannot end it early) the value of your Var element will be at least as big as row.Time.

The second question, however, should always appear and never be skipped, given the code you posted (unless there is an end command elsewhere).

Here is a code that, I think, will do what you want. It should be embedded in Template of course:

newTrial( "practice" ,
    newVar( "responses" , [] ).global(),
    newVar("grandaverage", 0).global()
        .test.is( v => v>=0.5 ).success( end() )
    ,
    newText( "fix2" , row.Word ).print()
    ,
    newKey( "choice" , "FJ" ).log().callback( getTimer("timewindow").stop() )
    ,
    newVar("RT").set( v=>Date.now() )
    ,
    newTimer( "timewindow" , row.Time ).start().wait()
    ,
    getKey("choice").disable().test.pressed( row.Correct )
        .success(  getVar("responses").set(v=>[true,...v]) )
        .failure(  getVar("responses").set(v=>[false,...v]) )
    ,
    getText("fix2").remove()
    ,
    getVar("RT").set( v=>Date.now()-v )
        .test.is( v => v < 2000 )
        .failure(
            newText("Too slow...please respond faster").print()
            ,
            newTimer(1500).start().wait()
            ,
            end()
        )
    ,
    newTimer("wait", 500) 
        .start()
        .wait()
    ,
    newText("pred","Did you predict the word?").print()
    ,
    newKey("answer", "ZM")
        .wait() // This waits for a key press
        .log("first")
)

Note that if row.Time is lower than 2000, then consequently RT will never reach 2000 either (ie. row.Time is the max limit of RT). I chose to print the “Too slow” message for 1.5s before if RT is over 2000, and end the trial immediately after that. If RT is below 2000, the end command is not executed and so the script continues to print the pred Text and wait for a keypress on Z or M before reaching the end of the trial

Let me know if you have questions

Jeremy