Randomization a subset of stimuli within builder

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10):
Windows 11
PsychoPy version (e.g. 1.84.x):
2023.1.2
**Standard Standalone? yes
What are you trying to achieve?
It is an experiment on visual memory testing (VSMT)2023-07-15T22:00:00Z
In a first step I am trying to present a subset of 4 stimuli randomized out of 10 target, later on the shuffed subsets are to assign to randomized foils:

I am wondering if there is a solution within builder or do I have to use Python Code?
I have no knowledge of any coding (Python etc.) so far.

Hello PsychoBen

you need some code to achieve this. Here the flow of a toy-experiment that presents numbers read from a condition-file.

Add the following code to the Begin Experiment tab:

useRows = list(range(0,10))
shuffle(useRows)

Set up the loop definition as follows:

Best wishes Jens

1 Like

Thank you so much for your advice.So, it is obviously necessary to implement a coder component.
I´m still struggling with 3 issues:

  1. How should I transfer the stimuli (1/f-noise-stimuli) into an Excel-conditions file?
  2. How to randomly assign the foils (60 stimuli) to the beforehand chosen 4 targets?
  3. Do I need special names for the Excel-filled stimuli: could I use the like foil/60.jpeg, foil/59.jpeg etc., target/10.jpeg, target/9.jpeg , inserting them all manually?
    I came across so-called Python modules like random.sample, random.choice … Schould I keep better at bay of this… due to my missing know-how… or would you recommend some code snippets as well?
    Examples of Foils, from one of the 3 subsets (with rsp. 3 exponents -0.5, -1, -1.5)



    Many thanks in advance.
    Ben

Hello Ben

How should I transfer the stimuli (1/f-noise-stimuli) into an Excel-conditions file?

Just give the filename of the corresponding stimulus. See your point 3. And yes, if you are using an Excel file as a conditions file, you will have to type them in, or you could use Excel to generate them for you (create the numbers 1:n by dragging the lower left corner of a selection of two cells, one containing 1, the other containing 2, then use the concatenate function to add the folder name and extension).

Ok, you need independent randomisation. You might want to take a look at

If you are not planning to run the experiment online, you can import any Python library you need. Otherwise, do not use Python libraries. PsychoPs is automatically compiled into PsychoJS for online experiments. There may be no JavaScript equivalent for the imported Python library.

Best wishes Jens

1 Like

The simpliest solution for my first issue (choosing randomly x rows out of n >x) is just using numpy that is a built-in module of Psychopy itself! Just inserting 0:x in the selected rows field of the loop dialog ! So be aware of not inserting 0:x-1.