Creating MiniBlocks from image Category

I have an experiment where participants see images belonging to one of three categories (A, B, or C). Currently, the images are being read from a CSV file; however, I would like to make it so that images are shown together in triplet minblocks (ex: image from category A, image from category A, image from category A). For instance if an image from category B is shown, the next 2 consecutive images should also be from Category B. Also, after an image is shown, they are removed from the pool of images that can be shown. To summarize, the first image of the triplet shown will always be chosen randomly from 1 of the 3 categories, but the following two images must be from the same category. Does anyone have experience doing this using the builder or code element?

Hello,
I created an example for it changes the text instead of the path of the image, but it should be straightforward to swap with the same logic.

Download:
3x3 Randomization.zip (15.2 KB)

Image of the flow:
Flow

Let’s start with the “Choose_Category” loop. It has the following spreadsheet:

image_1 image_2 image_3
Category 1, Image 1 Category 1, Image 2 Category 1, Image 3
Category 2, Image 1 Category 2, Image 2 Category 2, Image 3
Category 3, Image 1 Category 3, Image 2 Category 3, Image 3

Each row defines a different category, and each column defines another image out of the 3 (you can see I used text instead of paths in this example).
So when the experiment runs, it will have 3 conditions, one for category 1, one for category 2, and so on.

Now we are using the “Randomize” routine to shuffle our 3 images together with the following code:

# Begin Routine:
images_list = [image_1, image_2, image_3]
shuffle(images_list)

Now when we start the “Choose_Image” loop, we repeat the “display_image” routine 3 times.
Every repeat, we set a new value to the text component as the following:

$images_list[Choose_Image.thisRepN]

It should cover it. Let me know if something is unclear!
Let me know if it was your intention and if you successfully transformed it into paths.

Chen

Thanks for your response, this is very helpful! @Chen

One quick follow up:

  1. I have my CSV file organized so that the rows specify each category rather than the columns. And for each category (A, B, or C), two pairs of images (predetermined from CSV) will always appear on the screen at the same time, followed by the two consecutive pairings from the same category. Does the way the CSV is organized still work to present the categories as triplets?