psychopy.org | Reference | Downloads | Github

Nested block of 4 events, followed by a rating event, but randomization is not working. How do you randomize column from condition file in code?

If this template helps then use it. If not then just delete and start from scratch.

OS (e.g. Win10): Mac OS 10.14
PsychoPy version (e.g. 1.84.x): 1.85.6
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?:

I would like to develop a social evaluative feedback design involving three events per trial. Each trial will contain events in the following sequence: (a) self-evaluate on the self-relevance of trait word from 1 (Not at all) to 5 (Extremely), (b) receive confederate feedback from 1 to 5 on same trait. Fixation cross will be presented during ITI’s between events. The trials will be presented in sequences of 4, and participants will then receive an event asking participants to provide a rating of their mood. So it will go (1) self evaluate → (2) feedback, for four times, and then (3) mood rating, and then it will return to (1) and (2) four times, until all words have been presented.

There will be 148 words presented in total in a random order.

After all of this has been completed of (1) (2) and (3) for 148 words, participants will re-rate themselves on words again, but that is not the issue that I need help with.

What did you try to make it work?:

I tried the following format:

trials_3 contains a condition file with four rows per cell. This is to select blocks of four (0:4, 4:8, 8:12, etc.). Meanwhile, trials contains the word list I want to select from with the selected rows field as “$rows” which are the selected rows from trials_3 condition file (e.g. “4:8”).

If I can shuffle the wordlist once trials loop begins, I think that would resolve this. However, when I try to insert “shuffle” code into the beginning of routine, as follows:

34%20PM

I get the following error, despite shuffle definitely being correct syntax in psychopy. I’ve tried shuffle and random.shuffle (even though I’m pretty sure psychopy doesn’t need it preceded by random as numpy is already imported) and neither work.

How can I shuffle my word list on each loop so that it selects sequence of 4 from a randomized word list?

What specifically went wrong when you tried that?:

It is presented 4 words that are all adjacent to each other in the list, albeit in a randomized order within that block (e.g. “Good” “Good-Natured” etc.)

First, note that $ is not a valid part of the Python language (which is why it causes a syntax error). $ is just an indicator to Builder itself to treat what follows as a Python expression: Builder strips that $ prefix out before creating any code. So don’t use it inside any of your own Python code.

Second , when in doubt, print it out. What happens if you insert:

print(word)
print(type(word))

Is word actually a list that can be shuffled?

Lastly, if the above don’t help (and I’ve only really skimmed your post), I suspect that your problem might be solved by looking at similar things people have tried to do. Try Googling this:

psychopy independently shuffle conditions file column