Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

issue in pre-loading images

edited October 2020 in OpenSesame

Dear all,

I am preparing an experiment with video stimuli. Because I want a finer control of the videos, I have converted them in a series of images, one each frame, and a series of csv files with the paths of each image/frame, one csv file each video.

Therefore, in the opensesame script I wrote the following "prepare" script, just to see if the procedure might work:

path = [exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/001.png"],exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/002.png"],exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/003.png"],exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/004.png"],exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/005.png"],exp.pool["STIMOLI_SCALED/FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630/006.png"]]

exp.canvas_pictures = []

i = 0

for thispath in path:
   tmp = canvas(self.experiment)
   tmp.image(path[i],y=0,x=0)
   exp.canvas_pictures.append(tmp)
   i += 1

Then, in the run part, I simply wrote:

l = []

for img in exp.canvas_pictures:
   t = img.show()
   l.append(t)
   exp.sleep(40)

for t in l:
   print(t)

print("stop")

In this way, everything worked very well.

Then, I changed the "prepare" part in order to get the images paths from the csv file:

path = []

csvpath = exp.get_file('stimuli/FRAMES_1200_CUT_BICCHIERE_afferramento Lat_1_MVI_0630.csv')

j = 0

with open(csvpath) as file:
   stimuli = file.readlines()

   for stim in stimuli:
      tmp = str(stim.split(";")[2])
      tmp = tmp.replace("\"","")
      if j > 0:
         path.append(exp.pool[tmp])
      j += 1

exp.canvas_pictures = []

i = 0

for thispath in path:
    tmp = canvas(self.experiment)
    tmp.image(thispath,y=0,x=0)
    exp.canvas_pictures.append(tmp)
    i += 1


But something is not working, because OpenSesame returned the following error:

  • item: new_inline_script
  • phase: prepare
  • item-stack:experiment[run].father_loop[run].father_sequence[prepare].new_inline_script[prepare]
  • time: Thu Oct 15 17:27:58 2020
  • exception type: osexception
  • exception message: ` "STIMOLI_SCALED\FRAMES_1200_CUT_BICCHIERE_afferramento_Lat_1_MVI_0630\001.png " does not exist

As you can see, the problem is not the impossibility to read the csv file.

I have also done some tests, and it is reading it correctly, with the correct path for the file.

I have even tried to obtain using python within OpenSesame the complete path for the file by using exp.experiment_path.

In this way the path was correct (copy and paste in windows explorer opened the image), but OpenSesame returned the same error.

What I am doing wrong?


Thanks in advance for your time.


Michele


PS: in attachment, one exemplificative csv file

Comments

  • Do not bother to answer, I have found my solution:


    from datamatrix import io
    dm = io.readtxt(exp.pool['stimuli/FRAMES_1200_CUT_BICCHIERE_afferramento Lat_1_MVI_0630.csv'],delimiter=";")
    path = dm.image
    
Sign In or Register to comment.