Continuously exactly 1 frame is dropped per trial

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 they have seen an indoor- or an outdoor-scene by lifting a finger of one of the ctrl-keys, that are required to be held down.

Now here’s my problem (Code below): I set the win.recordFrameIntervals to True to obtain info about dropped frames. In order to see for every trial if frames were dropped, I set the recording to zero directly before starting with the presentation procedure, and save the number of dropped frames in a variable that is appended to my output. I alway get one dropped frame per trial, also with a second CRT-monitor I tested my experiment on. The computer has an external graphics card with drivers that are fully updated.

Code:

#Preload Images
images = [] # need to start with an empty list

filenames = expFile["filename"]
filenames_path = path_images + expFile["filename"]

for file in filenames_path: #create an image stimulus from each file, and store it in the list
    images.append(visual.ImageStim(win=win, image=file)) 

#function to present image and masks and capture RT of releasing a key
def presentImage(win,stimulus, maskPic1, maskPic2, maskPic3, fillerPic): 
    image = stimulus
        
    mask1 = maskPic1
        
    mask2 = maskPic2
        
    mask3 = maskPic3
        
    filler = fillerPic
        
    c = 0
    io.clearEvents() 

    for frameN in xrange(2): 
        image.draw()
        win.flip()
        if frameN == 0:
             t1 = core.getTime() #time at stimulus onset
    win.flip() 
    for frameN in xrange(2):
        mask1.draw()
        win.flip()
    win.flip()
    for frameN in xrange2):
        mask2.draw()
        win.flip()
    win.flip()
    for frameN in xrange(2):
        mask3.draw()
        win.flip()
    win.flip()
    waitTime = random.randint(90, 120)
    for frameN in xrange(waitTime):
        filler.draw()
        win.flip()
    win.flip()

    a = 0 #to only capture first release/reaction
    for event in keyboard_io.getReleases(keys=[target_key, distractor_key]):
        if a==0:
            c = event.time - t1 #difference in time between stimulus onset and key-release
            a += 1
        
    if c != 0:
        return (event.key, c)
    else:
        return (99, c)
#frame recording
win.recordFrameIntervals = True
win.refreshThreshold = 1/monitor_hz + 0.004

#do trials
for i in range(nTrials): #loop over all images
        #here, some stuff is done i don't want to bother you with, so I will just describe what is done
        #calling some functions: check if keys are held down, draw fixation cross
        #decide which masks are going to be used
        #now, the relevant part begins
        win.nDroppedFrames = 0 
        resp, RT = presentImage(win,dict2[stimList[i]], mask1, mask2, mask3, fillerPic) #save response and reaction time
        droppedFrames = win.nDroppedFrames

As mentioned before, my problem is that for every trial, one frame is recorded as dropped in the variable “droppedFrames”. I have no idea why that is and would naturally like to have no frames dropped.

Is there anybody with an idea what i could improve to controll the stimulus presentation in a way that no frames will be dropped?

Thank you in advance,
Mathis

It could be due to the section of code that is removed here (i.e. the code at the start of each iteration of the trial loop). If that takes longer than a refresh, then the first flip in presentImage will register as dropped (though not on the first trial, unless there is another flip in the removed code). Maybe add a print win.frameIntervals statement to the end of each iteration to see if you can identify which frame it is?

Thank you for your answer, I will try to identify the exact frame!