PennController for IBEX › Forums › Support › Randomize blocks and trials but keep breaks in the same order
Tagged: randomize
- This topic has 7 replies, 3 voices, and was last updated 1 year, 6 months ago by ediachek.
-
AuthorPosts
-
March 11, 2023 at 9:20 am #10364ChlorisParticipant
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,
ChlorisMarch 13, 2023 at 12:01 pm #10371JeremyKeymasterHi Chloris,
Should
pause_1
always appear afterblock_1
regardless of whereblock_1
ends up, or should it always appear after the first block to run, regardless of whether that’sblock_1
,block_2
orblock_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
March 16, 2023 at 4:23 am #10398ChlorisParticipantHi Jeremy,
I indeed meant the latter one. The code works perfectly. Thanks a lot!
Boyin
May 17, 2023 at 2:51 pm #10599ediachekParticipantHi 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.
May 19, 2023 at 11:03 am #10601JeremyKeymasterHi 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 withrandomize(anyOf("trials_study","trials_test"))
. If you’d rather have them evenly shuffled, usershuffle("trials_study","trials_test")
Jeremy
May 19, 2023 at 11:23 am #10602ediachekParticipantHi 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
May 19, 2023 at 12:21 pm #10603JeremyKeymasterIn that case use two
randomize
s inseq
, like this:var blocks = [ seq(randomize("trials_study"),randomize("trials_test")), // ...
Jeremy
May 19, 2023 at 3:17 pm #10604ediachekParticipantThat woks great! Thank you!
-
AuthorPosts
- You must be logged in to reply to this topic.