summaryrefslogtreecommitdiff
path: root/pyspike/cython/cython_profiles.pyx
diff options
context:
space:
mode:
authorMario Mulansky <mario.mulansky@gmx.net>2015-05-11 17:41:08 +0200
committerMario Mulansky <mario.mulansky@gmx.net>2015-05-11 17:41:08 +0200
commitbec2529367f1bdd5dac6d6fbaec560a30feec3c7 (patch)
tree9c817b1e3648b52238ae3aea44f5572097855f37 /pyspike/cython/cython_profiles.pyx
parent3b10b416940ae674df6d9dff8cdddc31085d8cf5 (diff)
treatment of empty spike trains in spike sync
Diffstat (limited to 'pyspike/cython/cython_profiles.pyx')
-rw-r--r--pyspike/cython/cython_profiles.pyx9
1 files changed, 5 insertions, 4 deletions
diff --git a/pyspike/cython/cython_profiles.pyx b/pyspike/cython/cython_profiles.pyx
index 3690091..d937a02 100644
--- a/pyspike/cython/cython_profiles.pyx
+++ b/pyspike/cython/cython_profiles.pyx
@@ -345,8 +345,8 @@ def spike_profile_cython(double[:] t1, double[:] t2,
# get_tau
############################################################
cdef inline double get_tau(double[:] spikes1, double[:] spikes2,
- int i, int j, double max_tau):
- cdef double m = 1E100 # some huge number
+ int i, int j, double interval, double max_tau):
+ cdef double m = interval # use interval as initial tau
cdef int N1 = spikes1.shape[0]-1 # len(spikes1)-1
cdef int N2 = spikes2.shape[0]-1 # len(spikes2)-1
if i < N1 and i > -1:
@@ -377,12 +377,13 @@ def coincidence_profile_cython(double[:] spikes1, double[:] spikes2,
cdef double[:] st = np.zeros(N1 + N2 + 2) # spike times
cdef double[:] c = np.zeros(N1 + N2 + 2) # coincidences
cdef double[:] mp = np.ones(N1 + N2 + 2) # multiplicity
+ cdef double interval = t_end - t_start
cdef double tau
while i + j < N1 + N2 - 2:
if (i < N1-1) and (j == N2-1 or spikes1[i+1] < spikes2[j+1]):
i += 1
n += 1
- tau = get_tau(spikes1, spikes2, i, j, max_tau)
+ tau = get_tau(spikes1, spikes2, i, j, interval, max_tau)
st[n] = spikes1[i]
if j > -1 and spikes1[i]-spikes2[j] < tau:
# coincidence between the current spike and the previous spike
@@ -392,7 +393,7 @@ def coincidence_profile_cython(double[:] spikes1, double[:] spikes2,
elif (j < N2-1) and (i == N1-1 or spikes1[i+1] > spikes2[j+1]):
j += 1
n += 1
- tau = get_tau(spikes1, spikes2, i, j, max_tau)
+ tau = get_tau(spikes1, spikes2, i, j, interval, max_tau)
st[n] = spikes2[j]
if i > -1 and spikes2[j]-spikes1[i] < tau:
# coincidence between the current spike and the previous spike