Randomize pictures of same category
Hi!
I'm programming an attentional task and I need some help.
The experiment has the following structure: distractor-target-response.
I have two different categories of distractors (food and neutral stimulus) and each one contains 40 pictures (food1, food2, ... / neutral1, neutral2, ...). The target can appear either the same position as the distractor (congruent trial) or the opposite position (incongruent trial).
I'm trying to make distractor images of same category appear randomized but I don´t know how to do it using javascript. I need them to follow the structure of the image.
Thank you so much for your help.
Comments
Hi @ireneruizp,
I'm not sure I understand your description, as your table does not contain an image variable. Your table already contains a fully orthogonal distractor x distractor_position x target_position design (2x2x2) and your table's "order" property is set to random, so this will generate a random presentation of the 8 trials in the table you posted to the forum.
I wonder whether what you mean is that there should be another variable containing the name of the image file and that you want the order of the image files randomized within the each distractor type (food/neutral). Is that what you mean?
You can achieve this by using code to store the image files in a memory array, shuffle that array, and then populate the loop's table on the fly as the trials run.
Coding can be achieved in Python or in Javascript, though if you plan to execute your experiment in a browser, you must use Javascript. You will find some example of this method used in the following posts (in Javascript), though in your case it would need to be adapted (see below):
In your case, as you have two categories of distractors (food and neutral), you'd have to create two arrays, shuffle both (this would be done before the loop), and then as the task run, you'd have to implement a counter that counts the number of trials of each type in order to pick the appropriate element in the appropriate array and use it to define the picture that should appear on the screen. So, say trial 23 is currently running: code in the trial sequence would check what condition we're currently in. Say it is the food distractor condition. The code would add 1 to the food trials counter. Let's say this is the 12th food trial so far. The code would then select the 11th element in the shuffled array of food picture filenames (11th because array start at 0, not at 1).
Hope this help. Let me know if you need further clarification or even load up your task so that I can take a look and suggest a more specific solution.
Good luck,
Fabrice.
PS: Are you planning to run this through OSWeb? (if you are, I might move this thread to the OSWeb forum)