image uploading with filepool fails (psychopy)
Hello, i am wrighting a very simple code using the inlinescript from O.S. for psychopy. I want an image from my pc to be displayed (which I have uploaded in file pool) but i keep getting an error.
my script is:
import psychopy.visual
import psychopy.event
win = psychopy.visual.Window(
size=[400, 400],
units="pix",
fullscr=False
)
img = psychopy.visual.ImageStim(
win=win,
image="neutral.jpg",
units="pix"
)
img.draw()
win.flip()
psychopy.event.waitKeys()
The error message I'm getting is:
Error while executing inline script
phase: prepare
item: inline_script
line: 654
exception message: Couldn't find image file 'neutral.jpg'; check path? (tried: C:\Program Files (x86)\OpenSesame\neutral.jpg)
exception type: OSError
Traceback (also in debug window):
File "dist\libopensesame\inline_script.py", line 150, in prepare
File "dist\libopensesame\python_workspace.py", line 111, in _exec
Inline_script, line 13, in <module>
File "dist\psychopy\visual\image.py", line 110, in __init__
File "dist\psychopy\visual\image.py", line 275, in setImage
File "dist\psychopy\visual\basevisual.py", line 655, in createTexture
OSError: Couldn't find image file 'neutral.jpg'; check path? (tried: C:\Program Files (x86)\OpenSesame\neutral.jpg)
Any ideas on how to solve that issue?
Thanks on advance
Comments
Hi Maria,
The file pool is located in a temporary folder. To get the full path to files in the file pool, you therefore need to do:
In your case, that would become:
See also:
Cheers,
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
i replaced the line image="neutral.jpg" with image=pool["neutral.jpg"] as you suggested and i am now getting this error message:
Error while executing inline script
phase: prepare
item: inline_script
line: 12
exception message: name 'pool' is not defined
exception type: NameError
Why is that happening? I am really sorry for the inconvenience but i just began using O.S...Thank you very much for your fast replies!
I just tried again what you suggested and it works, i can't remember what i did wrong the first time. Thanks again for your time!