Equals sign (=) and/or list/comma in expInfo defaults breaks experiment settings

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

OS (e.g. Win10): Windows 10 Enterprise
PsychoPy version (e.g. 1.84.x): 2022.2.4
Standard Standalone? (y/n) y
What are you trying to achieve?: Access experiment settings to remove the default.

What did you try to make it work?: Clicking the experiment settings cog.

What specifically went wrong when you tried that?:

Essentially, I added a field to expInfo via experiment settings and included 1=monolingual,2=bilingual as the default (as a pointer of what to type into the box). PsychoPy did not like this. The experiment crashed and now I get the attached error when even trying to open experiment settings…

Any other way I can amend/remove expInfo fields and salvage this file?

Error message attached as image and below as text.

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 625, in getInfo
    isList = ast.literal_eval(str(val))
  File "C:\Program Files\PsychoPy\lib\ast.py", line 59, in literal_eval
    node_or_string = parse(node_or_string, mode='eval')
  File "C:\Program Files\PsychoPy\lib\ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    1=monolingual,2=bilingual
     ^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 659, in getInfo
    infoDict = eval(re.sub(pattern, entryToString, infoStr))
  File "<string>", line 1
    {'participant': 'f"{randint(0, 999999):'06'.0f}"', 'group': '1=monolingual,2=bilingual'}
                                             ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\builder.py", line 1285, in setExperimentSettings
    dlg = DlgExperimentProperties(
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 1741, in __init__
    _BaseParamsDlg.__init__(self, frame=frame, element=element, experiment=experiment,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 787, in __init__
    self.ctrls = ParamNotebook(self, element, experiment)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 638, in __init__
    page = self.CategoryPage(self, self.parent, params)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 496, in __init__
    self.addParam(name, param)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 504, in addParam
    self.ctrls[name] = ParamCtrls(self.dlg, param.label, param, self, name)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\app\builder\dialogs\__init__.py", line 169, in __init__
    val=self.exp.settings.getInfo(), valType=param.valType,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\components\settings\__init__.py", line 664, in getInfo
    raise AttributeError(msg)
AttributeError: Builder Expt: syntax error in "Experiment info" settings (expected a dict)

Hi @PsyTechMMU,

It looks like a combination of errors in the participant field and your new group field. I have been able to replicate your error and have a solution. This involves directly editing the .psyexp file, so I recommend you make a backup of the experiment in case something goes wrong.

  1. Close PsychoPy and make the backup!
  2. right-click your .psyexp and select Open With your text editor of choice (notepad, notepad++, VS Code, etc)
  3. Look for the line that contains your expInfo fields. It should be near the top, in my experiment it was line 10. The field you are looking for probably looks like:
    <Param val="{'participant': 'f&quot;{randint(0,999999):\'06\'.0f}&quot;', 'group': 1=monolingual,2=bilingual}" valType="code" updates="None" name="Experiment info"/>
  4. Replace that line with:
    <Param val="{}" valType="code" updates="None" name="Experiment info"/>
    This erases all the ExpInfo fields, so the error should be removed.
  5. Save your edits, then close the text editor.
  6. You should now be able to reopen PsychoPy and use the Experiment Settings to re-add all the fields you want.

If you want random participant numbers by default, the default participant field is:
f"{randint(0, 999999):06.0f}"

For your groups, you should surround your value by string quotes to avoid the error:
"1=monolingual,2=bilingual"

Alternative: For your group field, if you have a set number of groups (e.g. 2 groups, monolingual and bilingual), you can set the field to provide your limited options in a dropdown with a list of strings:
field = group
default = ['monolingual','bilingual']
image

image

Hope that helps,
-shabkr

1 Like

Thanks, @shabkr! That helped immensely. I did wonder whether I could cheekily get into the file that way, but ran out of time to check it last week. Doing so and just removing that rogue Group field from the Experiment info dictionary did the trick beautifully though. :slight_smile:

Interestingly, the 1=monolingual,2=bilingual was already in quotes, though single and not double (which I didn’t think made a difference in Python, but maybe does in this context).

And thank you for the reminder about dropdowns for expInfo! Much appreciated. :smiley:

I had backups and hadn’t done that much since the last one, but still better to salvage this! Thanks again!

1 Like