Shuffle columns in pavlovia

URL of experiment:

Description of the problem: I am making a learning experiment. Briefly, the participants see various images of scenes with an embedded star. Simply, participants have to use their mouse to click on the star in each trial. I have a .csv file with 4 columns (Image, StarX, StarY, Side) and because I dont want every participant to see the star in the same location within each scene I have added a code component at the very beginning of the experiment which shuffles the list of StarX and StarY:

import csv

f = csv.reader(open('Learning.csv'))
Images, StarX, StarY, Side= zip(*f)

StarX = list(StarX) # convert the tuple to a list to make it editable
header_x = StarX.pop(0) # remove the header item 
shuffle(StarX) # randomise the actual values 
StarX.insert(0, header_x) # restore the header at the top 
 
StarY = list(StarY) # convert the tuple to a list to make it editable
header_y = StarY.pop(0) # remove the header item 
shuffle(StarY) # randomise the actual values  
StarY.insert(0, header_y) # restore the header at the top


subjectID=expInfo['participant']
sessionID=expInfo['session'] 

# create a file name based on those variables

filename1=subjectID + '_' + sessionID + '.csv'

with open(filename1, 'w') as w:
    writer = csv.writer(w)
    for i in range(len(Images)):
        writer.writerow([Images[i], StarX[i], StarY[i], Side[i]]) 

The code attached above when run locally creates a filename1 which I then specify as variable ($filename1) in the properties tab of my experimental loop. The problem is that this file, as expected, is not generated when the experiment runs online, so my loop doesn’t have access to the conditon file.

So,is there another way I could shuffle the x,y coordinates (StarX, StarY) that works online?

Thanks in advance.

2 Likes

Hi @phoenix,

Were you able to figure this out? I am trying to implement something similar and am wondering if you’d had any luck.

Thanks.

Hi @abarnas,

I didn’t manage to find a solution using this script, so I just made multiple experiment versions and assigned participants to each version based on their subject id. The main issue is that this script has to be translated into JS to work online. For that, you can have a look at this crib sheet by Wakefield Morys-Carter: