psychopy.org | Reference | Downloads | Github

Sanity check for monitor timing code

I was running a set of experimental procedures on several high refresh-rate monitors (240Hz) to see how they perform with ultra-fast stimulus display.

My setup comprised of a computer and an EEG recorder with a photodiode attached. This way I wanted t o see how each monitor displays simple stimuli in respect of the triggers recorded by the EEG.

What I noticed is some of the monitors, when asked to display a white square for e.g. 1 frame (approx. 4ms) every 100 frames, would randomly drop that frame, so for some time (1 more seconds) nothing would be displayed.

Before I’ll draw any conclusions, I wanted to check with You if by any chance there is something wrong with my code rather than the displays themselves.

The code is here

win = visual.Window(size=[1920, 1080], color=(0,0,0), units='pix',
                    fullscr=True, allowGUI=False, waitBlanking=True, screen=3)

def frame_stability(frames=[1], reps=100, trigger_start=180):
    '''Function test the stability of presentation based on the frame duration.
    Presents a constant stimulus for desired number of frames. By default it is
    a white square on a black background.
    
    Parameters
    ----------
        frames : list
            Contatins list of frame durs that stimuli suppose to be presented.
            Default is [1].
        reps : int
            Number of repetitions of each frame durations. Default is 50.
    
    '''
    
    wsquare = visual.Rect(win=win, width=1, height=1, size=(200,200), 
                          lineColor=None, fillColor=(1,1,1), units='pix')
    
    for dur in frames:
        fbreak = epoch - dur
        for rep in range(reps):
            for frame in range(dur):
                blackWin.draw()
                wsquare.draw()
                
                win.flip()
                if frame == 0:
                    trigger(trigger_start)
            
            for frame in range(fbreak):
                blackWin.draw()
                
                win.flip()

    win.flip()
    core.wait(break_time)
    win.clearBuffer()

After that it would be called like this:

epoch = 100
frame_stability([1], reps=100, trigger_start=185)

Do You think something in my code could cause this frame dropping behavior?
PsychoPy itself did not report and dropped frames.

Thanks in advance for any help!