# How to find the the starting and ending time of the spontaneous activity - visual coding data

**URL:** <https://community.brain-map.org/t/how-to-find-the-the-starting-and-ending-time-of-the-spontaneous-activity-visual-coding-data/654>\
**Category:** Technical\
**Tags:** nwb, brain-observatory-visual-coding, analysis, how-to\
**Created:** [August 9, 2020, 7:41pm UTC](https://community.brain-map.org/t/how-to-find-the-the-starting-and-ending-time-of-the-spontaneous-activity-visual-coding-data/654 "2020-08-09T19:41:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yameng](https://avatars.discourse-cdn.com/v4/letter/y/97f17d/32.png) [@yameng](https://community.brain-map.org/u/yameng)\
**Post date:** [August 9, 2020, 7:41pm UTC](https://community.brain-map.org/t/how-to-find-the-the-starting-and-ending-time-of-the-spontaneous-activity-visual-coding-data/654/1 "2020-08-09T19:41:42Z")

</div>

Hi,

I just downloaded a NWB file (502974807.nwb). I am interested in the spontaneous activity and wanted to find which part of the time is involved with the spontaneous time. I tried to open the epoch and it’s empty. Appreciate any help.

---

<div class="post-metadata">

**Author:** ![saskiad](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/saskiad/32/1695_2.png) [@saskiad](https://community.brain-map.org/u/saskiad)\
**Post date:** [August 12, 2020, 9:40pm UTC](https://community.brain-map.org/t/how-to-find-the-the-starting-and-ending-time-of-the-spontaneous-activity-visual-coding-data/654/2 "2020-08-12T21:40:17Z")

</div>

Hi,

The AllenSDK has a function called “get\_stimulus\_epoch\_table” that will return a table of the start and end of all stimulus epochs. This will tell you the start and end times (aligned the the 2P fluorescence traces) of each stimulus class. Here is the result for the file you were looking at:

 ![Screen Shot 2020-08-12 at 2.39.05 PM](https://canada1.discourse-cdn.com/flex027/uploads/brainobservatory/original/1X/fc785696404b30a0cd9f61e7ddcc0cbcc614a022.png)

---

<div class="post-metadata">

**Author:** ![yameng](https://avatars.discourse-cdn.com/v4/letter/y/97f17d/32.png) [@yameng](https://community.brain-map.org/u/yameng)\
**Post date:** [August 12, 2020, 11:57pm UTC](https://community.brain-map.org/t/how-to-find-the-the-starting-and-ending-time-of-the-spontaneous-activity-visual-coding-data/654/3 "2020-08-12T23:57:34Z")

</div>

Got it.

Thanks a lot.

Best,  
Yameng
