# How to randomly select images

**URL:** <https://discourse.psychopy.org/t/how-to-randomly-select-images/18746>\
**Category:** Builder\
**Tags:** randomization\
**Created:** [December 7, 2020, 3:54am UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746 "2020-12-07T03:54:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rachmaninoff](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rachmaninoff/32/12757_2.png) [@Rachmaninoff](https://discourse.psychopy.org/u/Rachmaninoff)\
**Post date:** [December 7, 2020, 3:54am UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746/1 "2020-12-07T03:54:35Z")

</div>

I am a second-grade student and were asked to design a simple experiment.  
The picture shows the outline of my experiment.  
What I need is to randomly select one image at a time from picture1, 2, 3, 4 and provide it to subjects.  
Next is to provide another image from pictures that remain. and so on… until the last image is presented. (no repeating image)

 ![JE{USU7(H9_DT51AN@HWQ](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/6/e6528dfe0011c03e68808e8059850936a746652c.png)

My question is, I can’t even select images randomly… 😭 although I did try

 ![two](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/b/ab01c9a97728d9a1cb17f514953c4c809205f983.png)  
I inserted a loop and set the “looptype” as random, but it didn’t work.  
I guess I should use the “Conditions”, but I just can’t put a file in it.  
So I guess some type of coding should be used here, which is absolutely beyond my knowledge. 😭

Maybe it’s a simple question for most of people, but it really crashes me…  
Really wish somebody could offer me some help 😭

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [December 7, 2020, 10:39am UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746/2 "2020-12-07T10:39:55Z")

</div>

Hello,

set up a csv. or Excel-file and load that via the browse button. In the Excel specify the pictures (with path) that you like to show.

BTW, if you press the help-button on the lower-left corner this will take you to a [help-page](https://www.psychopy.org/builder/flow.html#loops) on which the process is described.

Best Jens

---

<div class="post-metadata">

**Author:** ![Rachmaninoff](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/rachmaninoff/32/12757_2.png) [@Rachmaninoff](https://discourse.psychopy.org/u/Rachmaninoff)\
**Post date:** [December 7, 2020, 12:05pm UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746/3 "2020-12-07T12:05:52Z")

</div>

first of all, thank you for your sincere reply. I am so happy to get my first reply in this unfamiliar world.  
I’ve followed your advice and tried to set up a csv. or Excel-file, but unfortunately it didn’t work.  
Here’s the information I’ve got when I tried to load the Excel-file format.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/d/7/d77bdb046c6721392123a1839d3f0a45609ebebe.jpeg)

 ![A`48${91EE0{((VN}%GG74](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/f/efe326d2c23b7b1b6d5dee4d48177199cafbe1f9.png)  
And when I tried to load it as a csv. format, it informed me that some of the functions might get lost if I save it this way. and images did get lost if I did that.

i feel like I am a idot… just hoping to get your reply sooner 😭

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [December 7, 2020, 12:43pm UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746/4 "2020-12-07T12:43:13Z")

</div>

Hello,

You can’t load the images in your Excel-file. You need the filename of an image!. PsychoPy uses this as a pointer to your images.  
Set up a folder called **stim** in experiment folder, copy all you images in this folder. Then set up an Excelfile with with at least one columns containing the filenames including extensions of your images. Pick a column heading, e.g. stimulus. For example, you have the images, picture1.jpg, picture2.jpg i nthe folder stim aso. Your Excel looks like

stimulus  
stim/picture1.jpg  
stim/picture2.jpg

aso.

Use this Excelfile as a your **Conditions**.

You would really benefit from reading the documentation or even the book “Building Experiments in PsychoPy”. 😉 That prevents feeling like an idiot, at least sometimes.

Best jens

---

<div class="post-metadata">

**Author:** ![severinm18](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@severinm18](https://discourse.psychopy.org/u/severinm18)\
**Post date:** [November 28, 2024, 3:07pm UTC](https://discourse.psychopy.org/t/how-to-randomly-select-images/18746/5 "2024-11-28T15:07:07Z")

</div>

Additionally, setting the referred to variable in the csv file to “set every repeat” instead of “constant” might be necessary. At least it was for me.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/c/2c093bda6bc4d5ab46c46a288ce5f43e7a32c2eb.png)
