Randomising the selection of different series, while keeping items within each series sequential

OS (Win11):
PsychoPy version (e.g. 2024.2.4 Py 3.8):
Standard Standalone Installation? y
Do you want it to also run online? n
What are you trying to achieve?:

I am doing a recognition memory test with multiple series of images gradually getting closer to a “target” item. I would like the items within the series to be sequential, but the order of the series’ to be random - i.e. if I’ve got 3 series (S1,S2,S3) each consisting of 3 items (I1, I2, I3), I’d like the items to stay in order (always I1, I2, I3) but the series to be randomly be selected in different orders (e.g. S2, S1, S3; S3, S1, S2; etc). All series will eventually be shown to every participant

What did you try to make it work?:

I started off with making a routine for each series and then attempting to loop over it selecting randomly, but that’s both impactical (my real experiment will have 50 series) and just doesn’t work (I can see why it doesn’t work, I’m not actually dynamically referring to anything and just sticking a loop over a bunch of routines and selecting “random” on the loop isn’t going to change that)

I tried making a truth matrix with only one ‘1’ per column but this also didn’t work - I suspect because I was applying it to a nonsensical loop.

At the moment my experiment has just one ‘trial’ routine and then 2 nested loops like this, which I think is correct

However, I can’t work out what needs to go in the excel file, where the images should be stored (I assume just on the same filepath?), and what I should put in the “Image” box on image properties and what I should put in the “condition” box for each loop. I’ve attached screenshots of what I currently have at the end.

I currently have this excel file as the conditions for ‘images’ loop (‘image_refs.xlsx’). It repeats in the same pattern all the way down, though please note that the series are variably either length 4 or length 8. I don’t think that will impact how I build the experiment but I’m (evidently) not very knowledgeable about this, so I wanted to mention it in case it is relevant

I also have this excel sheet for the outer loop (‘outer_loop.xlsx’) based on advice from here: Sequential and Random Selection at the same time - #7 by Michael , but am unsure whether it’s actually useful, and definitely don’t know how to make it useful! I fear part of the problem is me missing some fundamentals…

I’ve pasted the image properties, and the properties for both loops, as I currently believe this is where the problem is.

Link to the most relevant existing thread you have found:

the below thread is somewhat similar but missing the ‘sequential series’ aspect

I got the command “$eval(“target” +$expInfo[‘target’])” from the below, but this also isn’t quite right

This is similar but opposite to my issue

What specifically went wrong when you tried that?:
Error message:

DEPRECATION Couldn’t find image eval(“target” +$expInfo[‘target’]); check path? (tried: C:\Users\Rey - Work\Documents\psypy_7_8_25\eval(“target” +$expInfo[‘target’]))

Dear Reyams,

The way I have done things similar to yours is like this.

For your outer loop, just have a set of excel file paths as each row. Then each excel file is just a whatever the trials you want in each “block”. The loop conditions for the inner is the reference variable in the outerloop spreadsheet (e.g. $excel_path), and then image reference is normal (e.g. $image_path).

I think there is a more elegant solution, but at the moment I cannot remember what it is.

It would look something like this:

This ^ would be two separate csv files. And make sure you set which loops are random or sequential properly. I think in my example I have those settings backwards (random within, sequential outer).

Best regards,

Issac

This is the standard solution. The only refinement I would recommend is to use selected rows instead of different spreadsheets.

2 Likes

Hello @reyams

I created a small toy-experiment that uses one condition-file.

Begin Experiment tab

#randomise list order

listOrder = []
start = 0
while start < 51:
    ende = start + 3
    if ende > 51:
        break
    listOrder.append(f"{start}:{ende}")
    start += 3
    
#randomises list order
#turn off for testing
shuffle(listOrder)

useRows = []

Begin routine tab

#use to acces first element of listOrder
useRows = listOrder.pop(0)

#use to access last element of listOrder
#useRows = listOrder.pop()

The condition file has one column called ‘stimulus’, containing numbers from 0 to 49.

This example can easily be adapted to larger files, while still allowing one condition file to be used and maintained.

Best wishes Jens