You are totally right. I have created another version for testing and did not change it back.
Now the error become:
15.2008 ERROR Couldn't find image t; check path? (tried: C:\Users\cat\Desktop\emotion-boundary interaction paradigm\Psychopy\t)
Traceback (most recent call last):
File "C:\Users\cat\Desktop\emotion-boundary interaction paradigm\Psychopy\EmotionBoundary_trial_custom_Fil_lastrun.py", line 247, in <module>
image_1.setImage(event_images)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\image.py", line 305, in setImage
setAttribute(self, 'image', value, log)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\tools\attributetools.py", line 141, in setAttribute
setattr(self, attrib, value)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\tools\attributetools.py", line 32, in __set__
newValue = self.func(obj, value)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\image.py", line 292, in image
wrapping=False)
File "C:\Program Files\PsychoPy3\lib\site-packages\psychopy\visual\basevisual.py", line 823, in _createTexture
raise IOError(msg % (tex, os.path.abspath(tex)))
OSError: Couldn't find image t; check path? (tried: C:\Users\cat\Desktop\emotion-boundary interaction paradigm\Psychopy\t)
This is very weird, I never have anytime name “t” in my image list. Below is the snip of my image list. They are all ends with “.bmp”.
This error happened after successfully showing one picture.
Since I need to show four images in an event, I set the nReps$ =4. I also tried 1, the program proceed with no problem. But only showed 1 image per event.
Below is my code (not much differ from your original one):
### Begin experiment
import pandas as pd
# Read csv, access first col, make Python list
# Do this only once at beginning of exp. No need to read from file over and over again.
neutral = np.array(pd.read_csv('neutral.csv').iloc[:,0]) # Read csv, choose first col, and convert to list
emotion = np.array(pd.read_csv('emotion.csv').iloc[:,0])
# Placeholder variables
prev_imgs = ''
last_idx = -1
# Dispatcher for lists of image filenames
imgs_select = {'emotion.csv' : emotion, 'neutral.csv' : neutral}
## Begin routine
n = currentLoop.thisN
if n == 0: # Only on first iteration of each event
all_images = imgs_select[ImgS]
image_idxs = np.arange(len(all_images))
# Exclude idx of last picture if same condition
if ImgS == prev_imgs:
image_idxs = np.setdiff1d(image_idxs, last_idx)
event_idx = np.random.choice(image_idxs, size=4) # Choose four
# Get our four random pictures
event_images = all_images[event_idx]
# Remember this for next event intialization
prev_imgs = ImgS
last_idx = event_idx[-1]
#Imageselect_1.addData(prev_imgs)
# Assign image
event_images = event_images[n]