def test_affpop_iadd(): a = ts.AfferentPopulation(ts.Afferent('SA1')) a2 = ts.Afferent('RA') ap = ts.AfferentPopulation(ts.Afferent('RA'), ts.Afferent('PC')) a += a2 assert len(a) == 2 assert len(a2) == 1 a += ap assert len(a) == 4 assert len(ap) == 2
def test_affpop_add(): a = ts.AfferentPopulation(ts.Afferent('SA1')) a2 = ts.Afferent('RA') ap = ts.AfferentPopulation(ts.Afferent('RA'), ts.Afferent('PC')) a_new = a + a2 assert len(a_new) == 2 assert len(a) == 1 assert len(a2) == 1 a_new = a + ap assert len(a_new) == 3 assert len(a) == 1 assert len(ap) == 2
def test_response_multiple1(): 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
def test_affpop_region_index(): a = ts.AfferentPopulation(ts.Afferent('SA1', surface=ts.hand_surface)) assert len(a['D2d']) == 1 assert a['D2d'].region[0][0] == 'D2d_t'