summaryrefslogtreecommitdiff
path: root/pyspike/cython
diff options
context:
space:
mode:
authorMario Mulansky <mario.mulansky@gmx.net>2015-09-09 17:51:03 +0200
committerMario Mulansky <mario.mulansky@gmx.net>2015-09-09 17:51:03 +0200
commit81c6609191786d96c9feaf40767a1615e9a0565c (patch)
tree4b60bebfc9d12a33d404ec31ffe7c28317eee0a5 /pyspike/cython
parentf1f1bfa2653986c7b8b5ae4d27e7013218293b00 (diff)
added SPIKE-Sync based filtering
new function filter_by_spike_sync removes spikes that have a multi-variate Spike Sync value below some threshold not yet fully tested, python backend missing.
Diffstat (limited to 'pyspike/cython')
-rw-r--r--pyspike/cython/cython_profiles.pyx31
1 files changed, 31 insertions, 0 deletions
diff --git a/pyspike/cython/cython_profiles.pyx b/pyspike/cython/cython_profiles.pyx
index f9893eb..3b33c5a 100644
--- a/pyspike/cython/cython_profiles.pyx
+++ b/pyspike/cython/cython_profiles.pyx
@@ -426,3 +426,34 @@ def coincidence_profile_cython(double[:] spikes1, double[:] spikes2,
c[1] = 1
return st, c, mp
+
+
+############################################################
+# coincidence_single_profile_cython
+############################################################
+def coincidence_single_profile_cython(double[:] spikes1, double[:] spikes2,
+ double t_start, double t_end, double max_tau):
+
+ cdef int N1 = len(spikes1)
+ cdef int N2 = len(spikes2)
+ cdef int j = -1
+ cdef double[:] c = np.zeros(N1) # coincidences
+ cdef double interval = t_end - t_start
+ cdef double tau
+ for i in xrange(N1):
+ while j < N2-1 and spikes2[j+1] < spikes1[i]:
+ j += 1
+ tau = get_tau(spikes1, spikes2, i, j, interval, max_tau)
+ print i, j, spikes1[i], spikes2[j], tau
+ if j > -1 and spikes1[i]-spikes2[j] < tau:
+ # current spike in st1 is coincident
+ c[i] = 1
+ if j < N2-1:
+ j += 1
+ tau = get_tau(spikes1, spikes2, i, j, interval, max_tau)
+ print i, j, spikes1[i], spikes2[j], tau
+ if spikes2[j]-spikes1[i] < tau:
+ # current spike in st1 is coincident
+ c[i] = 1
+
+ return c