Randomizaion and the condition file in Pavlovia

When I use PsychoPy I usually do something like this:

  • I create a routine.
  • I create a loop.
  • Inside the loop I specify a conditions file. For example, I tell PsychoPy that I will present two words, one on the left of the screen and one on the right. In this case, the file has four columns, let’s say “word1”, “word2”, “position1”, and “position2”.
  • I add a code component to the beginning of the experiment. In the code component I create the conditions file. I first create four lists (two for the words, two for the positions), shuffle them, and write them into a csv (i.e., this will be my conditions file).

But now I realized that this does not work with Pavlovia. Is there an easy way to make something similar using Pavlovia? My first thought was to go the other way: Add a code component opening a csv and shuffle each column. But I don’t know how to add this into a loop.

Any help is much appreciated! But if you are able and willing to help please note that I only have a very basic understanding of programming so please assume I’m stupid :joy:

Hi,

It seems that this could be solved by the integrated “conditions” component.
When you create a loop, click on it and at the bottom there will be a conditions line.
You can create and excel file containing the stimuli and tell psychopy to open and read it (without actually writing any code).
I recommend checking Jason Ozubko’s video tutorials for information as they are pretty easy to understand.

I hope this helps,
KKacar

Hi KKacar,
thanks for your answer! I usually do that. But if I want, for example, present random combinations of the two words in my experiment I need to randomize one of the columns in my Excel file for each participant. This is why I write some code. But using Pavlovia I can only use a conditions file, but not create it via code.

But I will nevertheless take a look at the tutorials. Maybe I’ll find a solution there :slight_smile:

Hi KKacar, this video indeed was very helpful: https://www.youtube.com/watch?v=r0z6lGhuaEY
Thanks! :slight_smile: :slight_smile:

In your code component, you need to provide a JavaScript equivalent to your current Python code (as Python doesn’t run in a web browser). In your code component, select “Auto → JS” and Builder will do its best to automatically translate your Python to JavaScript. This probably won’t work perfectly. So if necessary, change the button to “Both” so that you can manually edit the JavaScript, to fix any problems with it emulating what the Python code does.

See here for some tips on PsychoJS equivalents to PsychoPy code: