Howdy, Stranger!

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

Supported by

Problem with increasing presentation time of stimuli

edited June 2022 in OpenSesame

Hi all,

For my EEG experiment, the timing of presentation of visual stimuli is crucial. They should be presented for 300 ms with a 200 ms blank inter-stimulus interval, so that the total duration is 500 ms.

The experiment is programmed in OS with psycho_legacy back-end. The code for stimulus presentation that we use is:

# preparation
my_canvas = Canvas() # stimulus
my_blankcanvas = Canvas() # ISI

for idx in stream_idx:
   # draw image
   my_canvas.image(exp.get_file(stim[idx])) # load png file
   timing_canvas[trial_idx] = my_canvas.show()
   eeg_trigger(1)
   self.sleep(295)

   # inter-stimulus interval
   my_blankcanvas.show()
   self.sleep(195)

We send a trigger at the onset of a stimulus and calculate the difference between those onsets to get the duration between two consecutive stimuli.

The presentation time increases the further into the experiment (see figure below). There also seems to be a lot of variation regardless of the upwards trend. There exists a documentation page on timing (https://osdoc.cogsci.nl/3.3/manual/timing/) but I have not been able to fix the problem yet. I tried loading the images beforehand (in the preparation tab) but that did not seem to solve the issue.

Does anyone have an idea on how to solve this? It would be of great help! (I am new to OpenSesame, so this might be a simple change of code or back-end or ... that I am not aware of, or it might be a trigger related problem.)

Best,

Liesa

Comments

  • Hi @Lia@lrvts ,

    There are two things going on here:

    • The steadily increasing presentation time results from the fact that you're drawing images on top of each other, instead of clearing the canvas (or creating a new canvas) before drawing a new image. You presumably don't notice this because the new image covers the old ones. But the computer has to render them all!
    • The variability in the presentation time results from the fact that you're not preparing the canvas objects in advance, so the stimulus preparation time adds a slight-but-unpredictable delay.

    To solve this, I would first create a list of Canvas objects in the Prepare phase:

    my_canvases = []
    my_blankcanvas = Canvas()
    for idx in stream_idx:
        my_canvas = Canvas()
        my_canvas.image(pool[stim[idx]])
        my_canvases.append(my_canvas)
    

    And then show them in the Run phase:

    for my_canvas in my_canvases:
        timing_canvas[trial_idx] = my_canvas.show()
        eeg_trigger(1)
        clock.sleep(295)
        my_blankcanvas.show()
        clock.sleep(195)
    

    (I didn't test the code above, but it should convey the general idea.)

    — Sebastiaan

  • Dear Sebastiaan,

    Thanks a lot for your answer! This indeed solved the (two) problem(s).

    Best,

    Liesa

Sign In or Register to comment.