Description of the problem: Hey all, I’m trying to create an experiment that shows different sets of images. There are 5 positive images and 5 negative images. So far, I have 2 different Excel files. One Excel file has the positive images, and the other has the negative images. How do I get it to randomize the spreadsheets so that it will show all 5 negative images first and then the 5 positive ones? Then, when ran again, it has the chance to show the positive images first, followed by the negative.
Hello
Does this apply to the same participant or is it between participants? If it is between participants, you could make the order of positive - negative dependent on the participant ID.
Best wishes Jens
This may help
Hey Jens
It just needs to be completely randomized between participants. It will only show both sets of images and that’s it but I need to be randomized in which is shows wether that’s positive first then followed by negative or vice versa.
Best,
Jacob
Hello @Jacob_Kachur
Create a code-component before your trial-loop is accessed and paste the following code in a Begin Experiment tab.
index1 = []
index2 = []
if int(expInfo['participant']) % 2 == 0:
index1.extend(range(0,3))
index2.extend(range(3,6))
shuffle(index1)
shuffle(index2)
else:
index2.extend(range(0,3))
index1.extend(range(3,6))
shuffle(index1)
shuffle(index2)
index1.extend(index2)
Specify the Selected row* parameter in your trial loop.
Do you plan to run the experiment online? If so, set the code-component to both and paste the following code to the PsychoJS-side
index1 = [];
index2 = [];
if (((Number.parseInt(expInfo["participant"]) % 2) === 0)) {
index1 = Array.from({length: 3}, (e, i) => i);
index2 = Array.from({length: 3}, (e, i) => i + 3);
util.shuffle(index1);
util.shuffle(index2);
} else {
index2 = Array.from({length: 3}, (e, i) => i);
index1 = Array.from({length: 3}, (e, i) => i + 3);
util.shuffle(index1);
util.shuffle(index2);
}
index1.push(...index2);
The toy-experiment uses one Excel file with positive and negative stimuli in separate rows. In this example, there are only three rows of positive and three rows of negative stimuli. Adapt the number of lines to your needs.
Best wishes Jens