| Reference | Downloads | Github

Is it possible to use a list of file paths as the input for an image component?

Hi, I am very new to PsychoPy so apologise if I ask this question badly!

I am building an experiment in builder view using PsychoPy version 1.85.2. It is made up of two trials.

Using the code component I have written a piece of code which produces a list of file paths for images to which the participant responded fastest. When I print the list it looks like this:

[u’FileName\\ImageName1.jpg’, u’FileName\\ImageName3.jpg, u’FileName\\ImageName7.jpg’, etc]

I was planning on using this list as the input for my image component in my second trial but PsychoPy does not seem to recognise these strings as file paths in this format. Is there anyway that I can edit this list so that it can be used in this way? Or alternatively tell PsychoPy to expect a list of file paths.

Thanks in advance!

@Nick, what is the error message that you get? ~If you are presenting your images in the second part of your experiment in a loop, then the following should work. Assuming your loop in your second part of the experiment is trials2, and has a code and image component, in the code component:

# Begin Routine tab
image.setImage(yourFileList[trials2.thisTrialN])  # where image is name of your image component

Thanks! Is thisTrialN the name of the trial? I’ll post my error message tomorrow when I’m back at my computer.



@Nick, it is the number of the trial - see docs.

Thanks! I found that. I should have updated sorry. Unfortunately all I’m getting is a white square instead of the image

Ok, I think that the image is not being set correctly. Can I please take a look at your psyexp file?