| Reference | Downloads | Github

Shuffling condition file but keeping specific columns linked

OS: Win10
PsychoPy version : 1.84.2
Standard Standalone? (y/n) y

I’m building an experiment which has two main elements. A flanker paradigm presents a row of symbols for a discrimination task, which in itself was easy to make and involves 5 columns in a conditions file. There are 18 possible variations of the conditions (3 x 3 x 2). At the same time, one of 72 unique images will be onset in the background of the task. These images are in one of two conditions (36 / 36). The presentation of the images involves more than just their filename, also scale and shift values and their condition. So, I’ve made a conditions file with 72 rows (plus 1 header row), and 9 columns. The 18 flanker task variations are repeated 4 times to give 72 trials with unique images and 4 repeats of each flanker task condition.

However, currently the conditions file would mean that each time the experiment is run, each unique image will always be presented alongside a fixed flanker task condition. I need to randomise this so that while remaining as equiprobable as it is currently (i.e. that the 18 flanker conditions will be repeated twice in each image condition, currently the first 36 images and the final 36 images in the conds file), the experiment randomly assigns a flanker variation to each of the 72 images.

I’ve found guidance that will import a csv, convert the data from one column to a list, shuffle this then save it back, which would be perfect if the only column relating to the image presentation was a filename. Since I have 4 columns of data for each image, and these need to remain linked together as they give the condition, scale factor and shift value for that specific image, I need a way to take in the data from the conditions file, then using a list or otherwise, take the first 4 columns and, keeping each row of data for those columns linked together, shuffle their row position relative to the remaining 5 columns in the conditions file.
(Ideally, I’d need a way to actually do this for the first 36 rows (less the header) of data and last 36 rows of data independently to help make sure that flanker conditions are evenly spread for each image condition, but if not then it remains equiprobable anyway.)

I’ve been using builder, and really struggle when I try to interpret the Python code regarding this. I don’t understand how lists might incorporate multiple columns, perhaps with each list item as an array? I don’t know if this is even possible or if a better approach can be used in the case of shuffling linked columns of data.

I’ll attach a builder file and the conditions file I’ve used (currently xlsx with colours used to show how columns are linked and the way conditions are repeated)… there is a wealth of supporting content required for the experiment to run (image files etc) but hopefully this indicates where I’m at and how I’ve set things up so far. Note, the builder file also has for diagnostic purposes a text component which shows me the filename so I could identify any trials with faults with image presentation, ignore that. Likewise, the conditions file has 2 extra columns at the end which control the duration of presentation of the tasks, so I can adjust this easily (it normally would be 0.1-0.2ms but when checking everything works I need longer to inspect), these can be all but ignored really as they are the same throughout.

Thank you kindly in advance

allconds.xlsx (13.2 KB)