Psychopy:从外循环的条件文件中调用一个条件文件

Psychopy: Call a conditions file from the outer loop's conditions file

我对 PsychoPyPython 编码有点陌生,所以请原谅我的问题,如果它是基本的。在我的任务中,我有许多指示刺激位置的文件。我的外部循环有一个变量 ExcelList,它下面列出了前面提到的文件名。指示每次试验的内部循环尝试通过在 space 中输入 $ExcelList 来随机调用这些文件,以请求条件文件。据我了解,$ExcelList 的命令应该访问外循环中的条件文件,并提取其中一个包含该试验刺激位置的文件。但是,我收到以下错误:

File "/Users/bencline/Desktop/Psychexp/NegPriming2080_lastrun.py", line 247, in module> trialList=data.importConditions(ExcelList), File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/data.py", line 1366, in importConditions raise ImportError('Conditions file not found: %s' %os.path.abspath(fileName)) ImportError: Conditions file not found: /Users/bencline/Desktop/Psychexp/Trials_20_95.xlsx

看起来内循环没有在外循环中找到条件(或者完全没有读取外循环)。如果我尝试改写 $eval(ExcelList),则会出现以下错误:

File "/Users/bencline/Desktop/Psychexp/NegPriming2080_lastrun.py", line 247, in trialList=data.importConditions(eval(ExcelList)), File "", line 1, in NameError: name 'Trials_20_95' is not defined

这似乎更能说明潜在的问题,但我仍然不确定如何从这里开始。对于为什么会发生这种情况以及我可能如何解决它,您有什么建议吗?

谢谢,

-本

你的策略是对的。它在外循环中读取您的 ExcelList 但无法在您的文件系统上找到 ExcelList 中的文件名。特别是,在您的第一条错误消息中,它找不到 /Users/bencline/Desktop/Psychexp/Trials_20_95.xlsx。所以检查它是否真的存在。我强烈怀疑这不是因为其中一个或两个原因:

  • 它在不同的文件夹中,例如一个子文件夹。解决方案是在ExcelList文件中写出路径(相对或绝对)。
  • 它的拼写不同,例如带有小 T 或大写后缀 (XLSX)、空格键等。解决方案当然是让 ExcelList 中的文件名与实际文件名匹配。