From a5e6a12a619cb9528a4cf7f3ef8f082e5eb877c2 Mon Sep 17 00:00:00 2001 From: Mario Mulansky Date: Wed, 9 Sep 2015 17:51:03 +0200 Subject: 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. --- test/test_sync_filter.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/test_sync_filter.py (limited to 'test/test_sync_filter.py') 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 + +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) -- cgit v1.2.3