Thanks for your help! I removed the unnecessary import statements. When I add some debugging code, I get the following output code:
## Running: /Users/meganhuibregtse/OneDrive - Indiana University/Dissertation/fMRI Tasks/TASKS/Visual_Mem/N-back_visual_lastrun.py ##
filenames output:
[]
images output:
[]
13.9937 WARNING t of last frame was 27.34ms (=1/36)
14.0165 WARNING t of last frame was 22.77ms (=1/43)
2020-10-13 19:02:58.863 python[73153:8479379] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
File "/Users/meganhuibregtse/OneDrive - Indiana University/Dissertation/fMRI Tasks/TASKS/Visual_Mem/N-back_visual_lastrun.py", line 452, in <module>
Target0 = np.random.choice(a=images,size=1,replace=True)
File "mtrand.pyx", line 1125, in mtrand.RandomState.choice
ValueError: 'a' cannot be empty unless no samples are taken
##### Experiment ended. #####
So you’re right, images is empty (because so is filenames!)
I switched back to an old way I had grabbed the image filenames from the stim folder
path = os.getcwd()
filenames = glob.glob(os.path.join(path, 'stim/*.png'))
Now the output indicates that filenames and images contain the correct contents; however, now the following error message appears in the output:
## Running: /Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/N-back_visual_lastrun.py ##
filenames output:
['/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line1.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line2.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line3.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line7.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line6.png', '/Users/meganhuibregtse//Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line4.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line5.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line10.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line11.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line12.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line8.png', '/Users/meganhuibregtse/Dissertation/fMRI Tasks/TASKS/Visual_Mem/stim/line9.png']
images output:
[<psychopy.visual.image.ImageStim object at 0x1338ba390>, <psychopy.visual.image.ImageStim object at 0x1338ba8d0>, <psychopy.visual.image.ImageStim object at 0x1338c9860>, <psychopy.visual.image.ImageStim object at 0x1338c9a20>, <psychopy.visual.image.ImageStim object at 0x1338c9518>, <psychopy.visual.image.ImageStim object at 0x1338c9128>, <psychopy.visual.image.ImageStim object at 0x1338c9b70>, <psychopy.visual.image.ImageStim object at 0x1338c9c50>, <psychopy.visual.image.ImageStim object at 0x1338c9d30>, <psychopy.visual.image.ImageStim object at 0x1338c9e10>, <psychopy.visual.image.ImageStim object at 0x1338c9ef0>, <psychopy.visual.image.ImageStim object at 0x1338c9f98>]
2020-10-13 20:16:49.834 python[78053:8525732] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/data/experiment.py", line 216, in addData
hash(value)
TypeError: unhashable type: 'numpy.ndarray'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 180, in deepcopy
File "copy.pyc", line 280, in _reconstruct
File "copy.pyc", line 150, in deepcopy
File "copy.pyc", line 240, in _deepcopy_dict
File "copy.pyc", line 169, in deepcopy
ValueError: ctypes objects containing pointers cannot be pickled
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/meganhuibregtse/OneDrive - Indiana University/Dissertation/fMRI Tasks/TASKS/Visual_Mem/N-back_visual_lastrun.py", line 456, in <module>
thisExp.addData('Target0', Target0)
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/data/experiment.py", line 219, in addData
value = copy.deepcopy(value)
File "copy.pyc", line 161, in deepcopy
SystemError: <built-in method __deepcopy__ of numpy.ndarray object at 0x137ec6760> returned a result with an error set
Exception ignored in: <bound method ImageStim.__del__ of <psychopy.visual.image.ImageStim object at 0x13dbea240>>
Traceback (most recent call last):
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/visual/image.py", line 239, in __del__
self.clearTextures()
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/visual/basevisual.py", line 1015, in clearTextures
GL.glDeleteTextures(1, self._texID)
AttributeError: 'ImageStim' object has no attribute '_texID'
Exception ignored in: <bound method Window.__del__ of <psychopy.visual.window.Window object at 0x13dbea0b8>>
Traceback (most recent call last):
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/visual/window.py", line 576, in __del__
if self._closed is False:
AttributeError: 'Window' object has no attribute '_closed'
Exception ignored in: <bound method CocoaScreenMode.__del__ of CocoaScreenMode(width=None, height=None, depth=None, rate=None)>
Traceback (most recent call last):
File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/pyglet/canvas/cocoa.py", line 111, in __del__
quartz.CGDisplayModeRelease(self.cgmode)
AttributeError: 'CocoaScreenMode' object has no attribute 'cgmode'
##### Experiment ended. #####
So from my rudimentary knowledge of interpreting the output code, it looks like images is a numpy.ndarray and not exactly an array of ImageStim to chose from in the begin routine step? This is the error I get now:
File "/Users/meganhuibregtse/OneDrive - Indiana University/Dissertation/fMRI Tasks/TASKS/Visual_Mem/N-back_visual_lastrun.py", line 453, in <module>
thisExp.addData('Target0',Target0.name)
AttributeError: 'numpy.ndarray' object has no attribute 'name'
How do I get PsychoPy to recognize Target0 as an image? And then display it on the screen?