OS: macOS Catalina
PsychoPy version: 2021.1.4
Standard Standalone: Yes
What are you trying to achieve?:
I have an experiment that needs to load a unique set of images and text for every trial. I have it set up like this:
With the conditions set in an excel file:
I don’t want to add an ISI between trials, as this will interrupt the narrative (with the exception of specific trials, for which I have an ISI set to 12 - reaction time on the prior trial). Unfortunately, I am running into some timing inconsistencies on the order of 1 second, which is not ideal for an fMRI experiment. I am hoping to preload all of the image stimuli before the experiment.
What did you try to make it work?:
I tried adding a code component for “before experiment” with:
import glob
import os
filenames = glob.glob(os.path.join('/stim/','*.png'))
images = []
images.append(visual.ImageStim(win=win, image=file))
And then setting the image in the component by using $images[Image_Character], where “Image_Character” is the column in the excel file containing the name if the image file (not sure if this is the correct way to do this?).
What specifically went wrong when you tried that?:
There must be something wrong with my code, because I get the following error:
Alert 4210:JavaScript Syntax Error in ‘Before JS Experiment’ tab. See ‘Line 1: Unexpected token’ in the ‘Before JS Experiment’ tab.
For further info see 4210: Probable syntax error detected in your JavaScript code — PsychoPy v2021.2
I am very new to java script so I’m not sure exactly what the issue is, any advice would be greatly appreciated!