diff options
author | Mario Mulansky <mario.mulansky@gmx.net> | 2015-09-09 17:51:03 +0200 |
---|---|---|
committer | Mario Mulansky <mario.mulansky@gmx.net> | 2018-06-02 12:58:46 -0700 |
commit | a5e6a12a619cb9528a4cf7f3ef8f082e5eb877c2 (patch) | |
tree | 7afedd9d3dc9697a7fcfdf904dc62d5196a56c9a /test/test_sync_filter.py | |
parent | 66bf08417c651d1c0d96cb980571efb2043d7f1a (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 'test/test_sync_filter.py')
-rw-r--r-- | test/test_sync_filter.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test_sync_filter.py b/test/test_sync_filter.py new file mode 100644 index 0000000..ce03b23 --- /dev/null +++ b/test/test_sync_filter.py @@ -0,0 +1,43 @@ +""" test_sync_filter.py + +Tests the spike sync based filtering + +Copyright 2015, Mario Mulansky <mario.mulansky@gmx.net> + +Distributed under the BSD License + +""" + +from __future__ import print_function +import numpy as np +from numpy.testing import assert_equal, assert_almost_equal, \ + assert_array_almost_equal + +import pyspike as spk +from pyspike import SpikeTrain + + +def test_cython(): + st1 = np.array([1.0, 2.0, 3.0, 4.0]) + st2 = np.array([1.1, 2.1, 3.8]) + + # cython implementation + try: + from pyspike.cython.cython_profiles import coincidence_single_profile_cython \ + as coincidence_impl + except ImportError: + from pyspike.cython.python_backend import coincidence_single_profile_python \ + as coincidence_impl + + sync_prof = spk.spike_sync_profile(SpikeTrain(st1, 5.0), + SpikeTrain(st2, 5.0)) + + coincidences = np.array(coincidence_impl(st1, st2, 0, 5.0, 0.0)) + for i, t in enumerate(st1): + assert_equal(coincidences[i], sync_prof.y[sync_prof.x == t], + "At index %d" % i) + + coincidences = np.array(coincidence_impl(st2, st1, 0, 5.0, 0.0)) + for i, t in enumerate(st2): + assert_equal(coincidences[i], sync_prof.y[sync_prof.x == t], + "At index %d" % i) |