psychopy.org | Reference | Downloads | Github

Drawing words randomly from trial-specified lists?

I’ve got an affective words go-nogo experiment I’m working on. We have a bunch of trials, and each trial has a valence (positive, negative, neutral) and trial type (go, nogo).

What I want to do is: For each trial, draw a random word without replacement from a list of words matching that valence. I’m not sure how to do this in builder — in coder, I could just read the CSV file into lists, shuffle, and pop() items from the list. But I’d like to be able to run this both in python and on the web.

(The Eprime Way to do this would be with nested lists, but I’d really like to use psychopy for this one.)

Is there a standard way to make this go?

Thanks!

I think this will require some code in either way. I guess start with the Python version and then provide a JavaScript translation once you are confident the Python version is working properly (the Builder code components allow you to have both Python and JavaScript side by side).

I’d be tempted to put the words in your conditions file, connected to a random loop, and use code to balance and manipulate the valence and trial types. You could go the other way, in which case the code would be easier, but you’d have to handle reading in the list of words separately, or insert it as a list of literals in the code, which could be more cumbersome from a cross-language point of view.