Manipulating loop conditions resource breaks js export

link: ImmuStigTask [PsychoPy]

In previous versions of psychopy I was able to switch between resource files to implement custom trial randomizations. For example, I could pass a variable designID = 1, to the loop conditions field to load a particular csv file: $“Design”+str(designID)+“.csv”.

I would prepare multiple .csv resource files and switch between them.

This still works for offline experiments but brakes export to javascript (name ‘designID’ is not defined).
I’ve read heaps on here that the way that resources can be loaded has changed quite a bit, and I am preloading them correctly, but I still don’t quite get it how I should index these multiple preloaded loop resources within the experiment builder.

Many thanks!


Put designID = 0 in Begin Experiment

Tried, it doesn’t work. Here’s the exact error I get when trying to export to javascript:

Traceback (most recent call last):
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 1056, in findPathsInFile
    filePath = eval(filePath)
  File "<string>", line 1, in <module>
NameError: name 'designID' is not defined

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\", line 846, in fileExport
    exportPath = self.generateScript(experimentPath=exportPath,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 91, in generateScript
    compileScript(infile=exp, version=None, outfile=filename)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 229, in compileScript
    _makeTarget(thisExp, outfile, targetOutput)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\scripts\", line 202, in _makeTarget
    script = thisExp.writeScript(outfile, target=targetOutput, modular=True)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 356, in writeScript
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 390, in writeFlowSchedulerJS
    for resource in self.exp.getResourceFiles():
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 1174, in getResourceFiles
    condsPaths = findPathsInFile(params['conditionsFile'].val)
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 1070, in findPathsInFile
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\experiment\", line 1087, in findPathsInFile
    conds = data.importConditions(thisFile['abs'])  # load the abs path
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\", line 365, in importConditions
    trialList, fieldNames = _attemptImport(fileName=fileName,
  File "C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\", line 263, in _attemptImport
    trialsArr = pd.read_csv(fileName, encoding='utf-8-sig',
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\util\", line 311, in wrapper
    return func(*args, **kwargs)
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\io\parsers\", line 586, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\io\parsers\", line 482, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\io\parsers\", line 811, in __init__
    self._engine = self._make_engine(self.engine)
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\io\parsers\", line 1040, in _make_engine
    return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
  File "C:\Program Files\PsychoPy\lib\site-packages\pandas\io\parsers\", line 69, in __init__
    self._reader = parsers.TextReader(self.handles.handle, **kwds)
  File "pandas\_libs\parsers.pyx", line 542, in pandas._libs.parsers.TextReader.__cinit__
  File "pandas\_libs\parsers.pyx", line 642, in pandas._libs.parsers.TextReader._get_header
  File "pandas\_libs\parsers.pyx", line 843, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas\_libs\parsers.pyx", line 1917, in pandas._libs.parsers.raise_parser_error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 181: invalid start byte