How to call to specific csv columns from subject's number

Hi

I’m trying to design a second experiment which the subject see the same images as he saw from the first one.
In the first experiment the images are randomalize : which images ( there are 2 colors each) , order of appearance and place.
Is it possible to design that from the subject number that we enter he will do the experiment with his the same images as he saw before? Can I call the data from the csv columns of the first experiment?

Thank you in advance!

Leshem

Is this experiment to run locally or online? Have you already run the first experiment or are you designing them together? The reason I ask if because the approach I’de recommend is a little different depending on these questions.

Thanks,
Becca

thank you Becca

we run the experiment locally and we already run the first one.

Leshem

Hi Leshem,

OK in that case I’de suggest the following:

a) add a field to your experiment settings e.g. “data file” :experiment_settings: where you can write the name of the datafile from the participant
b) add a code component to your experiment
b) In the Begin Experiment tab use something like:

import pandas as pd

thisdata = pd.read_csv(expInfo['data file'])# load the datafile
images = {'image': list(thisdata['image_column_header'])}# where image_column_header refers to the column header where the images are presented!
conditions_file = pd.DataFrame.from_dict(images)
conditions_file.to_csv(expInfo['participant']+'.csv', index=False)# save the list of images to a new csv file (this can be fed into the loop where images are presented

this will read in the data file and save a conditions file with the name of your participant. You can then in your trials loop use $expInfo['participant']+'.csv' and use the variable “image” to present images.

I’ve made an example experiment with a how to guide here for you to download. Hopefully this helps!

Thanks,
Becca