# Randomising without repeats across blocks in builder for a Pavlovia experiment

**URL:** <https://discourse.psychopy.org/t/randomising-without-repeats-across-blocks-in-builder-for-a-pavlovia-experiment/35118>\
**Category:** Builder\
**Tags:** randomization, online, pavlovia\
**Created:** [May 30, 2023, 12:16pm UTC](https://discourse.psychopy.org/t/randomising-without-repeats-across-blocks-in-builder-for-a-pavlovia-experiment/35118 "2023-05-30T12:16:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TZak](https://avatars.discourse-cdn.com/v4/letter/t/9e8a1a/32.png) [@TZak](https://discourse.psychopy.org/u/TZak)\
**Post date:** [May 30, 2023, 12:16pm UTC](https://discourse.psychopy.org/t/randomising-without-repeats-across-blocks-in-builder-for-a-pavlovia-experiment/35118/1 "2023-05-30T12:16:58Z")

</div>

**OS** (e.g. Win10): Win10  
**PsychoPy version** (e.g. 1.84.x): Psychopy 2022.2.4  
**Standard Standalone? (y/n)** y  
**What are you trying to achieve?:**  
I have written a program in builder to run via Pavlovia, which works fine, other the randomisation that I would like it to have.  
The program is a learning task, which presents a stimulus (e.g. a square with a dot in the middle) followed by an outcome (a different face with a neutral, negative, or positive expression). I have three distinct stimuli, each associated with either neutral, negative, or positive expressions. I would like to present each stimulus/expression pairing randomly and repeat this 16 times, but repeating without replacement - for example the order could be N - Neg - Pos - Neg - Pos - N, but NOT N - Neg - Pos - Pos - Neg - N.

**What did you try to make it work?:**  
To achieve this, I have three loops around these learning trials in builder, following this advice: [https://www.psychopy.org/builder/blocksCounterbalance.html](https://www.psychopy.org/builder/blocksCounterbalance.html)

 ![Learning_program_builder](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/5/35a43a48d07fd847c5ca5283393622b5f074c670.png)

The outer most loop, “randomisation\_of\_files”, loops through conditions file “RandFile\_v1” which contains a “condsFile” column. The loop selects one mapping file (e.g. "Mapping1.xlsx; for simplicity, I only have the one possible option for now, but eventually there will be 6). This mapping file points to a file which assigns the type of stimulus (e.g. square or circle) to each expression type (neutral, negative positive).

![Randomisation_of_files_loop](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/1/1/11d29be9a258dd2131e38a0203360feb7fdacd8a.jpeg)  
 ![RandFile_v1](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/6/5648643aaa89bae0b779822a86707d1af2686167.png)

The middle loop, “blocks\_rand”, loops through a conditions file which the outer loop has selected - currently “Mapping1.xlsx”. This file contains two columns. The first column, “Emotion\_cat” points to three files, one for neutral, one for negative, and one for positive images (N1.xlsx. Neg1.xlsx, Pos1.xlsx). The second column, “stimulus\_file” assigns the stimulus image (e.g. a square, “GenStimA\_1.jpg”). This file is supposed to randomise the order of the expression presentation.

![blocks_rand_loop](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/3/e/3eb0d167910dba38c0a9263dd03e2bed241e5cca.png)

 ![Mapping1_file](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/0/c0ec22c72d592b6eab66d1a3235d73811ae00dbe.png)

The inner most loop, “trials”, cycles through the files which contain the outcome images and text, e.g. the 16 neutral images contained within “N1.xlsx” file.

![trials_loop](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/e/1/e1f9e2900a4a84651d99cc7e40d07fca380e7f90.png)

 ![N1_file](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/3/83c0efc5f07eb71a56201282c83d31a6cbe35f62.png)

**What specifically went wrong when you tried that?:**  
The program is working file and I do not get errors, but currently I only get repeated trials. The program appears to randomly choose neutral, negative, or positive images, and then presents all of them in a row. For example, it presents all positive images, followed by all neutral, followed by all negative, despite nReps being 1 at each of my loops.

I have read forum posts trying to achieve something similar, but in all cases I have seen, coding had to be used. However, I am new to coder and I was not sure how to adapt the code to my experiments. I am hoping there is a way to achieve what I need to within builder. Any help/pointers would be much appreciated.

---

<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:** [May 30, 2023, 1:18pm UTC](https://discourse.psychopy.org/t/randomising-without-repeats-across-blocks-in-builder-for-a-pavlovia-experiment/35118/2 "2023-05-30T13:18:03Z")

</div>

Hello

**nReps** refers to the number of repetitions of the conditions-file. You want pseudo-randomization and that can only be achieved via code.

Best wishes Jens
