Independet randomization with no repetition

Hey everyone!

I´m using version 2021.2.3
In my experiment I present 24 videos and in the background there is either no music, fasgt music or slow music. So I have a excel file with two parameters (videostim, musicstim). I have no prior experience with PsychoPy or Python, so I would appreciate simple code solutions.

What I´ve tried:
I´ve created a code snippet based on the video from Jason Ozubko on how to randomize two lists of stimuli and also oriented on this forum post Import and display images and words from a mixted Excel file (images are not displayed) from Romane.
I applied the code to my experiment. (see screenshots below)
(Unfortunately the suggestion to look at the Demo for independent randomization didn´t help, because the python coding is to complicated for me to implement that in my experiment)

Problem:
I can run the experiment on Psychopy without problems (there are 24 trials as wished) and the randomization almost works but there are always around 5 repetitions of pictures, eventhough all of the 24 pictures should appear just once.
Also in the Runner tab there is a error presented that might be the source of the problem (see below). I think it referes to the “import random” part in the JS section.
Is “import random” outdated or should it technically work? Or does someone know a easier way to do this?

It would be very much appreciated if someone could help me! Tank you!





Did you change the nReps setting in your loop from the default value of 5 to your desired value of 1?

It isn’t the source of the repetition problem.

This other problem is because you have the code component set to auto-translate to Javascript so that the experiment could also run online. There is no need to do that if you aren’t running online, and this automatic translation can’t work magic with custom code. If you are only running the experiment locally, set your code component to Py only, or if you want to provide your own manual translation for running online, set it to Both.

Hey Michael,
thank you for your answer.

  1. In the nReps setting I typed in “n_items” like described in the video. If I type in 1 then only one video+music is presented. If I type in 24, it´s the same as $n_items (still includes some repeated pictures)

  2. I also have to run the experient online so I need the auto-translate to Javascript.