Any ideas how to resolve this? I’m guessing the problem stems from when I define a path in a code component tab, like this:
path = (“images/”)
stimlist = [os.path.join(path, file)
for file in os.listdir(path)
if file.endswith(‘C.png’)]
So I figure the error arrises because os is not imported, but when I add ‘import os’ to a code component tab (before experiment), the experiment gets stuck on ‘initializing experiment…’
Thanks! But how do I reference the spreadsheet and a specific column so that it works online? Do I have to provide the xlsx file in the conditions file field of a loop or can I read it in from a code component?
I did not know that that was necessary. I have the component set to Auto - JS. So if I change it to Both, how should I edit the JS code to get it working?
ah yes, editing the JS code according to your coding snippet got me past the error. Thanks again.
To anyone having a similar issue: you also have to specify the spreadsheet in the Additional Resources field of the Online tab in the Experiments Settings.
I have one more problem regarding the trialHandler method that maybe you could help me with? How do I get the values, i.e., file names, that I guess are stored in _trialList in dictionaries? In python I could use list comprehension and refer to the column header / key like this:
stim_dict = data.TrialHandler(...)
allstim = [i['faces'] for i in stim_dict]
print('all stimuli',allstim)
I cant seem to find a method that works online with javascript, but I guess there must be some simple way of doing this?