# Neuropixel data - Question regarding stimulus ID for 'spontaneous' stimulus epoch

**URL:** <https://community.brain-map.org/t/neuropixel-data-question-regarding-stimulus-id-for-spontaneous-stimulus-epoch/1059>\
**Category:** Technical\
**Tags:** brain-observatory-visual-coding, analysis, how-to\
**Created:** [April 28, 2021, 5:13pm UTC](https://community.brain-map.org/t/neuropixel-data-question-regarding-stimulus-id-for-spontaneous-stimulus-epoch/1059 "2021-04-28T17:13:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarruedi1](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/sarruedi1/32/691_2.png) [@Sarruedi1](https://community.brain-map.org/u/Sarruedi1)\
**Post date:** [April 28, 2021, 5:13pm UTC](https://community.brain-map.org/t/neuropixel-data-question-regarding-stimulus-id-for-spontaneous-stimulus-epoch/1059/1 "2021-04-28T17:13:07Z")

</div>

I have a question regarding the calculation of spontaneous firing rates using the ecephys\_session tutorial. In the instructions it is stated: ‘The gray period stimulus (just a blank gray screen) never gets a block.’ Yet, when I filter for the ‘spontaneous’ epochs, it looks like multiple epochs of gray screen are acquired throughout the session but the stimulus block value is set to ‘null’ for all blocks.

I tried using the tutorial to calculate the firing rates but for ‘spontaneous’ the firing rates go off the charts compared to ‘drifting grating’ etc. I assume that this is due to the fact that all spontaneous epochs have the same Stimulus\_ID across the ‘null’ blocks, which is set to 0. While the stimulus\_presentation\_id seems to be unique across the different spontaneous epochs, the stimulus\_condition\_id is actually 0 for all entries. I would appreciate any feedback on whether it is possible to use the ‘spontaneous’ epoch as a filter due the stimulus ID as it’s done for ‘drifting gratings’ in the tutorial. Is there a specific reason that all spontaneous’ epochs have been assigned a ‘null’ value for the blocks?

---

<div class="post-metadata">

**Author:** ![joshs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/joshs/32/8_2.png) [@joshs](https://community.brain-map.org/u/joshs)\
**Post date:** [April 28, 2021, 11:36pm UTC](https://community.brain-map.org/t/neuropixel-data-question-regarding-stimulus-id-for-spontaneous-stimulus-epoch/1059/2 "2021-04-28T23:36:47Z")

</div>

Hi @Sarruedi1! First of all, I just want to make sure you’re aware that you can pull out a stimulus table for the spontaneous epochs using the following code:

```
spont_table = session.get_stimulus_table(['spontaneous'])

```

The reason we don’t assign a block index to the spontaneous epochs is because it’s technically not a block of stimuli, but instead represents the gap between stimulus blocks. Each spontaneous epoch still has a `stimulus_presentation_id`, though, so it can be uniquely identified.

To calculate the firing rate within a particular spontaneous epoch, you would just count the spikes between the `start_time` and `stop_time` for that epoch, then divide by the value in the `duration` column. To get the overall spontaneous firing rate, you can compute the average firing rate across all epochs.

If you’re using `conditionwise_spike_statistics` to calculate firing rates, you need to specify `use_rates=True`, so it normalizes by the duration of each epoch. Maybe this explains why the spontaneous firing rates seemed abnormally high?

Let me know if that helps!

---

<div class="post-metadata">

**Author:** ![Sarruedi1](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/sarruedi1/32/691_2.png) [@Sarruedi1](https://community.brain-map.org/u/Sarruedi1)\
**Post date:** [April 29, 2021, 12:06am UTC](https://community.brain-map.org/t/neuropixel-data-question-regarding-stimulus-id-for-spontaneous-stimulus-epoch/1059/3 "2021-04-29T00:06:17Z")

</div>

> [@joshs](#):
>
> `conditionwise_spike_statistics`

Hi Josh, Thank you for the feedback! In the meantime, I figured out how to get the ‘start\_time’ and ‘stop\_time’. I haven’t used `conditionwise_spike_statistics` yet, so thanks for the tip regarding this method.
