Example #1
0
def test_stimulus_pin_check():
    with pytest.warns(Warning):
        s = ts.stim_indent_shape(np.array([[0., 0.], [0.25, 0.]]),
                                 ts.stim_ramp(pin_radius=0.5))
    assert s.pin_radius == 0.125

    with pytest.warns(Warning):
        s = ts.stim_indent_shape(np.array([[0., 0.], [0.25, 0.], [0.5, 0.]]),
                                 ts.stim_ramp(pin_radius=0.5))
    assert s.pin_radius == 0.125
Example #2
0
def test_response_index():
    a = ts.affpop_single_models(noisy=False)
    s = [ts.stim_ramp(), ts.stim_ramp()]
    r = a.response(s)

    assert len(r[a[0]]) == 1
    assert len(r[a[0]]._spikes[0]) == 1
    assert len(r[a[0]]._spikes[1]) == 1
    assert len(r[a['PC']]) == 4
    assert len(r[a['PC']]._spikes[0]) == 4
    assert len(r[a['PC']]._spikes[1]) == 4
    assert r[a[1]].rate() == a[1].response(s).rate()
Example #3
0
def test_plot_stimulus_mpl():
    renderer = hv.renderer('matplotlib')
    s = ts.stim_ramp(len=0.25,amp=.1,ramp_len=0.05)
    obj = plot(s)

    s += ts.stim_sine(freq=25.,len=.25,loc=[1.,1.])
    obj = plot(s)
    obj = plot(s,grid=True)

    with pytest.warns(Warning):
        s = ts.stim_indent_shape(ts.shape_circle(hdiff=0.5),ts.stim_ramp(len=0.1))
    obj = plot(s,spatial=True)
Example #4
0
def test_profile_1pin_ramp():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],[],1);
    '''
    s = ts.stim_ramp(pin_radius=1.)

    assert np.around(max(s._profile.flatten()), decimals=3) == 0.119
Example #5
0
def test_stim_ramp():
    s = ts.stim_ramp(pin_radius=1., len=0.5)

    assert s.pin_radius == 1.
    assert s.duration == 0.5
    assert s.time[0] == 0.
    assert s.time[-1] == 0.5
    assert s.location[0, 0] == 0.
    assert s.location[0, 1] == 0.
    assert s.fs == 5000.
Example #6
0
def test_static_1pin_ramp():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],[],1);
    a = Afferent('SA1');
    [~,stat_comp] = s.propagate(a,false);
    '''
    s = ts.stim_ramp(pin_radius=1.)
    a = ts.Afferent('SA1')
    stat_comp, _, _ = s.propagate(a)

    assert np.around(max(stat_comp)[0], decimals=4) == 0.0203
Example #7
0
def test_stimulus_iadd():
    s = ts.stim_ramp(loc=[0., 0.])
    s2 = ts.stim_ramp(loc=[5., 0.])
    assert len(s) == 1

    s += s2

    s3 = ts.stim_ramp(loc=[10., 0.], pin_radius=2.)
    with pytest.warns(Warning):
        s += s3
    assert len(s) == 3
    assert s.pin_radius == 0.5
    assert s3.pin_radius == 2.

    s4 = ts.stim_ramp(loc=[0., 0.])
    with pytest.raises(Exception):
        s += s4

    s5 = ts.stim_ramp(loc=[0., 0.], fs=500.)
    with pytest.raises(Exception):
        s += s5
Example #8
0
def test_waveprop_delay_1pin2():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],'sine',1);
    a = Afferent('SA1','location',[150 0]);
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_ramp(pin_radius=1., ramp_type='sine')
    a = ts.Afferent('SA1', location=[150., 0.])
    _, dyn_comp, _ = s.propagate(a)

    assert np.argmax(dyn_comp.flatten()) >= 219 - delay_slack
    assert np.argmax(dyn_comp.flatten()) <= 219 + delay_slack
Example #9
0
def test_waveprop_1pin_ramp2():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],[],1);
    a = Afferent('SA1','location',[50 0]);
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_ramp(pin_radius=1.)
    a = ts.Afferent('SA1', location=[50., 0.])
    _, dyn_comp, _ = s.propagate(a)

    assert np.around(max(dyn_comp)[0], decimals=3) == 0.169
    assert np.around(min(dyn_comp)[0], decimals=3) == -0.169
Example #10
0
def test_dynamic_1pin_ramp():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],[],1);
    a = Afferent('SA1');
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_ramp(pin_radius=1.)
    a = ts.Afferent('SA1')
    _, dyn_comp, _ = s.propagate(a)

    assert np.around(max(dyn_comp)[0], decimals=3) == 13.281
    assert np.around(min(dyn_comp)[0], decimals=3) == -13.281
Example #11
0
def test_RA_ramp_resample():
    '''
    Matlab code:
    s = stim_ramp([],[],[],100,[],[],1);
    a = Afferent('RA','idx',1,'noisy',false);
    '''
    s = ts.stim_ramp(pin_radius=1., fs=100.)
    a = ts.Afferent('RA', idx=0, noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 7. - rate_slack
    assert r.rate()[0, 0] <= 7. + rate_slack
    assert r.spikes[0][0] >= 0.0088 - timing_slack
    assert r.spikes[0][0] <= 0.0088 + timing_slack
Example #12
0
def test_SA_ramp():
    '''
    Matlab code:
    s = stim_ramp([],[],[],[],[],[],1);
    a = Afferent('SA1','idx',1,'noisy',false);
    '''
    s = ts.stim_ramp(pin_radius=1.)
    a = ts.Afferent('SA1', idx=0, noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 22. - rate_slack
    assert r.rate()[0, 0] <= 22. + rate_slack
    assert r.spikes[0][0] >= 0.0062 - timing_slack
    assert r.spikes[0][0] <= 0.0062 + timing_slack
Example #13
0
def test_response_multiple3():
    s = [
        ts.stim_ramp(pin_radius=1.),
        ts.stim_sine(freq=250., amp=0.005, fs=1000.)
    ]
    a = ts.Afferent('PC', idx=0, noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 124.5 - rate_slack
    assert r.rate()[0, 0] <= 124.5 + rate_slack
    assert r.rate(sep=True)[0, 0] >= 3 - rate_slack
    assert r.rate(sep=True)[0, 0] <= 3 + rate_slack
    assert r.rate(sep=True)[0, 1] >= 246 - rate_slack
    assert r.rate(sep=True)[0, 1] <= 246 + rate_slack
    assert r.spikes[0][0] >= 0.0004 - timing_slack
    assert r.spikes[0][0] <= 0.0004 + timing_slack
    assert r._spikes[1][0][0] >= 0.0042 - timing_slack
    assert r._spikes[1][0][0] <= 0.0042 + timing_slack
Example #14
0
def test_stim_default():
    s = ts.stim_sine()
    s = ts.stim_noise()
    s = ts.stim_impulse()
    s = ts.stim_ramp()