Multiple trial repetition

PennController for IBEX Forums Support Multiple trial repetition

This topic contains 6 replies, has 2 voices, and was last updated by Avatar Farzaneh 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #5575
    Avatar
    Farzaneh
    Participant

    Hi Jeremy,
    I’m trying to create an examiner prompt page right after two practice trials where participants select between “Repeat Practice” and “Move to experimental trials”. I’m not sure how to incorporate the two trials within a loop after clicking on repeat practice. I appreciate any suggestions you may have. This is a short version of my current script:

    //practice # 1
    let launch1 = [
        
        getAudio("p1_aud_hp_sr.mp3").play().wait()
        ,
        getImage("one").size(270,270).css("border", "solid 1px black")
        ,
        getImage("two").size(270,270).css("border", "solid 1px black")
        ,
        getImage("three").size(270,270).css("border", "solid 1px black")
        ,
        getImage("four").size(270,270).css("border", "solid 1px black")
        ,
        getCanvas("images")
           .settings.add( 260 , 0, getImage("one") )
           .settings.add( 730 , 0 , getImage("two") )
           .settings.add( 260 , 320, getImage("three") )
           .settings.add( 730 , 320 , getImage("four") ).print()
        ,
        newTimer(250).start().wait()
        ,
        getSelector("select").enable()
    ];
    newTrial(
    
        newAudio("p1_aud_hp_sr.mp3"),
        newImage("one", "Bunny.png"),
        newImage("two", "Mouse.png"),
        newImage("three", "Cat.png"),
        newImage("four", "Dog.png")
        ,
        newCanvas("images", 1270 , 610)
        ,
        newSelector("select")
    	   .settings.add(getImage ("one"), getImage ("two"), getImage ("three"), getImage ("four")).settings.log().wait().settings.disableClicks());
        
    //practice # 2
    let launch2 = [
    
        getAudio("p2_aud_hp_sr.mp3").play().wait()
        ,
        getImage("one").size(270,270).css("border", "solid 1px black")
        ,
        getImage("two").size(270,270).css("border", "solid 1px black")
        ,
        getImage("three").size(270,270).css("border", "solid 1px black")
        ,
        getImage("four").size(270,270).css("border", "solid 1px black")
        ,
        getCanvas("images")
           .settings.add( 260 , 0, getImage("one") )
           .settings.add( 730 , 0 , getImage("two") )
           .settings.add( 260 , 320, getImage("three") )
           .settings.add( 730 , 320 , getImage("four") ).print()
        ,
        newTimer(250).start().wait()
        ,
        getSelector("select").enable()
    ];
    newTrial(
    
        newAudio("p2_aud_hp_sr.mp3"),
        newImage("one", "Goose.png"),
        newImage("two", "Horse.png"),
        newImage("three", "Bear.png"),
        newImage("four", "Cat.png")
        ,
        newCanvas("images", 1270 , 610)
        ,
        newSelector("select")
    	   .settings.add(getImage ("one"), getImage ("two"), getImage ("three"), getImage ("four")).settings.log().wait().settings.disableClicks());
    	
    //select "repeat practice" or "move to experiment"
        newImage("rep", "Repeat.png").center().print(),
        newImage("exp", "Experimental.png").center().print(),
        newSelector("choice")
            .add(getImage ("rep"), getImage ("exp") )
            .keys ("F", "J")
            .log()
            .wait(
                getSelector("choice").test.selected( getImage("exp") )
                .failure( 
                    getSelector("choice").disable()
                )
        );

    Thank you!

    Farzaneh

    #5576
    Jeremy
    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

    #5590
    Avatar
    Farzaneh
    Participant

    Thanks for your response. The solution works great. I have a follow-up question. When the second trial starts, the canvas seems to get doubled in size and I have to scroll down to see the images although there’s both a .clear () and a .remove () command in the script that should’ve removed the canvas from the first trial. Do you have any idea why this happens?

    Farzaneh

    #5591
    Jeremy
    Jeremy
    Keymaster

    Which version of PennController are you using? There was a bug until 1.7 where Canvas elements wouldn’t properly get removed from the page

    Jeremy

    #5592
    Avatar
    Farzaneh
    Participant

    I haven’t installed any PennController version; I just use the Ibex Farm directly.

    Farzaneh

    #5593
    Jeremy
    Jeremy
    Keymaster

    By Ibex Farm, do you mean the PCIbex Farm at https://expt.pcibex.net or the original Ibex Farm at https://spellout.net/ibexfarm? PennController comes pre-installed on the former, but not on the latter

    In any case, it won’t hurt to install/update to the latest version of PennController. On either farm, just follow the instructions on this page and your project will import PennController 1.8

    Jeremy

    #5594
    Avatar
    Farzaneh
    Participant

    Yes, I meant the PCIbex Farm. Sure, will do.

    Thank Jeremy,

    Farzaneh

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.