Randomize blocks and trials but keep breaks in the same order

PennController for IBEX Forums Support Randomize blocks and trials but keep breaks in the same order

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #10364
    Chloris
    Participant

    Hi Jeremy,

    I’m building an experiment with 3 blocks and 2 breaks (pauses). I’m wondering if there’s a way to only randomize the blocks and within-block trials but keep the breaks in the same order. That is, pause_1 should always appear after the first block regardless of which block it is (and pause_2 after the second block). I checked this thread but it didn’t mention breaks.

    My current code only randomizes within-block trials:

    Sequence("consent", randomize("block_1"), "pause_1", randomize("block_2"), "pause_2", randomize("block_3"), "send", "completion")

    Thanks a lot!

    Best,
    Chloris

    #10371
    Jeremy
    Keymaster

    Hi Chloris,

    Should pause_1 always appear after block_1 regardless of where block_1 ends up, or should it always appear after the first block to run, regardless of whether that’s block_1, block_2 or block_3? Assuming you mean the latter, you can achieve it like this:

    var blocks = [randomize("block_1"),randomize("block_2"),randomize("block_3")];
    fisherYates(blocks);
    
    Sequence("consent", blocks[0], "pause_1", block[1], "pause_2", blocks[2], "send", "completion")

    Jeremy

    #10398
    Chloris
    Participant

    Hi Jeremy,

    I indeed meant the latter one. The code works perfectly. Thanks a lot!

    Boyin

    #10599
    ediachek
    Participant

    Hi Jeremy,

    I’m also trying to make an experiment with randomized blocks and this is super helpful! However, I have a few more questions.

    My each block will include study trials and test trials. Right now, these are 2 separate templates and I’m not sure how to unite them into 1 block. Here is what I have so far, I’d really appreciate your guidance!

    -Yev

    
    //Phase 1 Block 1: Study Trials [randomized in Sequence]
    Template("bell_bottoms_study_2AFC_1.csv", row =>
        newTrial("trials_study",
        
            newText("study_question","Click on the image as described in the audio")
                .center()
                .cssContainer({"margin-bottom":"1em"})
            ,
         
            //Load images
            newImage("target", row.target_filename),
            newImage("foil", row.foil_filename),
            
            //Load audio
            newAudio("audio", row.audio_file),
            
            //Display images
            newCanvas("image_study", 1000, 500)
                .add(0, "middle at 60%", getImage("target"))
                .add(550, "middle at 60%", getImage("foil") )
                .print()
                //.center()
                .log()
            ,
            
            //Play audio with instructions
            getAudio("audio")
                .play()
            ,
            
            //Allow to select
            newSelector("answer_study")
                .add(getImage("target"), getImage("foil"))
                .shuffle()
                .log()
                .wait()
            ,
            
            newTimer("post-trial", 1000).start().wait()
        )
    
    //Phase 2: Test Trials [randomized in Sequence]
    Template("bell_bottoms_test_2AFC.csv", row =>
        newTrial("trials_test",
        
            //Question
            newText("Which image did you see in the previous section of the study?").print().center().cssContainer({"margin-bottom":"1em"}),
    
            //Load images
            newImage("target", row.target_filename),
            newImage("distractor", row.distractor_filename),
        
            newSelector("answer_test"),
        
            //Display images
            newCanvas("image_study", 1000, 500)
                .add(0, "middle at 60%", getImage("target"))
                .add(500, "middle at 60%", getImage("distractor") )
                .print()
                //.center()
                .log()
            ,
            
            //Allow to select
            newSelector("answer_study")
                .add(getImage("target"), getImage("distractor"))
                .shuffle()
                .log()
                .wait()
        )
    • This reply was modified 1 year, 7 months ago by ediachek.
    #10601
    Jeremy
    Keymaster

    Hi Yev,

    If your first block consists of all the trials labeled “trials_study” and those named “trials_test” and you want them randomly (unevenly) shuffled, you could replace randomize("block_1") from the code above with randomize(anyOf("trials_study","trials_test")). If you’d rather have them evenly shuffled, use rshuffle("trials_study","trials_test")

    Jeremy

    #10602
    ediachek
    Participant

    Hi Jeremy,

    Thank you for your response and I’m sorry, I still have a question. Let me rephrase my issue.

    Each one of my 4 blocks includes study trials and test trials. I would like the 4 blocks to be randomized across participants, and the trial order within each block to be randomized as well. However, test trials for block 1 should always follow study trials for block 1 because participants can only do a memory test on the items they have already studied. So possible orders of presentation would be:

    [“study_trials_2″,”test_trials_2″,”study_trials_4″,”test_trials_4″,”study_trials_1″,”test_trials_1″,”study_trials_3″,”test_trials_3”]

    OR

    [“study_trials_1″,”test_trials_1″,”study_trials_3″,”test_trials_3″,”study_trials_4″,”test_trials_4″,”study_trials_2″,”test_trials_2”]

    etc.

    I was hoping to achieve this by just grouping study and test trials together into one variable “block” but not sure how to achieve that. I might also be missing another solution, so I would appreciate your advice!

    Thanks again for all your help!

    -Yev

    #10603
    Jeremy
    Keymaster

    In that case use two randomizes in seq, like this:

    var blocks = [
      seq(randomize("trials_study"),randomize("trials_test")),
      // ...
    

    Jeremy

    #10604
    ediachek
    Participant

    That woks great! Thank you!

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