problems with timeout

PennController for IBEX Forums Support problems with timeout

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10489
    noedoc1
    Participant

    Hi, Jeremy!
    I’m coding a lexical decision task and I want participants no answer if the word they see on the screen is a Spanish word or not with 1 (yes) and 0 (no). I also want to include a timeout, so if they take more than 1000 they can’t answer anymore and the experiment goes on to the next stimulus.
    I used the .success and .failure options to code this (thanks for your answers on previous threads!) however now I’m having problems when the answer is correct. If I press 1 or 0 before the 1000 time limit, it should move on to the next trial, however this is not working. I have to press the 1 or 0 two times for it to move on. Do you know what might be wrong in the code?

    Here is the relevant code:

    newTrial("entrenamiento1",
        // Display all future Text elements centered on the page, and log their display time code
        defaultText.center().print("center at 50vw","middle at 50vh")
        ,
        // Automatically start and wait for Timer elements when created
        defaultTimer.start().wait()
        ,
        // Mask, shown on screen for 250ms
        newText("mask","########"),
        newTimer("maskTimer", 250),                       
        getText("mask").remove()
        ,
        // Prime, shown on screen for 28ms
        newText("prime", "verde"),
        newTimer("primeTimer", 28),
        getText("prime").remove()
        ,
        // Mask, shown on screen for 14ms
        newText("blanco"," "),
        newTimer("blancoTimer", 14),                       
        getText("blanco").remove()
        ,
        // Mask, shown on screen for 46ms
        newText("mask2","########"),
        newTimer("maskTimer2", 46),                       
        getText("mask2").remove()
        ,
        // Target, shown on screen until 1 or 0 is pressed  
        newText("target","NARANJA")
        ,
        newTimer("hurry", 1000)
            .log()
            .start()
        ,
        newKey("answerTarget", "10")    
            .log()
            .callback(getTimer("hurry").stop())
        ,
        getTimer("hurry")
        .wait()
        ,
        getKey("answerTarget")
        .test.pressed()
        .success(getText("target").remove())
        .failure(getText("target").remove(),
            newText("lento", "¡Muy lento! Recordá responder rápidamente.")
            .log()
            .print("center at 50vw","middle at 50vh")
            .center()
            .color("red"),
            newTimer("fail", "1000"),
            getText("lento"))
        ,
        newText("*")
        .css("font-size", "x-large")
        .center().print("center at 50vw","middle at 50vh")
        ,
        newTimer("*timer", 250)
        ,
        getText("*")
        .remove() // End of trial   
    )

    Also, the demonstration link is here: https://farm.pcibex.net/r/nwrPpa/

    Thanks a lot!
    Noelia.

    • This topic was modified 11 months ago by noedoc1.
    #10499
    Jeremy
    Keymaster

    Hi Noelia,

    All the Timer elements in your trial are started and waited for upon creation: defaultTimer.start().wait()

    This applies to the one named “hurry” too, so newTimer("hurry", 1000).log().start() implicitly stands for newTimer("hurry", 1000).start().wait().log().start()

    Remove .wait() from the default commands, and include it explicitly where you need it

    Jeremy

    #10502
    noedoc1
    Participant

    Thanks, Jeremy! This solved my problem!

    #10514
    noedoc1
    Participant

    Hi Jeremy! I dowloaded the results file and I am having some problems identifying the key pressed in the lexical decision task. I put the .log command on both the newKey and the getKey, but on the results file it says (failed keypresses happened). I pressed the keys following a pattern, so there should be several 1 answers, several 0 answers, several null answers (which are time-out answers; this are actually displayed), several 1 answers and so on…
    I also don’t understand why all the information about the pressed keys are at the bottom, and not on each trial. Do you see what the problem is?

    Here is the relevant code:

    Template( "list.csv" , 
        row => newTrial( "test" ,   
            // Display all Text elements centered on the page, and log their display time code
            defaultText.center().print("center at 50vw","middle at 50vh").log()
            ,
            // Automatically start for Timer elements when created, and log those events
            defaultTimer.log().start()
            ,
            // Mask, shown on screen for 250ms
            newText("mask","########"),
            newTimer("maskTimer", 250).wait(),                       
            getText("mask").remove()
            ,
            // Prime, shown on screen for 28ms
            newText("prime",row.prime),
            newTimer("primeTimer", 28).wait(),
            getText("prime").remove()
            ,
            // Mask, shown on screen for 14ms
            newText("blanco"," "),
            newTimer("blancoTimer", 14).wait(),                       
            getText("blanco").remove()
            ,
            // Mask, shown on screen for 46ms
            newText("mask2","$$$$$$$$"),
            newTimer("maskTimer2", 46).wait(),                       
            getText("mask2").remove()
            ,
            // Target, shown on screen until 1 or 0 is pressed
            newText("target",row.target)
            ,
            newVar("rt") 
            .global()
            .set(v=>Date.now())
            ,
            newTimer("hurry", 3000)
            .log()
            ,
            newKey("answerTarget", "10")
            .log()
            .callback(getTimer("hurry").stop())
            ,
            getTimer("hurry").wait()
            ,
            getKey("answerTarget")
            .test.pressed()
            .success(getText("target").remove())
            .failure(getText("target").remove())
            .log()
            ,
            getVar("rt")
            .set(v=>Date.now()-v)
            ,
            newText("*")
            .css("font-size", "x-large")
            .center().print("center at 50vw","middle at 50vh")
            ,
            newTimer("*timer", 250).wait()
            ,
            getText("*")
            .remove() // End of trial
    )
        .log( "rt", getVar("rt")) // guardo el tiempo
        .log( "Group", row.Group)      // Group o lista
        .log( "cond", row.cond)  // condición (1, 2, 3, 4)
        .log( "cond_prime", row.cond_prime)  // condición del prime (congruente, incongruente)
        .log( "cond_target", row.cond_target)  // condición del target (congruente, incongruente)
        .log( "morf_prime", row.morf_prime)  // morfología del prime (femenina o masculina)
        .log( "morf_target", row.morf_target)  // morfología del target (femenina o masculina)
        .log( "rta_esperada", row.rta_esperada)  // respuesta esperada (1 o 0, 1 para sí/palabra y 0 para no/nopalabra)
        .log( "tarea", row.tarea)  // tipo de tarea (mujer_neutros; varon_neutros)
    )

    And here is the demonstration link: https://farm.pcibex.net/r/nwrPpa/

    Thanks in advance!

    #10519
    Jeremy
    Keymaster

    Hi,

    Use .log("first") instead of just .log() so you can capture keypresses that do not validate a wait command on the Key element:

    newKey("answerTarget", "10")
        .log("first")
        .callback(getTimer("hurry").stop())
    ,
    getTimer("hurry").wait()
    ,
    getKey("answerTarget")
        .test.pressed()
        .success(getText("target").remove())
        .failure(getText("target").remove())
        // removed this .log() as to not overwrite the first one
    ,

    Jeremy

    #10522
    noedoc1
    Participant

    Thanks a lot, Jeremy! This worked perfectly!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.