# Inaccurate stimulus duration timing for online image components

**URL:** <https://discourse.psychopy.org/t/inaccurate-stimulus-duration-timing-for-online-image-components/45564>\
**Category:** Online experiments\
**Created:** [September 10, 2025, 9:25am UTC](https://discourse.psychopy.org/t/inaccurate-stimulus-duration-timing-for-online-image-components/45564 "2025-09-10T09:25:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stanley1O1](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@stanley1O1](https://discourse.psychopy.org/u/stanley1O1)\
**Post date:** [September 11, 2025, 6:49pm UTC](https://discourse.psychopy.org/t/inaccurate-stimulus-duration-timing-for-online-image-components/45564/2 "2025-09-11T18:49:10Z")

</div>

Dear Tim

The best way to actually measure if you are actually losing frames is a photodiode.

As for where your singular frame might be going try these posts? [Need help choosing frames or timed duration for my visual stimulus - #3 by wakecarter](https://discourse.psychopy.org/t/need-help-choosing-frames-or-timed-duration-for-my-visual-stimulus/39510/3)

> [@Continuously exactly 1 frame is dropped per trial](https://discourse.psychopy.org/t/continuously-exactly-1-frame-is-dropped-per-trial/2668):
>
> Hi all, I’m relatively new to psychopy (doing my first experiment for my bachelor’s thesis) and have come across a problem controlling stimulus presentation: In my experiment’s procedure, I do present an image for 2 frames on a 75 hz CRT-monitor. This is directly followed by a set of three masks, that are also presented for 2 frames each. Next, there is a blank intervall randomly ranging between 90 and 120 frames. Having seen the image, subjects should as quickly as possible decide whether th…

> [@Abnormal frame duration 2.0](https://discourse.psychopy.org/t/abnormal-frame-duration-2-0/17164):
>
> Hi community, I am running the code below on a dell XPS Laptop 15’ with a Nvidia GTX 1080 on Windows 10 (Psychopy v 3.2.4): win = visual.Window(fullscr=True, monitor='mathieu', color=[145,145,145], colorSpace='rgb255', units='cm') police = 'Consolas' win.setMouseVisible(False) # initialize keyboard resp = keyboard.Keyboard() some\_text = visual.TextStim(win=win, text ="Hello world", font=police, pos=[0, 0], height=0.5, color=[0,0,0], colorSpace='rgb255') …

Your lost frame might be in the buffer frame at trial start

```auto
    # reset timers
    t = 0
    _timeToFirstFrame = win.getFutureFlipTime(clock="now")
    frameN = -1
    
    # --- Run Routine "trial" ---
    trial.forceEnded = routineForceEnded = not continueRoutine
    while continueRoutine and routineTimer.getTime() < 1.0:
        # get current time
        t = routineTimer.getTime()
        tThisFlip = win.getFutureFlipTime(clock=routineTimer)
        tThisFlipGlobal = win.getFutureFlipTime(clock=None)
        frameN = frameN + 1 # number of completed frames (so 0 is the first frame)
        # update/draw components on each frame
        
        # *image* updates
        
        # if image is starting this frame...
        if image.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
            # keep track of start time/frame for later
            image.frameNStart = frameN # exact frame index
            image.tStart = t # local t and not account for scr refresh
            image.tStartRefresh = tThisFlipGlobal # on global time
            win.timeOnFlip(image, 'tStartRefresh') # time at next scr refresh
            # add timestamp to datafile
            thisExp.timestampOnFlip(win, 'image.started')
            # update status
            image.status = STARTED
            image.setAutoDraw(True)
        
        # if image is active this frame...
        if image.status == STARTED:
            # update params
            pass
        
        # if image is stopping this frame...
        if image.status == STARTED:
            # is it time to stop? (based on global clock, using actual start)
            if tThisFlipGlobal > image.tStartRefresh + 1.0-frameTolerance:
                # keep track of stop time/frame for later
                image.tStop = t # not accounting for scr refresh
                image.tStopRefresh = tThisFlipGlobal # on global time
                image.frameNStop = frameN # exact frame index
                # add timestamp to datafile
                thisExp.timestampOnFlip(win, 'image.stopped')
                # update status
                image.status = FINISHED
                image.setAutoDraw(False)

```

I may be incorrect here but the

```auto
frameN = frameN + 1

```

is creating a buffer frame on frame 0, then starts drawing objects on frame 1. Hence a “lost” frame.

Issac

---

_[View the full topic](https://discourse.psychopy.org/t/inaccurate-stimulus-duration-timing-for-online-image-components/45564)._
