1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
""" test_spike_delay_asymmetry.py
Tests the asymmetry functions
Copyright 2015, Mario Mulansky <mario.mulansky@gmx.net>
Distributed under the BSD License
"""
import numpy as np
from numpy.testing import assert_equal, assert_almost_equal, \
assert_array_equal
import pyspike as spk
from pyspike import SpikeTrain, DiscreteFunc
from pyspike.spike_directionality import _spike_directionality_profile
def test_profile():
st1 = SpikeTrain([100, 200, 300], [0, 1000])
st2 = SpikeTrain([105, 205, 300], [0, 1000])
expected_x = np.array([0, 100, 105, 200, 205, 300, 1000])
expected_y = np.array([1, 1, 1, 1, 1, 0, 0])
expected_mp = np.array([1, 1, 1, 1, 1, 2, 2])
f = _spike_directionality_profile(st1, st2)
assert f.almost_equal(DiscreteFunc(expected_x, expected_y, expected_mp))
assert_almost_equal(f.avrg(), 2.0/3.0)
assert_almost_equal(spk.spike_directionality(st1, st2), 2.0/3.0)
assert_almost_equal(spk.spike_directionality(st1, st2, normalize=False),
4.0)
st3 = SpikeTrain([105, 195, 500], [0, 1000])
expected_x = np.array([0, 100, 105, 195, 200, 300, 500, 1000])
expected_y = np.array([1, 1, 1, -1, -1, 0, 0, 0])
expected_mp = np.array([1, 1, 1, 1, 1, 1, 1, 1])
f = _spike_directionality_profile(st1, st3)
assert f.almost_equal(DiscreteFunc(expected_x, expected_y, expected_mp))
|