Reply To: Multiple trial repetition

PennController for IBEX Forums Support Multiple trial repetition Reply To: Multiple trial repetition

#5576
Jeremy
Keymaster

Hi Farzaneh,

Unfortunately IBEX only supports static sequences of trials: the sequence of trials is computed at the very beginning of the experiment and proceeds linearly.

The only solution for implementing any loop of this kind at the moment is to create a single trial which will take care of executing some code in a loop. So you will have to make your two practice trials fit a single PennController trial, and run their code as part of a callback. Here is a possible implementation:

const launch = (audio,image1,image2,image3,image4) => [
    clear()
    ,
    newAudio(audio).play().wait()
    ,
    newSelector("select").log()
    ,
    newCanvas("images", 1270 , 610)
        .add( 260,   0, newImage(image1).size(270,270).css("border","solid 1px black").selector("select") )
        .add( 730,   0, newImage(image2).size(270,270).css("border","solid 1px black").selector("select") )
        .add( 260, 320, newImage(image3).size(270,270).css("border","solid 1px black").selector("select") )
        .add( 730, 320, newImage(image4).size(270,270).css("border","solid 1px black").selector("select") )
        .print()
    ,
    getSelector("select").wait().disable()
    ,
    newTimer(250).start().wait()
    ,
    getSelector("select").enable()
    ,
    clear()
]

newTrial(
    newButton("Start").print().wait().remove()
    ,
    newButton("launch").callback(
        ...launch("p1_aud_hp_sr.mp3","Bunny.png","Mouse.png","Cat.png","Dog.png")
        ,
        ...launch("p2_aud_hp_sr.mp3","Goose.png","Horse.png","Bear.png","Cat.png")
        ,
        getButton("Restart").print(),
        getButton("Proceed").print()
    )
    .click()
    ,
    newButton("Restart").callback( getButton("launch").click() ),
    newButton("Proceed").wait()
)

Jeremy