How to randomly select an image file from two separate condition files?

Hi all,

Let’s say I have 3 excel files. One with a long list of negative emotional images (emotional.xlsx), one with a long list of neutral images (neutral.xlsx) and a condition file (condition_file.xlsx).

In the condition file, I have a variable titled “image_type” and I would like it to randomly select an image from the neutral or emotional excel files.

In e-prime I used nested lists. What would be the best approach to do such a thing in psychopy?
I will also appreciate a solution that would work online.

Any ideas?


Do this with a single condition file, with two columns: image_type and image_file

Put all the neutral images first, followed by the negative ones (actually the order is unimportant, but it will make it easier for you to just paste in the blocks of file names, and auto fill the image types, if they are in consecutive blocks).

Set the “image” field of your image stimulus to be $image_file, and set it to update on every repeat.

Connect your loop to the conditions file and set the loop type to be random.

The first column isn’t used: it is just informational: having it just means that it ends up in your data file, to help with analysis.

Hi Noam,

Are you wanting to display a block containing one valence of image followed by a block of the other? If so, then that can easily be achieved by nested loops.

If you are trying to interleave the two lists, then you could use my Prospective Memory solution, which I’ve detailed here: PsychoPy Code Component Snippets - Google Docs

Randomised items should be done in a single list, as per @Michael 's post.

Ahh, yes, I just interpreted “I would like it to randomly select an image from the neutral or emotional excel files” as trial-by-trial random selection. Maybe the OP had something more complex in mind.