RSVP image presentation timing errors

URL of experiment: GitLab; Pavlovia; RSVPexample.psyexp (abridged version of PsychoPy experiment)

Description of the problem: I have an attentional blink experiment with a RSVP stream of images and the presentation timing lags every so often. The presentation method I’m using came from an old thread with a similar issue (which I can’t seem to find again) and I believe @jon was the one who came up with the solution. The method has two images (odd and even) and each loop alternates the opacity of each image so that only one is shown at a time. Then while one is being shown, the other is invisibly loaded so that the program doesn’t have to load and show a new image in a single component each loop, which prevents lagging. Here are the code snippets from my variation:

Begin Routine:

next_image_loaded = 0;

//do different things on even and odd numbered trials:
if (stimNum % 2 === 0) {
    RSVPimage_odd.opacity = 0; //hide this one
    RSVPimage_even.opacity = 1; //show this one
    
} else {
    RSVPimage_odd.opacity = 1;
    RSVPimage_even.opacity = 0;
    
}

Each Frame:

if ((next_image_loaded === 0) && (frameN > 1) && ((stimNum + 1) < nStim)) { //stimNum = the loop number; nStim = total number of loops
    
    //find out the next image:
    var nextTrial = (stimNum+1);
    var nextImage = RSVPstream[nextTrial];
    
    //do different things on even and odd numbered trials:
    if (stimNum % 2 === 0) {
        RSVPimage_odd.setImage(nextImage);
    } else {
        RSVPimage_even.setImage(nextImage);
    }    
    next_image_loaded = 1;
}

I’ve already made multiple versions of the same type of experiment with this method that all worked fine (as far as I know), but this one isn’t as smooth for some reason. I’m not worried about slight variations in timing, but every four or so trials only shows a few images. All images are supposed to be shown for 70ms. I printed t at the start and end of each loop to get approximate timing for each image (I know that’s not the best method, but I just wanted an estimate) and here are the outputs for some of the first 10 trials:

Trial 1:
[0,0.07560000002384015]
[0,0.06199999999999761]
[0,0.05989999997615314]
[0,0.06099999999999284]
[0,0.0613999999761603]
[0,0.05970000004768394]
[0,0.061799999952313556]
[0,0.06039999997616974]
[0,0.0613999999761603]
[0,0.0601000000238372]
[0,0.06079999995230878]
[0,0.060899999976157915]
[0,0.06189999997616269]
[0,0.06189999997616269]
[0,0.059800000071518866]
[0,0.06039999997616974]

Trial 2:
[0,0.04749999999999943]
[0,0.060899999976157915]
[0,0.061499999999995225]
[0,0.061499999999995225]
[0,0.0613999999761603]
[0,0.061199999928476245]
[0,0.05979999995231822]
[0,0.06070000004768872]
[0,0.06039999997616974]
[0,0.06169999992847863]
[0,0.059900000095368]
[0,0.06170000004767928]
[0,0.060000000000002274]
[0,0.05989999997615314]
[0,0.06139999997614609]
[0,0.0601000000238372]

Trial 4:
[0,0.04860000002383913]
[0,0.06070000004768872]
[0,0.06049999999999045]
[0,0.28139999997615917]
[0,0.03010000002383606]
[0,0]
[0,0]
[0,0.00010000002383492301]
[0,0.00010000002384913387]
[0,0]
[0,0]
[0,0.00010000002384913387]
[0,0]
[0,0]
[0,0]
[0,0]

Trial 5:
[0,0.0519999999999925]
[0,0.0613999999761603]
[0,0.06199999999999761]
[0,0.062100000023846746]
[0,0.06050000000000466]
[0,0.061199999928476245]
[0,0.06189999997616269]
[0,0.06039999997615553]
[0,0.060599999904624724]
[0,0.06289999997615325]
[0,0.06020000004768633]
[0,0.0613999999761603]
[0,0.06070000004768872]
[0,0.06190000009536334]
[0,0.06189999997616269]
[0,0.06189999997616269]

Trial 8:
[0,0.055699999928478405]
[0,0.061799999952313556]
[0,0.22320000004768303]
[0,0.028800000071527165]
[0,0.00010000002384913387]
[0,0]
[0,0.00010000002383492301]
[0,0]
[0,0]
[0,0]
[0,0]
[0,0]
[0,0]
[0,0.00010000002384913387]
[0,0]
[0,0.00010000002383492301]

Trial 9:
[0,0.05560000002384413]
[0,0.061200000047676895]
[0,0.06070000004768872]
[0,0.06100000000000705]
[0,0.06169999992846442]
[0,0.060899999976157915]
[0,0.06100000000000705]
[0,0.060899999976157915]
[0,0.06049999999999045]
[0,0.05989999997615314]
[0,0.060000000000002274]
[0,0.06200000000001182]
[0,0.061799999952313556]
[0,0.060899999976157915]
[0,0.060600000023839584]
[0,0.06130000007152603]

So you can see on trial 4 and 8 that most images aren’t shown at all and image 3 is shown for much longer than it should be. Also none of them are showing for 70ms, but that’s not a huge deal. Is there a reason this could be happening? The last code that worked was using version 2020.2 and this one is using 2021.1.4, so is it maybe something to do with the version? The method was from 2016/2017 (I really wish I bookmarked the thread) so maybe there’s a better way to go about this now? Thanks!

I think that this is the post you mean and it was by @Michael

Yes you’re right thank you!! Sorry, I was looking at a lot of threads around the same time and forgot who solved this one. And I guess it wasn’t as old as I thought it was.

So do you or @Michael know why the images might be lagging so bad every four trials?

I’m not sure why it would be multiples of four, but I feel that there is probably an overhead in having each frame as a new repeat of the routine. I’ve just copied my own Change Blindness RSVP experiment from December last year to my demo namespace so you can take a look at the code. The entry in my online demos post points back here for the discussion thread. I’d be interested to see if its timing is good enough, if you’re happy to test it.

Change Blindness RSVP code | try it | online demos

An experiment created in December 2020 for Sasha Andrade (supervised by Michael Pilling). In this case the polygons for each RSVP stream are set up in one routine and then displayed in a second using AutoDraw manipulations to show and hide each frame.

The thing that makes it difficult is that the images need to be consecutive (no blank screen between them) and there are 16+ images it has to cycle through. The first RSVP I made (back in May 2020) was with words so it worked fine with just updating the text each loop. However, it became difficult/laggy when I switched to image stimuli, most likely because the images needed time to load before being shown, which couldn’t really be done in 70ms. That’s when I found Michael’s thread and his method worked like a charm for two of my experiments now (made ~10 months ago). But then this new version, which is essentially identical to one of the previous experiments that worked, is having this lagging problem. The only thing that’s changed is the PsychoPy version. So I’m wondering if something was changed that might affect timing/loading of stimuli?

For that we’d have to ask @thomas_pronk or @TParsons

I don’t think my method would have a problem with the removal of the blank screens (that would simplify the code) or preloading of 16 images. All 16 would be loaded before the stream started.

1 Like

Edit: I’ve set up the experiment to use frames instead of time for the stimuli and that worked. It’s still strange that the time doesn’t work anymore though.

Update on this: I’ve tried many things to get this to work, but it’s still very laggy in some points. A lot of the trials, it will just skip stimuli altogether or only show one image. As I said in the original post, I had essentially the exact same same experiment that ran perfectly fine. So I kept going back and forth between the two codes to see if my slight differences messed it up. The only other difference between the two experiments is the PsychoPy version. The working code is run on 2020.2 and the new one is currently running on 2021.1.4. So I tested the theory by copying and pasting the exact same PsychoPy experiment with the same stimuli and synced it using the current version I have, and turns out that the version is probably the issue because it no longer works. You can see the old working version here and the same experiment with the newer PsychoPy version here to look at the differences in how it runs. But it’s the exact same code. @jon @dvbridges Was there a change in the newer PsychoPy versions that maybe affected how stimuli are displayed? Is there a better way to make a RSVP of images now? I will test this again whenever the IT guy at my school updates PsychoPy to the newest version, but I’m not sure if this is a 2021.1.4 bug or a long-term change that will also be in 2021.2.3, and I’m kind of pressed for time so I wanted to ask now. Thank you!