Esempio n. 1
0
def test_response_multiple2():
    s = [
        ts.stim_sine(freq=250., amp=0.005, fs=1000.),
        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] >= 246. - rate_slack
    assert r.rate()[0, 0] <= 246. + rate_slack
    assert r.spikes[0][0] >= 0.0042 - timing_slack
    assert r.spikes[0][0] <= 0.0042 + timing_slack
Esempio n. 2
0
def test_static_2pin_async():
    '''
    Matlab code:
    s1 = stim_sine(10,0.5,90,[],[],[],[],0.5);
    s2 = stim_sine(10,0.5,0,[],[1 1],[],[],0.5);
    s = Stimulus([s1.trace s2.trace],[s1.location;s2.location],5000,0.5);
    a = Afferent('SA1','location',[.5 .5]);
    [~,stat_comp] = s.propagate(a,false);
    '''
    s = ts.stim_sine(freq=10, amp=0.5, phase=90., pin_radius=0.5)
    s += ts.stim_sine(freq=10, amp=0.5, pin_radius=0.5, loc=[1., 1.])
    a = ts.Afferent('SA1', location=[.5, .5])
    stat_comp, _, _ = s.propagate(a)

    assert np.around(max(stat_comp)[0], decimals=4) == 0.0061
Esempio n. 3
0
def test_dynamic_2pin_sync():
    '''
    Matlab code:
    s1 = stim_sine(10,0.5,0,[],[],[],[],0.5);
    s2 = stim_sine(10,0.5,0,[],[1 1],[],[],0.5);
    s = Stimulus([s1.trace s2.trace],[s1.location;s2.location],5000,0.5);
    a = Afferent('SA1','location',[.5 .5]);
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_sine(freq=10, amp=0.5, pin_radius=0.5)
    s += ts.stim_sine(freq=10, amp=0.5, pin_radius=0.5, loc=[1., 1.])
    a = ts.Afferent('SA1', location=[.5, .5])
    _, dyn_comp, _ = s.propagate(a)

    assert np.around(max(dyn_comp)[0], decimals=3) == 16.895
    assert np.around(min(dyn_comp)[0], decimals=3) == -16.895
Esempio n. 4
0
def test_profiledyn_1pin_sine():
    '''
    Matlab code:
    s = stim_sine(10,0.25,0);
    '''
    s = ts.stim_sine(freq=10, amp=0.25)

    assert np.around(max(s._profiledyn.flatten()), decimals=3) == 0.935
    assert np.around(min(s._profiledyn.flatten()), decimals=3) == -0.935
Esempio n. 5
0
def test_plot_response_mpl():
    renderer = hv.renderer('matplotlib')
    a = ts.affpop_hand(region='D2')
    s = ts.stim_sine(freq=50.,amp=0.1)
    r = a.response(s)
    obj = plot(r)
    obj = plot(r)[:,0:0.2]
    obj = plot(r,spatial=True)
    obj = plot(r,spatial=True,scale=False)[:,'RA']
Esempio n. 6
0
def test_static_1pin_sine():
    '''
    Matlab code:
    s = stim_sine(10,0.25,0);
    a = Afferent('SA1');
    [~,stat_comp] = s.propagate(a,false);
    '''
    s = ts.stim_sine(freq=10, amp=0.25)
    a = ts.Afferent('SA1')
    stat_comp, _, _ = s.propagate(a)

    assert np.around(max(stat_comp)[0], decimals=4) == 0.0107
Esempio n. 7
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)
Esempio n. 8
0
def test_waveprop_1pin_sine():
    '''
    Matlab code:
    s = stim_sine(10,0.25,0);
    a = Afferent('SA1','location',[1 1]);
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_sine(freq=10, amp=0.25)
    a = ts.Afferent('SA1', location=[1., 1.])
    _, dyn_comp, _ = s.propagate(a)

    assert np.around(max(dyn_comp)[0], decimals=3) == 2.390
    assert np.around(min(dyn_comp)[0], decimals=3) == -2.390
Esempio n. 9
0
def test_dynamic_1pin_sine():
    '''
    Matlab code:
    s = stim_sine(10,0.25,0);
    a = Afferent('SA1');
    [~,~,dyn_comp] = s.propagate(a,false);
    '''
    s = ts.stim_sine(freq=10, amp=0.25)
    a = ts.Afferent('SA1')
    _, dyn_comp, _ = s.propagate(a)

    assert np.around(max(dyn_comp)[0], decimals=3) == 10.391
    assert np.around(min(dyn_comp)[0], decimals=3) == -10.391
Esempio n. 10
0
def test_RA_sine():
    '''
    Matlab code:
    s = stim_sine(25,0.5,0);
    a = Afferent('RA','idx',1,'noisy',false);
    '''
    s = ts.stim_sine(freq=25., amp=0.5)
    a = ts.Afferent('RA', idx=0, noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 119. - rate_slack
    assert r.rate()[0, 0] <= 119. + rate_slack
    assert r.spikes[0][0] >= 0.0126 - timing_slack
    assert r.spikes[0][0] <= 0.0126 + timing_slack
Esempio n. 11
0
def test_SA_sine():
    '''
    Matlab code:
    s = stim_sine(10,0.5,0);
    a = Afferent('SA1','idx',1,'noisy',false);
    '''
    s = ts.stim_sine(freq=10., amp=0.5)
    a = ts.Afferent('SA1', idx=0, noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 43. - rate_slack
    assert r.rate()[0, 0] <= 43. + rate_slack
    assert r.spikes[0][0] >= 0.013 - timing_slack
    assert r.spikes[0][0] <= 0.013 + timing_slack
Esempio n. 12
0
def test_PC_sine_resample():
    '''
    Matlab code:
    s = stim_sine(250,0.005,0,[],[],1000);
    a = Afferent('PC','idx',1,'noisy',false);
    '''
    s = 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] >= 246. - rate_slack
    assert r.rate()[0, 0] <= 246. + rate_slack
    assert r.spikes[0][0] >= 0.0042 - timing_slack
    assert r.spikes[0][0] <= 0.0042 + timing_slack
Esempio n. 13
0
def test_PC_waveprop1():
    '''
    Matlab code:
    s = stim_sine(250,0.01,0);
    a = Afferent('PC','idx',1,'location',[25 0],'noisy',false);
    '''
    s = ts.stim_sine(freq=250., amp=0.01)
    a = ts.Afferent('PC', idx=0, location=[25., 0.], noisy=False)
    r = a.response(s)

    assert r.rate()[0, 0] >= 40. - rate_slack
    assert r.rate()[0, 0] <= 40. + rate_slack
    assert r.spikes[0][0] >= 0.0238 - timing_slack
    assert r.spikes[0][0] <= 0.0238 + timing_slack
Esempio n. 14
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
Esempio n. 15
0
def test_stim_default():
    s = ts.stim_sine()
    s = ts.stim_noise()
    s = ts.stim_impulse()
    s = ts.stim_ramp()