1

I'm writing an experiment in Psychopy Coder on Windows, Python 3.7.

I would like to present pictures from a local folder in a randomized order to the participant, basically iterating through that folder.

The problem is that because I have many pictures, I wouldn't like to create an ImageStim for every single pic. Also, the pics are in the same folder but with different filenames.

So how should I do this? Could somebody explain this to me please?

boggart96
  • 11
  • 1

1 Answers1

1

You could get a list of all the file names in your directory (see here: How do I list all files of a directory?). Then you could shuffle that list https://docs.python.org/3.5/library/random.html#random.shuffle . And then you could have a function that would loop through each of the images in that list one at a time. Something like for i in myimageList: ... visual.ImageStim(...image=i...) ... My ellipses mean that there are alot more specifics to add. As @ASHu2 suggests, if you give people some example code they may be able to suggest some fixes.

brittAnderson
  • 1,428
  • 11
  • 25