Problem with Psychopy detecting condition name from experimental settings (Chapter 8 in the Psychopy Book)

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

OS (e.g. Win10):
PsychoPy version (e.g. 2021.1.4
**Standard Standalone? Y
What are you trying to achieve?:
Hello everyone, I am following along the example of building a blocked bilingual stroop task from chapter 8 in Bulding Experiments in Psychopy.

All has gone well until I have got to the counterbalancing part, where I have two groups, GroupA for English Stroop first, and GroupB for Maori Stroop first.

In order to allow Psychopy to choose which condition should go first, Group A or B, the book states in the experimental settings create a new variable called group and default A. I went ahead and did this no problem (See screen shot below)

Then within the conditions file in my block loop, I changed the conditions to what the book suggests to see the image below of my conditions expression.

What did you try to make it work?:
I re-read the book, retyped the info and I double checked all my excel conditions files were equal and had all the same capitalisation etc.

What specifically went wrong when you tried that?:
This is the error message I got.

Traceback (most recent call last):
File “C:\Users\rh4818\Documents\Psychopy book exp\Stroop\”, line 218, in
NameError: name ‘group’ is not defined

Experiment ended.

I have definitely created the group variable in the experimental conditions, but it seems like psychopy isn’t interpreting that from the expression I wrote in the conditions file for my Block. Maybe something has changed since the book was written?


I think you must use
$'Group'+ expInfo['group'] + '.xlsx'

see here

or here

Best wishes Jens

Hi Jens, thank you so much! My Experiment works. Initially the experiment worked per your suggestion for the correct expression but it would always have Maori first but I went and changed random to sequential and it works as intended from what I can tell. I think I understand now the Random vs Sequential parameters when we have some basic counterbalancing in the loops.

I had a suspicion it was that Psychopy wasn’t picking group from experimental settings, but I had no idea how to “force” it to use it in the expression.

Again many thanks, I will have a look at the links you sent in depth and see where I can get even better at counterbalancing.

Have a great day.

Kind regards,