| Reference | Downloads | Github

Creating participant unique csv files, detailing trial conditions

I am adapting an experiment that I previously wrote in matlab (using PTB) to the PsychoPy framework, using the Builder (which is a pleasure to use, thanks for your time & effort!), with the aim of running it online.

I want each participant to have a unique sequence of trials. The way I do this is with a code component at the beginning of the experiment. In the component, all the trial conditions are assigned and defined in a ‘dict’ called ‘seq’. I then save these variables to a csv file, using pandas.

pd_seq = pd.DataFrame.from_dict(seq)
pd.DataFrame.to_csv(pd_seq, ‘seq.csv’)

This csv file is used to control the conditions for each trial.

When I export the project to pavlovia, I doesn’t work. I believe the issue is the code component in python has:

import pandas as pd

which is translated into JS as:

import * as pd from ‘pandas’;

Does anyone have any suggestions? [it is possible I am going about this completely the wrong way - I am relatively new to this, apologies if this is obvious]

If you need further details please let me know and I will add the code.


Hi @MDag97,

pandas (and anything that is not base Python) can not be auto-translated to Javascript, as far as I know.

I think you will need to generate the seq_csv files in advance and add a Code Component in the beginning of your experiment that randomly selects one for each participant.

I have a similar issue for my task and I will try to either run participants with the same configuration in small batches or continuously update the conditions file while the study is running (see my related question here).

Hope that helps!

Super, thanks that’s really helpful, will do that!

1 Like