Created
June 23, 2015 07:44
-
-
Save dilawar/a81226c7d7526e587752 to your computer and use it in GitHub Desktop.
count spikes in a list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_spikes(tables, threshold): | |
'''Count the number of spikes, also pupulate the spikeTables ''' | |
nSpikes = 0 | |
spikeBegin = False | |
spikeEnds = False | |
clock = moose.Clock('/clock') | |
for tname in tables: | |
t = tables[tname] | |
dt = clock.currentTime / len(t.vector) | |
spikeList = [] | |
for i, x in enumerate(t.vector): | |
if x > threshold: | |
if not spikeBegin: | |
spikeBegin = True | |
spikeEnds = False | |
else: pass | |
else: | |
if spikeBegin: | |
spikeEnds = True | |
spikeBegin = False | |
spikeList.append(i*dt) | |
nSpikes += 1 | |
spikeTables[tname] = spikeList | |
return nSpikes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment