def test_tuning_curve_1d_with_2d_position():
    position = nept.Position(np.hstack([np.array([2, 4, 6, 8])[..., np.newaxis],
                                        np.array([7, 5, 3, 1])[..., np.newaxis]]),
                             np.array([0., 1., 2., 3.]))

    binsize = 2

    spikes = [nept.SpikeTrain(np.array([0., 3., 3., 3.]), 'test')]

    with pytest.raises(ValueError) as excinfo:
        nept.tuning_curve_1d(position, spikes, binsize=binsize)

    assert str(excinfo.value) == 'position must be linear'
예제 #2
0
def test_tuning_curve_1d_with_2d_position():
    position = nept.Position(
        np.hstack([
            np.array([2, 4, 6, 8])[..., np.newaxis],
            np.array([7, 5, 3, 1])[..., np.newaxis]
        ]), np.array([0., 1., 2., 3.]))

    binsize = 2

    spikes = [nept.SpikeTrain(np.array([0., 3., 3., 3.]), 'test')]

    with pytest.raises(ValueError) as excinfo:
        nept.tuning_curve_1d(position, spikes, binsize=binsize)

    assert str(excinfo.value) == 'position must be linear'
def test_simple_tc():
    linear = nept.Position(np.linspace(0, 10, 4), np.linspace(0, 3, 4))

    spikes = [nept.SpikeTrain(np.array([0.5]), 'test'),
              nept.SpikeTrain(np.array([1.5]), 'test'),
              nept.SpikeTrain(np.array([2.5]), 'test')]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)

    assert np.allclose(tuning, ([1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.]))
예제 #4
0
def test_sort_idx():
    linear = nept.Position(np.linspace(0, 10, 4), np.linspace(0, 3, 4))

    spikes = [nept.SpikeTrain(np.array([1.5]), 'test'),
              nept.SpikeTrain(np.array([0.5]), 'test'),
              nept.SpikeTrain(np.array([2.5]), 'test')]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)
    sort_idx = nept.get_sort_idx(tuning)

    assert np.allclose(sort_idx, [1, 0, 2])
def test_simple_tc1():
    """Time spent in each bin not the same."""
    linear = nept.Position(np.linspace(0, 9, 4), np.linspace(0, 3, 4))

    spikes = [nept.SpikeTrain(np.array([0.0]), 'test'),
              nept.SpikeTrain(np.array([1.0]), 'test'),
              nept.SpikeTrain(np.array([2.0]), 'test'),
              nept.SpikeTrain(np.array([2.5]), 'test')]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)

    assert np.allclose(tuning, ([1., 0., 0.], [0., 1., 0.], [0., 0., 0.5], [0., 0., 0.5]))
예제 #6
0
def test_simple_tc():
    linear = nept.Position(np.linspace(0, 10, 4), np.linspace(0, 3, 4))

    spikes = [
        nept.SpikeTrain(np.array([0.5]), 'test'),
        nept.SpikeTrain(np.array([1.5]), 'test'),
        nept.SpikeTrain(np.array([2.5]), 'test')
    ]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)

    assert np.allclose(tuning,
                       ([1., 0., 0., 0.], [0., 1., 0., 0.], [0., 0., 1., 0.]))
예제 #7
0
def test_sort_idx():
    linear = nept.Position(np.linspace(0, 10, 4), np.linspace(0, 3, 4))

    spikes = [
        nept.SpikeTrain(np.array([1.5]), 'test'),
        nept.SpikeTrain(np.array([0.5]), 'test'),
        nept.SpikeTrain(np.array([2.5]), 'test')
    ]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)
    sort_idx = nept.get_sort_idx(tuning)

    assert np.allclose(sort_idx, [1, 0, 2])
def test_tuning_curve_1d_gaussian():
    linear = nept.Position(np.linspace(0, 9, 4), np.linspace(0, 3, 4))

    spikes = [nept.SpikeTrain(np.array([0.0]), 'test'),
              nept.SpikeTrain(np.array([1.0]), 'test'),
              nept.SpikeTrain(np.array([2.0]), 'test'),
              nept.SpikeTrain(np.array([2.5]), 'test')]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=1.5)

    assert np.allclose(tuning, ([0.78698604, 0.10650698, 0.0],
                                [0.10650698, 0.78698604, 0.10650698],
                                [0.0, 0.05325349, 0.39349302],
                                [0.0, 0.05325349, 0.39349302]))
예제 #9
0
def test_tuning_curve_1d_gaussian():
    linear = nept.Position(np.linspace(0, 9, 4), np.linspace(0, 3, 4))

    spikes = [
        nept.SpikeTrain(np.array([0.0]), 'test'),
        nept.SpikeTrain(np.array([1.0]), 'test'),
        nept.SpikeTrain(np.array([2.0]), 'test'),
        nept.SpikeTrain(np.array([2.5]), 'test')
    ]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=1.5)

    assert np.allclose(tuning, ([0.78698604, 0.10650698, 0.0], [
        0.10650698, 0.78698604, 0.10650698
    ], [0.0, 0.05325349, 0.39349302], [0.0, 0.05325349, 0.39349302]))
예제 #10
0
def test_simple_tc1():
    """Time spent in each bin not the same."""
    linear = nept.Position(np.linspace(0, 9, 4), np.linspace(0, 3, 4))

    spikes = [
        nept.SpikeTrain(np.array([0.0]), 'test'),
        nept.SpikeTrain(np.array([1.0]), 'test'),
        nept.SpikeTrain(np.array([2.0]), 'test'),
        nept.SpikeTrain(np.array([2.5]), 'test')
    ]

    tuning = nept.tuning_curve_1d(linear, spikes, binsize=3, gaussian_std=None)

    assert np.allclose(
        tuning, ([1., 0., 0.], [0., 1., 0.], [0., 0., 0.5], [0., 0., 0.5]))