# Dropping many frames: Spike triggered average

**URL:** <https://discourse.psychopy.org/t/dropping-many-frames-spike-triggered-average/27129>\
**Category:** Coding\
**Created:** [February 1, 2022, 11:48am UTC](https://discourse.psychopy.org/t/dropping-many-frames-spike-triggered-average/27129 "2022-02-01T11:48:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Smirnov](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/ivan_smirnov/32/31660_2.png) [@Ivan\_Smirnov](https://discourse.psychopy.org/u/Ivan_Smirnov)\
**Post date:** [February 1, 2022, 11:48am UTC](https://discourse.psychopy.org/t/dropping-many-frames-spike-triggered-average/27129/1 "2022-02-01T11:48:53Z")

</div>

Hello, everyone!  
I’m trying to Use the Psychopy for receptive field mapping, using spike triggered average method.  
But, every time there are a lot of dropped frames.  
I’m using the following code:

```auto
# Create screen
win = visual.Window(size=[280, 300],
                    fullscr=False,
                    screen=1,
                    allowGUI=False,
                    allowStencil=False,
                    monitor='testMonitor',
                    color=[-1, -1, -1],
                    colorSpace='rgb',
                    blendMode='avg',
                    useFBO=False,
                    waitBlanking=True)
# setting up for recording frames interval
win.recordFrameIntervals = True

# Open noise file
binary_matrix = np.load(FILE_WITH_NOISE)

# Binary stimulus
stimulus = visual.ImageStim(win, units='norm', size=[2, 2])

for trial in range(TRIALS):
    time_start = time.time()
    for mat_number in range(binary_matrix.shape[2]):
        stimulus.image = binary_matrix[:, :, mat_number]

        for frame in range(FRAME_NUM):
            stimulus.draw()
            win.flip()
    print(time.time() - time_start)

plt.figure()
plt.plot(win.frameIntervals)
plt.show()

frame_times_file = datetime.now().strftime("%Y%m%d-%H:%M")
win.saveFrameIntervals(fileName='STA_ft_' + frame_times_file + '.log')

win.close()

```

OS: win10  
GPU: nvidia gtx 1060  
RAM: 32 gb  
CPU: core i7

Thank you!

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [February 1, 2022, 5:47pm UTC](https://discourse.psychopy.org/t/dropping-many-frames-spike-triggered-average/27129/2 "2022-02-01T17:47:11Z")

</div>

Hi There,

I suspect the topic “spike triggered average” is a bit too specific for forum users to understand what the problem is and identify if they can help, so I hope you don’t mind me changing the topic here to attract more relevant community support.

If you open coder and select “demos \>timing \> timebyframes” what does the output of that look like? this will help determine if it is a code/stimulus issue or a hardware issue.

Thanks,  
Becca

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [February 3, 2022, 10:04am UTC](https://discourse.psychopy.org/t/dropping-many-frames-spike-triggered-average/27129/3 "2022-02-03T10:04:30Z")

</div>

Hello,

did you turn off nvidia g-sync ready option? This allows the graphic card to dynamically adjust the frame-rate…

Best wishes Jens
