Reply To: Can we randomize time with newTimer() ?

PennController for IBEX Forums Support Can we randomize time with newTimer() ? Reply To: Can we randomize time with newTimer() ?

#7954
Larissa_Cury
Participant

Dear Jeremy,
Thank you for your kind answer as always. I’ve went through what we’ve discussed and I wasn’t able to notice before that the 4000 timeout trial had, indeed, the same formula as the original paper had (D1 + D2 + D3 + DRt + DWait = 4000 equals DWait = 3500 – D1 – DRT), I’m so sorry I took your time for trying to explaining that to me, but I really appreaciate your kindness, so, thank you once more. and thank you more going over the alternative method, I didn’t have a clue about using the Java option, so i’m sure that will contribuite for my future codes! I’ve already updated the whole model with the 4000 timeout approach, I only have 2 final concerns:

In order to use this approach to the practice trial, I’ve ajusted the Wait timer to 6000, not 4000, since the feedback takes 2000ms, like this:

//////////////////////////////////////////trial_1 - no_cue// PARA CIMA/LEFT//////////////////////////////////////////////////////
    Template("tabela-target_left.csv" , row => 
    newTrial("p_trial_1_no_cue_UP",
defaultText
        .center()
       .cssContainer({"position": "absolute",
                      "top": "50%",
                      "left": "50%",
                      "transform": "translate(-50%, +50%)"})
        .print()
,
newTimer("wait-separacao",6000).start()
,
    newText("D1", " <br> <b>+</b>")
    .cssContainer({
    "font-size":"100px",
    "color":"blue"})
    .center()
    .print()
,
   newTimer("timer-D1",400+Math.round(1200*Math.random()))
    .start()
    .wait()
,
   getText("D1")
   .remove()
,
newText("cue", "<br> <b>+</b>")
   .cssContainer({
   "font-size":"100px",
   "color":"green"})
   .center()
   .print()
,
    newTimer("timer_cue_D2",100)
    .start()
    .wait()
,
   getText("cue","D2")
   .remove()
,
   newText("D3", "<br> <b>+</b>")
   .cssContainer({
   "font-size":"100px",
   "color":"pink"})
   .center()
   .print()
,
   newTimer("timer_D3",400)
    .start()
    .wait()
,
   getText("D3")
   .remove()
,
newTimer("timer-RT",1700).start()
,
    newImage("imagens", row.imagem)
    .size(500, 200)
,
   newText("cruz_central", "<br> <b>+</b>")
   .cssContainer({
   "font-size":"100px",
   "color":"black"})
   .center()
   .print()
,
    //para cima//
    newCanvas("center", 150,150)
    .add( "center at 50%" , "center at 50%" , getImage("imagens"))
    .cssContainer({
    "position": "absolute",
    "margin-top": "85px"})
    .center()
    .log()
    .print()
,
newVar("localRT").set(v=>Date.now()),
    newKey("keypress1","SK")
    .log()
    .callback( getTimer("timer-RT").stop() )
,
 getTimer("timer-RT").wait()
,
getKey("keypress1").disable(),
    getText("cruz_central").remove()
,
    getCanvas("center").remove()
,
    getVar("localRT").set(v=>Date.now()-v),
    newVar("practiceRTs",[]).global().set(v=>[...v,getVar("localRT").value])
,
    newVar("accurate", []).global()
,
    getKey("keypress1")
     .test.pressed("S")
    .success(
    newVar("positiveFeedback").set( getVar("localRT") ).set( v=> "Correto! Você demorou "+v+"ms para responder" )
    ,
    newText("success")
        .text( getVar("positiveFeedback") )
        .cssContainer({"font-size":"30px", "text-align":"center", "margin-top":"255px","font-family":"Comic Sans MS", "color":"green","white-space":"nowrap"})
    ,
    getVar("accurate").set(v=>[...v,true])
)
    .failure(
    newVar("negativeFeedback").set( getVar("localRT") ).set( v=> "Incorreto! Você demorou "+v+"ms para responder" )
    ,
    newText("failure")
        .text( getVar("negativeFeedback") )
        .cssContainer({"font-size":"30px", "text-align":"center", "margin-top":"255px","font-family":"Comic Sans MS", "color":"red","white-space":"nowrap"})
,
    getVar("accurate").set(v=>[...v,false])
)
,
    newTimer("wait-success",2000) //timer for the success or failure messenge
    .start()
    .wait()
,
    getText("success")
    .remove()
,
    getText("failure")
    .remove()
,
   newText("separacao", "<br> <b>+</b>")
   .cssContainer({
    "font-size":"100px",
    "color":"yellow"})
   .center()
   .print()
,
    getTimer("wait-separacao").wait()
));

It seems to me that it’s working just fine, I’d just like to check if the math is right, is it?

Btw, I wasn’t able to fiz the “come back” button as you’ve explained me to do, it keeps on duplicating the trials, I’m sure I’ve did something wrong, but I don’t know what:

newText("instructions-14","<p><center> Se você quiser praticar de novo, clique aqui:")
    .cssContainer({
        "font-size":"22px",
        "text-align": "center"
    })
    .center()
    .print()
  ,
  newVar("practiceRTs").set( [] ) // --------------------------------- here  (I've tried to put it before the jumping inside the callback(), but it didn't work too (I probably did sth wrong, though)
  ,
  newButton("come back","PRATICAR DE NOVO")
    .callback(jump(startsWith("p_trial")) , end() )
    .css("margin","1.5em")
    .center()
    .print()

best,

  • This reply was modified 2 years, 8 months ago by Larissa_Cury. Reason: add relevant information to the post