Set a condition for the randomisation of row content

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

OS (e.g. Win10):
PsychoPy version (e.g. 1.84.x): 3.2.4
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:
For a n-back task different letters (A, B, C, D, E) come one by one to the screen (using a text elements that refers to column ‘letters’ in an excel file, this column has on each row a different letter). The order of the letters is randomized using a loop that is defined as random). However, I want the number of times that a letter is the same as the previous letter (so for example B follows B, or C follows C) to be 33%.

What did you try to make it work?:
I have no idea how to do this. Is there for example a way to code that in 33% of the cases the ‘randomized’ row has to be shown twice in a row?


It sounds like you want a pseudorandom order. Pseudorandomisation is a feature not currently supported by PsychoPy, but is something we have discussed improving on and a future direction for sure.

For now, I would recommend pre-creating the condition files to be in the pseudorandom orders you want* and setting loop method to be ‘sequential’. If it is ok for all participants to be presented with the same pseudorandom order then you only need one conditions files. If you need a new order for each participant you will need a new conditions file for each and then in your loop the Conditions field would be something like $'conditionsFile'+expInfo['participant']+'xlsx'.

Hope this helps,

*I previously used the tool ‘Conan’ for my pseudorandomisation but I can’t seem to find the docs on that now - @jderrfuss might be able to provide a link to that though!

Conan! Boon and bane of days long past… I’ve taken this as an opportunity to contact my old institute to see if they’re happy with me sharing the script. Will update when I hear back, @Becca.


1 Like

Thanks Jan - I was curious if I dreamt of pseudoransomisation tools :joy:

Thanks @Becca
I would be interested to hear about this Conan tool…