Mixing fillers and items

PennController for IBEX Forums Support Mixing fillers and items

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5197
    angelica
    Participant

    Hi Jeremy,

    My experiment has 4 groups of experimental items (A, B, C, D; 20 items each) and 1 group of fillers (20 items). I’d like a participant to see one group of experimental items and all of the fillers (40 items total).

    The design: for each item/trial, the participant sees a target word and hears a sentence, pressing the spacebar if they hear the target word. Some sentences are followed by comprehension questions.

    I currently have two templates that are identical, but one takes items from “test_items” and one takes items from “test_fillers” (these are shortened tables just for testing; the rest of the items are in .csv files). This works, but I find it a little clunky to have two basically identical large chunks of code. Is there a better way to do this? I thought that maybe I could name a template and then do something like getTemplate() with a different table as input, but I’m not sure this is possible.

    PennController.ResetPrefix(null);                       
    
    Sequence(shuffle(randomize("items"), randomize("fillers")))
    
    // experimental items for testing
    AddTable( "test_items" ,
        "group,item,cond2,stimulus,target,sentence,question,answer_1,answer_2,correct\n"+
    	"A,1,Clash.NoShift,SC_Clash_NoShift_1.wav,target_1_A,question_1_A,WHERE DID THE MEN STOP?,THE DOLLAR STORE,THE CONSTRUCTION SITE,answer_1\n"+
    	"B,1,Clash.Shift,SC_Clash_Shift_1.wav,target_1_B,question_1_B,WHERE DID THE MEN STOP?,THE DOLLAR STORE,THE CONSTRUCTION SITE,answer_1\n"+
    	"C,1,NoClash.NoShift,SC_NoClash_NoShift_1.wav,target_1_C,question_1_C,WHERE DID THE MEN STOP?,THE DOLLAR STORE,THE CONSTRUCTION SITE,answer_1\n"+
    	"D,1,NoClash.Shift,SC_NoClash_Shift_1.wav,target_1_D,question_1_D,WHERE DID THE MEN STOP?,THE DOLLAR STORE,THE CONSTRUCTION SITE,answer_1\n"+
    	"B,2,Clash.NoShift,SC_Clash_NoShift_2.wav,target_2_B,question_2_B,,,,\n"+
    	"C,2,Clash.Shift,SC_Clash_Shift_2.wav,target_2_C,question_2_C,,,,,\n"+
    	"A,2,NoClash.NoShift,SC_NoClash_NoShift_2.wav,target_2_A,question_2_A,,,,,\n"+
    	"D,2,NoClash.Shift,SC_NoClash_Shift_2.wav,target_2_D,question_2_D,,,,,\n"+
    	"C,3,Clash.NoShift,SC_Clash_NoShift_3.wav,target_3_C,question_3_C,WAS THE MEAL EXPENSIVE?,YES,NO,answer_1\n"+
    	"D,3,Clash.Shift,SC_Clash_Shift_3.wav,target_3_D,question_3_D,WAS THE MEAL EXPENSIVE?,YES,NO,answer_1\n"+
    	"B,3,NoClash.NoShift,SC_NoClash_NoShift_3.wav,target_3_B,question_3_B,WAS THE MEAL EXPENSIVE?,YES,NO,answer_1\n"+
    	"A,3,NoClash.Shift,SC_NoClash_Shift_3.wav,target_3_A,3_A,WAS THE MEAL EXPENSIVE?,YES,NO,answer_1\n"+
    	"D,4,Clash.NoShift,SC_Clash_NoShift_4.wav,target_4_D,question_4_D,,,,,\n"+
    	"A,4,Clash.Shift,SC_Clash_Shift_4.wav,target_4_A,question_4_A,,,,,\n"+
    	"C,4,NoClash.NoShift,SC_NoClash_NoShift_4.wav,target_4_C,question_4_C,,,,,\n"+
    	"B,4,NoClash.Shift,SC_NoClash_Shift_4.wav,target_4_B,question_4_B,,,,,"
    );
    
    // filler items for testing
    AddTable( "test_fillers" ,
    	"item,cond2,stimulus,target,sentence,question,answer_1,answer_2,correct\n+"+
    	"1,filler,filler.wav,filler_1,,,,,n+"+
    	"2,filler,filler.wav,filler_2,,,,,\n+"+
    	"3,filler,filler.wav,filler_3,,,,,\n+"+
    	"4,filler,filler.wav,filler_4,,,,,\n+"+
    	"5,filler,filler.wav,filler_5,,,,,\n+"+
    	"6,filler,filler.wav,filler_6,,,,,"
    );
    
    // experimental item trial 
    PennController.Template("test_items", 
        variable => PennController("items",
            defaultText
                .center()
            ,
            
            // Display target word 
            newText("listen_for", "Listen for:")
                .settings.css({"width": "300px"})
                .italic()
            ,
            newText("target_word", variable.target)
                .settings.css({"font-size": "200%", "width": "300px"})        
            ,
            newText("next", "Press the spacebar to continue.")
                .settings.css({"width": "300px"})
                .italic()
            ,
            newCanvas(300, 300)
                .add(0, 100, getText("listen_for"))
                .add(0, 150, getText("target_word"))
                .add(0, 250, getText("next"))
                .print()
            ,
            newKey(" ")
                .wait()
            ,
            clear()
            ,
            
            // Play audio stimulus and record reaction time
            newImage("fixation_cross", "fixation_cross.png")
                .size(300, 300)
            ,
            newCanvas(300, 300)
                .add(0, 0, getImage("fixation_cross"))
                .print()
            ,
            newKey("reaction_time", " ")                   
                .log("all")                                 
            ,
            newAudio("stimulus", variable.stimulus)
                .play()
                .wait() 
            ,
        	clear()
            ,
            
            // Comprehension question
            (variable.question?[newText("question", variable.question)
                .settings.cssContainer({"width": "600px", "font-size": "150%", "height": "50px"})
            ,
            newText("answer_1", variable.answer_1)
                .settings.cssContainer({"width": "300px"})
            ,
            newText("answer_2", variable.answer_2)
                .settings.cssContainer({"width": "300px"})
            ,
            newCanvas(600, 300)
                .add(0, 150, getText("question"))
                .add(0, 200, getText("answer_1"))
                .add(300, 200, getText("answer_2"))
                .print()
            ,
            newKey("FJ")
                .wait()
                .log()
            ]:null)
        )
        .log("group",       variable.group)
        .log("item",        variable.item)
        .log("condition",   variable.cond2)
        .log("target",      variable.target)
        .log("correct",    	variable.correct)
    
    );
    
    // Filler item trial 
    PennController.Template("test_fillers",
        variable => PennController("fillers",
            defaultText
                .center()
            ,
            
            // Display target word 
            newText("listen_for", "Listen for:")
                .settings.css({"width": "300px"})
                .italic()
            ,
            newText("target_word", variable.target)
                .settings.css({"font-size": "200%", "width": "300px"})        
            ,
            newText("next", "Press the spacebar to continue.")
                .settings.css({"width": "300px"})
                .italic()
            ,
            newCanvas(300, 300)
                .add(0, 100, getText("listen_for"))
                .add(0, 150, getText("target_word"))
                .add(0, 250, getText("next"))
                .print()
            ,
            newKey(" ")
                .wait()
            ,
            clear()
            ,
            
            // Play audio stimulus and record reaction time
            newImage("fixation_cross", "fixation_cross.png")
                .size(300, 300)
            ,
            newCanvas(300, 300)
                .add(0, 0, getImage("fixation_cross"))
                .print()
            ,
            newKey("reaction_time", " ")                    
                .log("all")                                 
            ,
            newAudio("stimulus", variable.stimulus)
                .play()
                .wait() 
        	,
        	clear()
            ,
            
            // Comprehension question
            (variable.question?[newText("question", variable.question)
                .settings.cssContainer({"width": "600px", "font-size": "150%", "height": "50px"})
            ,
            newText("answer_1", variable.answer_1)
                .settings.cssContainer({"width": "300px"})
            ,
            newText("answer_2", variable.answer_2)
                .settings.cssContainer({"width": "300px"})
            ,
            newCanvas(600, 300)
                .add(0, 150, getText("question"))
                .add(0, 200, getText("answer_1"))
                .add(300, 200, getText("answer_2"))
                .print()
            ,
            newKey("FJ")
                .wait()
                .log()
            ]:null)
        )
        .log("group",       variable.group)
        .log("item",        variable.item)
        .log("condition",   variable.cond2)
        .log("target",      variable.target)
        .log("correct",    	variable.correct)
    
    );

    Thank you in advance!

    Best,
    Angelica

    #5198
    angelica
    Participant

    (Forgot to mention this in the original post, sorry!)

    I also thought about modifying the input table such that each of the 4 experimental groups also contains all of the fillers (A: 20 items + 20 fillers, B: 20 items + 20 fillers, C: 20 items + 20 fillers, D: 20 items + 20 fillers), but I think this also relies on a lot of copy-paste.

    #5199
    Jeremy
    Keymaster

    Hi Angelica,

    You can always use regular javascript alongside PennController commands. So you can do this:

    customTrial = label => variable => newTrial( label ,
        defaultText
            .center()
        ,
        // Display target word 
        newText("listen_for", "Listen for:")
            .css({"width": "300px"})
            .italic()
        ,
        newText("target_word", variable.target)
            .css({"font-size": "200%", "width": "300px"})        
        ,
        newText("next", "Press the spacebar to continue.")
            .css({"width": "300px"})
            .italic()
        ,
        newCanvas(300, 300)
            .add(0, 100, getText("listen_for"))
            .add(0, 150, getText("target_word"))
            .add(0, 250, getText("next"))
            .print()
        ,
        newKey(" ")
            .wait()
        ,
        clear()
        ,
        // Play audio stimulus and record reaction time
        newImage("fixation_cross", "fixation_cross.png")
            .size(300, 300)
        ,
        newCanvas(300, 300)
            .add(0, 0, getImage("fixation_cross"))
            .print()
        ,
        newKey("reaction_time", " ")                   
            .log("all")                                 
        ,
        newAudio("stimulus", variable.stimulus)
            .play()
            .wait() 
        ,
    	clear()
        ,
        // Comprehension question
        (variable.question?[newText("question", variable.question)
            .cssContainer({"width": "600px", "font-size": "150%", "height": "50px"})
        ,
        newText("answer_1", variable.answer_1)
            .cssContainer({"width": "300px"})
        ,
        newText("answer_2", variable.answer_2)
            .cssContainer({"width": "300px"})
        ,
        newCanvas(600, 300)
            .add(0, 150, getText("question"))
            .add(0, 200, getText("answer_1"))
            .add(300, 200, getText("answer_2"))
            .print()
        ,
        newKey("FJ")
            .wait()
            .log()
        ]:null)
    )
    .log("group",       variable.group)
    .log("item",        variable.item)
    .log("condition",   variable.cond2)
    .log("target",      variable.target)
    .log("correct",    	variable.correct)

    Then you can use it like this:

    // experimental item trial 
    Template("test_items", customTrial("items") )
    
    // Filler item trial 
    Template("test_fillers", customTrial("fillers") )

    Jeremy

    #5200
    angelica
    Participant

    Hi Jeremy,

    This worked perfectly, thank you!

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