I have a large set of data which consists of only 0s and 1s, When plotting on a graph, the 1s represent [FONT=inherit !important][FONT=inherit !important]peaks[/FONT][/FONT], but a single peak spans over a number of data points, and sometimes briefly drops to 0 but then continues. I cant figure out which function to use to count the number of peaks in my data, given that even if it drops to zero for a certain specified time frame, it still counts as one peak. Any help would be appreciated. Hope the example below helps:

Here, the time frame for 0s between two peaks to still count as one peak is 1 second

Heres a visualisation of the actual problem