psychopy.org | Reference | Downloads | Github

Selecting a random number of rows from conditions file

I have a conditions file with 9 rows, each specifiying the position of a block on the screen. I want to create a sequence of those blocks, with the sequence varying in length (selecting between 3 and 7 rows of the file each loop).

I first tried
‘’’
random($Length)*8
‘’’
in the selected rows box (where Length is specified from a conditions file). That worked in creating sequences of all the specified lengths in a random order, but that created repeats in the trial selected, as discussed here:

I attempted to follow these instructions. The result is that it selects the same 4 rows of my conditions file, and presents them in a different order on each loop.

Is there a way to get it so that each loop it selects a random length (either specified in a conditions file or as a variable), and then selects this number of rows from the conditions file without replacement?

Could you try describing your design again in more detail? It’s not clear to me how one could sample 3–7 rows multiple times from a population of just 9 and not have repetition across blocks.

Apologies!
It’s a memory trial, so I’m presenting a sequence of x images in various locations (9, as specified in a conditions file), (then a load of unrelated tasks), then the participant recalls the sequence, and so on. Repetition across blocks is fine, however currently I’m getting repetition within blocks

With the first solution I tried in the selected rows box, I was getting correct length sequences, but with repetition within blocks-same location presented more than once per sequence.

Using the code snippet you provided I was getting the same x rows presented on each block, rather than a randomly selected new set of x each time (and I can’t figure out how to make x random 3-7 rather than a static number).

Hope that’s clearer!

Hi guys!

I’m new to PsychoPy and I came across the same problem as you did @carolinea. I put the shuffle and selection snippet as a code component in the routine where I want the a new row randomly picked in every iteration (without replacement). Unfortunately, it did not pick a different number each time the routine started again but stayed at the same number. I know this is an older thread by now, but maybe someone has got an answer?