def testShotNoiseFromSpikes(self): stg = stgen.StGen() from numpy import array st = stg.poisson_generator(10.0,0.0,1000.0) ge = stgen.shotnoise_fromspikes(st,2.0,10.0,dt=0.1) assert ge.t_start==0.0 assert ge.t_stop==1000.0 st = stg.poisson_generator(10.0,0.0,1000.0) ge = stgen.shotnoise_fromspikes(st,2.0,10.0,dt=0.1,t_start=500.0,t_stop=1500.0) assert ge.t_start==500.0 assert ge.t_stop==1500.0
def testShotNoiseFromSpikes(self): stg = stgen.StGen() from numpy import array st = stg.poisson_generator(10.0, 0.0, 1000.0) ge = stgen.shotnoise_fromspikes(st, 2.0, 10.0, dt=0.1) assert ge.t_start == 0.0 assert ge.t_stop == 1000.0 st = stg.poisson_generator(10.0, 0.0, 1000.0) ge = stgen.shotnoise_fromspikes(st, 2.0, 10.0, dt=0.1, t_start=500.0, t_stop=1500.0) assert ge.t_start == 500.0 assert ge.t_stop == 1500.0
# generate shot noise from step poisson from NeuroTools import stgen clf() stg = stgen.StGen() rate = numpy.array([6.0,10.0,6.0,6.0]) t = numpy.array([0.0,100.0,200.0,300.0]) q = 2.0 tau = 10.0 trials = 1000 st = stg.inh_poisson_generator(rate, t, 300.0) g,tsn = stgen.shotnoise_fromspikes(st,q,tau,dt=0.1,t_start=0.0,t_stop=300.0,array=True) for i in range(trials-1): st = stg.inh_poisson_generator(rate, t, 300.0) g_tmp,tmp = stgen.shotnoise_fromspikes(st,q,tau,dt=0.1,t_start=0.0,t_stop=300.0,array=True) g+=g_tmp plot(t,rate,'b:',ls='steps-post',lw=2) plot(tsn,g/q/tau/trials*1000.0,'r-',lw=2) xlabel('time [ms]',size=20) xticks(size=16) ylabel(r'$\nu(t)$ [Hz]',size=20) yticks(size=16)
clf() stg = stgen.StGen() rate = numpy.array([6.0, 10.0, 6.0, 6.0]) t = numpy.array([0.0, 100.0, 200.0, 300.0]) q = 2.0 tau = 10.0 trials = 1000 st = stg.inh_poisson_generator(rate, t, 300.0) g, tsn = stgen.shotnoise_fromspikes(st, q, tau, dt=0.1, t_start=0.0, t_stop=300.0, array=True) for i in range(trials - 1): st = stg.inh_poisson_generator(rate, t, 300.0) g_tmp, tmp = stgen.shotnoise_fromspikes(st, q, tau, dt=0.1, t_start=0.0, t_stop=300.0, array=True) g += g_tmp plot(t, rate, 'b:', ls='steps-post', lw=2)
pylab.plot(time_axis, cc, label = 'no correlation', alpha = 0.5) # inject correlation into st1 and st2 st3 = sg.poisson_generator(rate = rate_shared, t_stop = duration) st1.merge(st3) st2.merge(st3) cc2 = numpy.correlate(st1.time_histogram(time_bin = 1.), st2.time_histogram(time_bin = 1.), mode = 'same') pylab.plot(time_axis, cc2, label = '10% correlation', alpha = 0.5) pylab.legend() pylab.show() #generate shot noise from st1 st1_shot = stgen.shotnoise_fromspikes(st1, q = 1.0, tau = 10., t_start = st1.t_start, t_stop = st1.t_stop) f = pylab.figure() pylab.plot(st1_shot.signal) f.gca().set_title('shot noise') f.gca().set_xlabel('time [ms]') # spike triggered average reveals the original shot-noise kernel sta = st1_shot.event_triggered_average(st1, display = True, average = True)