Saving the stimuli that were randomly presented for later

Hello, I am trying to create a project where out of a list of letters in either blue or yellow it is randomized for the trial, which letters are presented in yellow or blue, but the same letter can only be presented once. It is first a trial of either only all the yellow or blue letters, then later on, I want to show these letters in that color again (in a later trial).

The letters are presented as picture-files and each color should be shown equally.

My Questions for this:

  1. How do I program it in a way, that it is random whether participants are shown either the blue or yellow group first?

  2. How do I make sure, each letter is only shown once in either one of the colors?

  3. How do I save, what letter was shown in which color so that I can shown them in al later trial again?

The study is supposed to run online.
I would be grateful for any helpful tips, as I am only starting using PsychoPy.

Thanks in advance.


I did not have any letters saved as images, so I implemented the experiment just with letters. This is the flow of the experiment

The code-component Begin experiment tab contains:

The code-component Begin routine tab contains:

and the text-component is set up as follows


The condition-file has a column named letter which contains the letters to be displayed. The condition file is run twice.

Best wishes Jens

1 Like

Thank you so much Jens, this is very helpful!
One more question though, if you don´t mind.
Is there a way to save the letters that were shown so that later on I can show the exact same one again or is that already implemented in the code and I just didn´t see that?

Best regards Annalena

Thank you JensBoelte

Your solution helps me a lot!!

And I have the same question as asichel
Is there a way for psychopy to save the used stimuli for later?

In my case, I have 160 sets of paired images, and I want to display one of the paired images in the first STUDY phase. Later, in the TEST phase, I will present both images and ask participants to select the one they saw in the previous phase.

This process requires Psychopy to save the first image as the “correct answer” for the TEST phase, and I’m still struggling to realize it :confused:

Again, thank you so much for your patience :slight_smile:

Best regards James


well, the letters are just read from the Excel-file, so you know which letters have been shown. Or do want to use only a part of the rows of the Excel-file?

Best wishes Jens


you create two routines following each other. In the first routine you show one picture of the pair, in the second routine you show both pictures.

Best wishes Jens