Counterbalancing based on custom variable in the info dialog box

Hi all,

I’m a complete beginner and I started out with the new book (Peirce & MacAskill), which is great by the way. In Chapter 8 (p. 118-120) I came across a problem with counterbalancing blocks of trials based on a custom variable in theexperiment settings dialog box. I try to provide enough info below.

Thanks in advance for your help!
Eva

OS: Win10
PsychoPy version: 1.90.1
Standard Standalone? y
What are you trying to achieve?: Counterbalance the order of 2 blocks (Maori/English Stroop versions) based on a Group variable (A or B) defined in the experiment settings. This is an exercise in the new book (Peirce & MacAskill, 2018) on pages 118-120.

What did you try to make it work? Used a very basic Stroop design prepared in previous exercises, which works fine. Created 2 .xlsx files (GroupA.xlsx and GroupB.xlsx) both containing a single “language” variable referring to the order of the languages (English-Maori for GroupA and Maori-English for groupB). Folder also contains 2 .xlsx condition files for each of the languages (English.xlsx and Maori.xlsx). Next, added a custom variable named group in the Experiment Info dialog box. Referred to this in the BlocksLoop using: $'Group' + group + '.xlsx' In the TrialLoop I already used a reference to the two language files: $language + '.xlsx'

What specifically went wrong when you tried that?:

##### Running: C:\Data Eva\Onderzoek\PsychoPy\Exercises\Stroop\new2\Stroop.py #####
Traceback (most recent call last):
  File "C:\Data Eva\Onderzoek\PsychoPy\Exercises\Stroop\new2\Stroop.py", line 170, in <module>
    trialList=data.importConditions('Group' + group + '.xlsx'),
NameError: name 'group' is not defined

Hi @Evdbussc, you have an error

Try replacing group with expInfo['group'], as this is the dictionary that contains your data that was input from the GUI at the beginning of the experiment.

2 Likes

Thanks David. Just to clarify for future readers who will find Eva’s post, it was indeed a typo in the textbook and the complete line on page 120 should read:

$'Group' + expInfo['group'] + '.xlsx'

rather than:

$'Group' + group + '.xlsx'

as we need to explicitly refer to the variable entered in the Experiment Info dialog box.

This error will be corrected in the second edition and should already be corrected in the Japanese translation of the first edition.

2 Likes

Many thanks! This indeed solved the problem.
Eva