| Reference | Downloads | Github

Independent randomisation of parameters in PsychoPy?


I’m building an experiment which requires presentation of two images within a routine, side-by-side. One image is a target (i.e. correct response) and the other is a foil. I have an excel stimuli sheet with all the necessary picture files, target stimuli in one column and foil stimuli in another, however I would like the appearance of foil pictures to be fully random. At present, PsychoPy reads out each row such that the same target image is always paired with the same foil. Is there any way around this? Perhaps with the use of a code component?



Hi Lyam. There are two approaches to this. One does all the shuffling completely in code, the other actually reads in your conditions file, shuffles it, and writes it back to disk. The first is feasible (and possibly more flexible) if the number of variables and levels is small, the second more useful if the number of levels is large.

Can you list your variables and their levels?


Hi Michael

I have 2 variables, each with 2 levels:

  1. Correct response (one picture matches a previously presented word [i.e. is correct], the other does not)
  2. Position on X axis (one picture appears on the left, the other on the right) - note: this is randomised using a code component

My experiment as a whole includes other variables but these are in separate routines so I haven’t included them here



Hi Lyam and Michael,

Can you suggest a solution to this problem? I’m having a similar issues - I have a master file and would like randomise 2 different variables independently, because at the moment they are tied together. I think one way to do it without coding would be to create a separate excel file for the second variable, but I don’t know how to refer to an excel file when defining an image (which is what the variable is).
Altrnatively, can you suggest how to deal with this problem using code component?



Hi there,

Take a look at this thread:

It’s not quite the same problem but the solution provided in the above thread SHOULD be helpful.