Changeset 84
- Timestamp:
- 01/12/08 21:42:26 (1 year ago)
- Files:
-
- trunk/analysis.py (modified) (2 diffs)
- trunk/benchmark.py (modified) (3 diffs)
- trunk/examples/retina/benchmark_noise.py (modified) (3 diffs)
- trunk/examples/retina/benchmark_retina.py (modified) (1 diff)
- trunk/examples/retina/make_all.py (modified) (5 diffs)
- trunk/examples/retina/retina.py (modified) (4 diffs)
- trunk/examples/retina/retina_nest2.py (modified) (8 diffs)
- trunk/examples/single_neuron/SpikeTrainPlay.wav (deleted)
- trunk/examples/single_neuron/benchmark_neuron_vs_noise.py (modified) (2 diffs)
- trunk/examples/single_neuron/benchmark_neuron_vs_signal.py (modified) (3 diffs)
- trunk/examples/single_neuron/benchmark_synaptic_strength.png (deleted)
- trunk/examples/single_neuron/benchmark_synaptic_strength.py (modified) (2 diffs)
- trunk/examples/single_neuron/playing_with_simple_single_neuron.py (modified) (1 diff)
- trunk/examples/single_neuron/simple_single_neuron.py (modified) (4 diffs)
- trunk/spikes.py (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/analysis.py
r78 r84 14 14 output. 15 15 16 >>> record(my_spike_train) 17 16 18 """ 17 19 18 20 19 21 # from the spike list 20 simtime_seconds = output.t_stop - output.t_start22 simtime_seconds = (output.t_stop - output.t_start)/1000. 21 23 #time = numpy.linspace(0, simtime_seconds , fs*simtime_seconds) 22 (trace,time) = numpy.histogram(output.spike_times , fs*simtime_seconds)24 (trace,time) = numpy.histogram(output.spike_times*1000., fs*simtime_seconds) 23 25 24 26 … … 39 41 40 42 see playing_with_simple_single_neuron.py for a sample use 43 44 >>> play(my_spike_train) 45 46 TODO: make it possible to play multiple spike trains in stereo 41 47 """ 42 48 trunk/benchmark.py
r78 r84 110 110 111 111 This will generate one file per experiment and a default 112 113 TODO : use a more sexy filename with: 114 name='' 115 for key in data_root['run'][experiment].keys(): 116 name = name+'_'+key+'_'+str(data_root['run'][experiment][key]) 112 117 """ 113 118 if experiment == '': … … 144 149 # HIGHER-LEVEL FUNCTIONS 145 150 def list_param(self,param): 146 """ Lists values for param in experiments , a bitthe reverse of get_experiment_dict151 """ Lists values for param in experiments = the reverse of get_experiment_dict 147 152 148 153 """ … … 208 213 Execute all experiments from experiment_list. 209 214 210 This should be a batch o sf experiments to launch on one core.215 This should be a batch of experiments to launch on one core. 211 216 212 217 """ trunk/examples/retina/benchmark_noise.py
r77 r84 50 50 pylab.xlabel('Noise amplitude') 51 51 pylab.axis('tight') 52 pylab.savefig(benchmark. filename + '/benchmark_noise.png')#, dpi=300) #52 pylab.savefig(benchmark.name + '/benchmark_noise.png')#, dpi=300) # 53 53 #command = 'epstopdf "%s" "%s"'% (pdffile, psfile) 54 54 #os.system(command) … … 71 71 tag = 'test' # going OO 72 72 73 filename = 'results/' + tag + '_benchmark_noise'73 name = 'results/' + tag + '_benchmark_noise' 74 74 75 75 # create the list of experiments as all possibilities accross parameter vectors … … 77 77 78 78 # create benchmark (or open it if it exists) 79 B = benchmark.Benchmark( filename,ret,run)79 B = benchmark.Benchmark(name,ret,run) 80 80 # there are many ways to get data from the benchmark. see benchmark.py 81 81 B.run_simulations() trunk/examples/retina/benchmark_retina.py
r78 r84 193 193 194 194 figure_format , dpi = '.png' , 150 195 figure1(benchmark. filename + '/benchmark_retina' + figure_format,dpi)196 figure2(benchmark. filename + '/benchmark_retina_CRF' + figure_format,dpi)197 figure3(benchmark. filename + '/benchmark_retina_input' + figure_format,dpi)195 figure1(benchmark.name + '/benchmark_retina' + figure_format,dpi) 196 figure2(benchmark.name + '/benchmark_retina_CRF' + figure_format,dpi) 197 figure3(benchmark.name + '/benchmark_retina_input' + figure_format,dpi) 198 198 199 199 if __name__ == '__main__': trunk/examples/retina/make_all.py
r78 r84 33 33 ### testing the noise response 34 34 import benchmark_noise 35 filename = 'results/' + tag + '_benchmark_noise'35 name = 'results/' + tag + '_benchmark_noise' 36 36 ret = Retina(N) 37 37 # create the list of experiments as all possibilities accross parameter vectors 38 38 run = get_experiment_dict({'noise_std':linspace(.10,4.0,N_exp), 'snr' : [ 0.0 ]}) 39 39 # create benchmark (or open it if it exists) 40 B = Benchmark( filename,ret,run)40 B = Benchmark(name,ret,run) 41 41 # there are many ways to get data from the benchmark. see benchmark.py 42 42 B.run_simulations() … … 45 45 ### testing the linear response 46 46 import benchmark_linear 47 filename = 'results/' + tag + '_benchmark_linear'47 name = 'results/' + tag + '_benchmark_linear' 48 48 49 49 ret = Retina(N) … … 51 51 52 52 run = get_experiment_dict({'snr' : 10.**(linspace(-.50,.75,N_exp))}) 53 B = Benchmark( filename,ret,run)53 B = Benchmark(name,ret,run) 54 54 B.run_simulations() 55 55 benchmark_linear.show(B) … … 58 58 import benchmark_retina 59 59 60 filename = 'results/' + tag + '_benchmark_retina'60 name = 'results/' + tag + '_benchmark_retina' 61 61 ret = Retina(N) 62 62 snr = ret.params['snr'] * 10.**(linspace(-.50,.75,N_exp)) … … 64 64 run = get_experiment_dict({'snr':snr,'kernelseed':seeds}) 65 65 66 B = Benchmark( filename,ret,run)66 B = Benchmark(name,ret,run) 67 67 B.run_simulations() 68 68 benchmark_retina.show(B) trunk/examples/retina/retina.py
r78 r84 72 72 import datetime 73 73 74 from NeuroTools.spikes import tmpfile2spikelist74 from NeuroTools.spikes import loadSpikeList 75 75 from NeuroTools.benchmark import Model 76 76 import pyNN.nest1 as sim … … 219 219 220 220 # TODO LUP use something like "for pop in [phr, out]" ? 221 out_ON.printSpikes(out_ON_filename)#,compatible_output=False)222 out_OFF.printSpikes(out_OFF_filename)#,compatible_output=False)223 224 # TODO LUP get out_ON_DATA on a 2D grid independantly of out_ON.cell.astype(int)225 221 out_ON_filename=os.path.join(tmpdir,'out_on.gdf') 226 222 out_OFF_filename=os.path.join(tmpdir,'out_off.gdf') 227 out_ON_DATA = tmpfile2spikelist(out_ON_filename,N, 228 t_start=0.0, t_stop=params['simtime']/1000.) 229 out_OFF_DATA = tmpfile2spikelist(out_OFF_filename,N, 230 t_start=0.0, t_stop=params['simtime']/1000.) 223 out_ON.printSpikes(out_ON_filename)# 224 out_OFF.printSpikes(out_OFF_filename)# 225 226 # TODO LUP get out_ON_DATA on a 2D grid independantly of out_ON.cell.astype(int) 227 out_ON_DATA = loadSpikeList(out_ON_filename,range(N), 228 t_start=0.0, t_stop=params['simtime']) 229 out_OFF_DATA = loadSpikeList(out_OFF_filename,range(N), 230 t_start=0.0, t_stop=params['simtime']) 231 231 232 232 out = {'out_ON_DATA':out_ON_DATA, … … 285 285 ax.set_ylabel('X') 286 286 ax.set_zlabel('Y') 287 ax.set_xlim([0,self.params['simtime'] /1000.])287 ax.set_xlim([0,self.params['simtime']]) 288 288 pylab.show() 289 289 #### spike_time=numpy.cumsum(out_ON_DATA[:,0]) * ret.params['dt'] … … 311 311 #ret.params['noise_std'] = 4.0 312 312 #ret.params['snr'] = 5.0 313 out = ret.run( )313 out = ret.run(ret.params) 314 314 ret.show(out) #(ret.params) 315 315 trunk/examples/retina/retina_nest2.py
r77 r84 10 10 ( https://facets.kip.uni-heidelberg.de/private/wiki/index.php/V1_hypercolumn#Benchmark_one ) 11 11 12 : This version uses specifically nest2 calls 12 : This version uses specifically nest2 calls 13 13 14 14 … … 18 18 import datetime 19 19 20 from NeuroTools.s andbox import tmpfile2spikelist20 from NeuroTools.spikes import loadSpikeList 21 21 from NeuroTools.benchmark import Model 22 22 import pyNN.nest2 as sim … … 67 67 ## 'TauSyn_I': 10.0, 'V_reversal_sfa': -70.0, 'q_sfa': 0., #14.48, 68 68 ## 'Tau_sfa':110.0, 'V_reversal_relref': -70.0, 'q_relref': 3214.0, 69 ## 'Tau_relref': 1.97}#,'python':True} 69 ## 'Tau_relref': 1.97}#,'python':True} 70 70 self.params['parameters_gc'] = {'v_thresh':-57.0, 'v_reset': -70.0, 71 'v_init': -63.0, 'tau_m': 0.5, 'cm':289.5, 71 'v_init': -63.0, 'tau_m': 0.5, 'cm':289.5, 72 72 'e_rev_E': 0.0, 'e_rev_I': -75.0, 'tau_syn_E':1.5, 'tau_syn_I': 10.0} 73 73 74 74 # default input image # TODO add start and stop time 75 75 … … 101 101 N = params['N'] 102 102 #dc_generator 103 phr_ON = sim.Population( (N,N),'dc_generator')104 phr_OFF = sim.Population( (N,N),'dc_generator')103 phr_ON = sim.Population(N,'dc_generator') 104 phr_OFF = sim.Population(N,'dc_generator') 105 105 for phr in [phr_ON, phr_OFF]: 106 106 phr.set({ 'start' : params['simtime']/4, 'stop' : params['simtime']/4*3}) 107 107 108 108 # TODO LUP : justify this noise model 109 noise_ON = sim.Population( (N,N),'noise_generator',{'mean':0.,'std':params['noise_std']})110 noise_OFF = sim.Population( (N,N),'noise_generator',{'mean':0.,'std':params['noise_std']})109 noise_ON = sim.Population(N,'noise_generator',{'mean':0.,'std':params['noise_std']}) 110 noise_OFF = sim.Population(N,'noise_generator',{'mean':0.,'std':params['noise_std']}) 111 111 112 112 phr_ON.tset('amplitude', params['amplitude'] * params['snr']) … … 114 114 115 115 # target ON and OFF populations (what about a tridimensional Population?) 116 out_ON = sim.Population( (N,N) , sim.IF_cond_alpha,params['parameters_gc'])#'iaf_sfa_neuron')#)#sim.IF_curr_alpha)# sim.IF_cond_alpha)#,params['parameters_gc'])#'iaf_cond_neuron')# IF_cond_alpha) #117 out_OFF = sim.Population( (N,N) ,sim.IF_cond_alpha,params['parameters_gc'])# 'iaf_sfa_neuron',params['parameters_gc'])#sim.IF_curr_alpha)#'iaf_sfa_neuron')116 out_ON = sim.Population(N , sim.IF_cond_alpha)#,params['parameters_gc'])#'iaf_sfa_neuron')#)#sim.IF_curr_alpha)# sim.IF_cond_alpha)#,params['parameters_gc'])#'iaf_cond_neuron')# IF_cond_alpha) # 117 out_OFF = sim.Population(N ,sim.IF_cond_alpha)#,params['parameters_gc'])# 'iaf_sfa_neuron',params['parameters_gc'])#sim.IF_curr_alpha)#'iaf_sfa_neuron') 118 118 # initialize membrane potential TODO: and conductances? 119 119 # TODO just store the seed 120 120 numpy.random.seed(params['kernelseed']) 121 121 122 for out_ in [out_ON, out_OFF]:123 V_init = params['parameters_gc']['v_init'] + numpy.random.rand(N,N)*(params['parameters_gc']['v_thresh'] - params['parameters_gc']['v_reset'])124 out_.tset('v_init',V_init)122 ## for out_ in [out_ON, out_OFF]: 123 ## V_init = params['parameters_gc']['v_init'] + numpy.random.rand(N,N)*(params['parameters_gc']['v_thresh'] - params['parameters_gc']['v_reset']) 124 ## out_.tset('v_init',V_init) 125 125 ## alternatively 126 126 ## >>> from pyNN.random import RandomDistribution … … 133 133 for (pre, post) in [(phr_ON,out_ON), (noise_ON,out_ON),(phr_OFF,out_OFF), (noise_OFF,out_OFF)]: 134 134 sim.nest.ConnectWD(pre.cell.flatten().tolist(),post.cell.flatten().tolist(),[params['weight']],[10.0]) 135 135 136 136 ## retina_proj_ON = sim.Projection(phr_ON, out_ON, 'oneToOne') 137 137 ## #print type(params['weight']) # TODO: fix numpy.float64 problem … … 146 146 ## noise_proj_OFF.setWeights(params['weight'])#* numpy.ones((N,N)) 147 147 148 out_ON_filename= os.path.join(tmpdir,'out_on.gdf')149 out_OFF_filename= os.path.join(tmpdir,'out_off.gdf')148 out_ON_filename=tmpdir+'out_on.gdf'#os.path.join(tmpdir,'out_on.gdf') 149 out_OFF_filename=tmpdir+'out_on.gdf'#os.path.join(tmpdir,'out_off.gdf') 150 150 151 151 out_ON.record() … … 167 167 168 168 # TODO LUP get out_ON_DATA on a 2D grid independantly of out_ON.cell.astype(int) 169 out_ON_DATA = tmpfile2spikelist(out_ON_filename + '-0',params['dt'])#,compatible_output=False) 170 out_OFF_DATA = tmpfile2spikelist(out_OFF_filename + '-0',params['dt'])#,compatible_output=False) 169 out_ON_DATA = loadSpikeList(out_ON_filename,range(N), 170 t_start=0.0, t_stop=params['simtime']/1000.) 171 out_OFF_DATA = loadSpikeList(out_OFF_filename,range(N), 172 t_start=0.0, t_stop=params['simtime']/1000.) 171 173 out = {'out_ON_DATA':out_ON_DATA,'out_OFF_DATA':out_OFF_DATA} 172 174 # cleans up 173 os.remove(out_ON_filename + '-0')174 os.remove(out_OFF_filename + '-0')175 os.remove(out_ON_filename) 176 os.remove(out_OFF_filename) 175 177 os.rmdir(tmpdir) 176 178 trunk/examples/single_neuron/benchmark_neuron_vs_noise.py
r78 r84 43 43 if __name__ == '__main__': 44 44 45 filename = 'results/benchmark_neuron_vs_noise'45 name = 'results/benchmark_neuron_vs_noise' 46 46 47 47 myFibers = model.FiberChannel() … … 49 49 run = benchmark.get_experiment_dict({'snr' :[0], 'noise_std' : 10.**(numpy.linspace(-.50,2.,25))}) 50 50 51 B = benchmark.Benchmark( filename,myFibers,run)51 B = benchmark.Benchmark(name,myFibers,run) 52 52 B.run_simulations() 53 53 show(B) trunk/examples/single_neuron/benchmark_neuron_vs_signal.py
r78 r84 23 23 24 24 """ 25 from numpy import sin, cos, pi, zeros 25 from numpy import sin, cos, pi, zeros, where 26 26 params = benchmark.get('params') 27 27 N, simtime = params['N'], params['simtime'] 28 28 experiments = benchmark.list_experiments() 29 noise_list = benchmark.list_param('noise_std') 30 n_noise = len(noise_list) 31 n_snr = len(experiments) / len(noise_list) 32 noise, snr, CRF = zeros(n_noise),zeros((n_noise,n_snr)), zeros((n_noise,n_snr)) 33 for i_noise, noise in enumerate(noise_list): 34 snr_list = benchmark.list_where('noise_std',noise) 35 noise[i_noise] = benchmark.get('experiments')[experiment]['noise_std'] 36 37 for i_snr, experiment in enumerate(snr_list): 38 out_ON_DATA = benchmark.get('out',experiment).as_list_id_list_time() 39 snr[i_noise,i_snr] = benchmark.get('experiments')[experiment]['snr'] 40 spikes_during_signal = where((out_ON_DATA[1]/simtime-1/2)<1/4) 41 CRF[i_noise,i_snr] = len(spikes_during_signal) / N / simtime 29 #noise_list = benchmark.list_param('noise_std') 30 #n_noise = len(noise_list) 31 n_snr = len(experiments) #/ len(noise_list) 32 noise, snr, CRF = zeros(n_snr),zeros(n_snr), zeros(n_snr) 33 ## for i_noise in noise_list: 34 ## snr_list = benchmark.list_where('noise_std',noise) 35 ## 36 ## for i_snr, experiment in enumerate(snr_list): 37 ## out_ON_DATA = benchmark.get('out',experiment).as_list_id_list_time() 38 ## #print noise#out_ON_DATA 39 ## snr[i_noise,i_snr] = benchmark.get('experiments')[experiment]['snr'] 40 ## #spikes_during_signal = where((out_ON_DATA[1]/simtime-1/2)<1/4) 41 ## spikes_during_signal = where((out_ON_DATA[1]>simtime/4)&(out_ON_DATA[1]<3*simtime/4)) # more elegant 42 ## CRF[i_noise,i_snr] = len(spikes_during_signal) / N / simtime 43 for i_exp,experiment in enumerate(experiments): 44 out_SL = benchmark.get('out',experiment)#.as_list_id_list_time() 45 snr[i_exp] = benchmark.get('experiments')[experiment]['snr'] 46 noise[i_exp] = benchmark.get('experiments')[experiment]['noise_std'] 47 #TODO use subSpikeList 48 #spikes_during_signal = where((out_ON_DATA[1]>simtime/4)&(out_ON_DATA[1]<3*simtime/4)) # more elegant 49 CRF[i_exp] = out_SL.mean_rate()# len(spikes_during_signal) / N / simtime 42 50 43 51 44 52 #pylab.subplot(111) 45 pylab. plot(snr,CRF,'o', color = (sin(2*pi*noise)**2,cos(2*pi*noise)**2,1))53 pylab.scatter(snr,CRF, c = noise) #color = (sin(2*pi*noise_list)**2,cos(2*pi*noise_list)**2,1)) 46 54 pylab.ylabel('Firing Frequency (Hz)') 47 55 pylab.xlabel('Signal (nA?)') 56 pylab.colorbar() 48 57 pylab.axis('tight') 49 58 pylab.savefig('results/benchmark_neuron_vs_signal.png') # … … 51 60 if __name__ == '__main__': 52 61 53 filename = 'results/benchmark_neuron_vs_signal_and_noise'62 name = 'results/benchmark_neuron_vs_signal_and_noise' 54 63 55 64 myFibers = model.FiberChannel() … … 59 68 'snr' : numpy.linspace(-4.,4.,N_exp)}) 60 69 61 B = benchmark.Benchmark( filename,myFibers,run)70 B = benchmark.Benchmark(name,myFibers,run) 62 71 B.run_simulations() 63 72 show(B) trunk/examples/single_neuron/benchmark_synaptic_strength.py
r78 r84 42 42 if __name__ == '__main__': 43 43 44 filename = 'results/benchmark_synaptic_strength'44 name = 'results/benchmark_synaptic_strength' 45 45 46 46 myFibers = model.FiberChannel() … … 49 49 run = benchmark.get_experiment_dict({'weight' : 10.**(numpy.linspace(-.50,.75,N_exp))}) 50 50 51 B = benchmark.Benchmark( filename,myFibers,run)51 B = benchmark.Benchmark(name,myFibers,run) 52 52 B.run_simulations() 53 53 show(B) trunk/examples/single_neuron/playing_with_simple_single_neuron.py
r78 r84 13 13 14 14 myFibers = model.FiberChannel() 15 myFibers.params['simtime'] = 4.*10**3 # 4 seconds16 15 myFibers.params['N'] = 1 # 17 16 trunk/examples/single_neuron/simple_single_neuron.py
r79 r84 19 19 import sys, os, tempfile 20 20 import pyNN.nest1 as sim 21 from NeuroTools.spikes import tmpfile2spikelist21 from NeuroTools.spikes import loadSpikeList 22 22 from NeuroTools.benchmark import Model 23 23 … … 58 58 59 59 # internal noise model 60 print params['noise_std']61 60 noise = sim.Population(N,'noise_generator',{'mean':0.,'std':params['noise_std']}) 62 61 … … 90 89 output_filename=os.path.join(tmpdir,'output.gdf') 91 90 output.printSpikes(output_filename)# 92 output_DATA = tmpfile2spikelist(output_filename,N,93 t_start=0.0, t_stop=params['simtime'] /1000.)91 output_DATA = loadSpikeList(output_filename,N, 92 t_start=0.0, t_stop=params['simtime']) 94 93 95 94 … … 100 99 print "Number of Neurons : ", N 101 100 #print "Input rate : ", input.meanSpikeCount(), "spikes/neuron in ", params['simtime'], "ms" 102 print " Output rate : ", output.meanSpikeCount(), "spikes/neuron in",params['simtime'], "ms"101 print "Mean Output rate : ", output_DATA.mean_rate(), " during ",params['simtime'], "ms" 103 102 print "Build time : ", buildCPUTime, "s" 104 103 print "Simulation time : ", simCPUTime, "s" trunk/spikes.py
r83 r84 14 14 This class defines a spike train as a list of the events times. 15 15 16 Event times are given in a list (sparse representation) in ISO units (seconds).16 Event times are given in a list (sparse representation) in milliseconds. 17 17 18 18 >>> s1 = SpikeTrain([0.0, 0.1, 0.2, 0.5]) … … 34 34 def __init__(self, spike_times, dt=None, t_start=None, t_stop=None): 35 35 """ 36 `spike_times` is a list/numpy array of spike times (in seconds)36 `spike_times` is a list/numpy array of spike times (in milliseconds) 37 37 38 38 TODO: We proposed innitially that : 39 39 If `dt`is specified, the time values should be ints, 40 40 and will be multiplied by `dt`, otherwise time values should be floats. 41 42 this is confusing. All times should be in seconds. period. 41 Markus suggested that the internal representation should be integer and that analysis methods also. 43 42 44 43 If `t_start` and `t_stop` are not specified, they are inferred from the data. … … 128 127 def time_axis(self, binwidth): 129 128 return numpy.arange(self.t_start, self.t_stop, binwidth) 130 131 129 130 132 131 def subSpikeTrain(self, t_start, t_stop): 133 132 idx = numpy.where((self.spike_times >= t_start) & (self.spike_times <= t_stop))[0] … … 147 146 148 147 if normalized: 149 hist *= 1000.0/binwidth # TODO why 1000.0 ?? we are using seconds everywhere148 hist *= 1000.0/binwidth 150 149 return hist 151 150 … … 300 299 301 300 301 def concatenate(SpikeList_list): 302 # We check that Spike Lists have similar time_axis 303 sl_=SpikeList_list[0] 304 for sl in SpikeList_list: 305 if not((sl.t_start==sl_.t_start)&(sl.t_stop==sl_.t_stop)&(sl.dt==sl_.dt)): 306 raise Exception("Spike Lists should have similar time_axis") 307 308 new_SpkList = SpikeList([], [], self.dt, self.t_start, self.t_stop) 309 for sl in SpikeList_list: 310 for id in sl.id_list: 311 new_SpkList.append(id, sl.spiketrains[id]) 312 return new_SpkList 313 314 302 315 def idsubSpikeList(self, id_list): 303 316 # We check what are the elements that are in self.id_list and not in … … 315 328 """ 316 329 returns a new SpikeList 317 330 318 331 """ 319 332 new_SpkList = SpikeList([], [], self.dt, t_start, t_stop) … … 405 418 def cv_isi(self, nbins=100, display=False): 406 419 cvs_isi = [] 407 for idx,id in enumerate(self.id_list): 420 for idx,id in enumerate(self.id_list): 408 421 isi = self.spiketrains[id].isi() 409 422 if len(isi) > 1: … … 462 475 Calculate firing rate traces (in Hz) from arrays of spike times. 463 476 464 Spike times and binwidth should are in seconds.477 Spike times and binwidth should are in milliseconds. 465 478 Returns a tuple (list_of_firing_rate_traces,bins) 466 479 467 >>> pylab.plot(output[0].time_axis( 0.02),sum(output.firing_rate(0.02)))480 >>> pylab.plot(output[0].time_axis(dt),sum(output.firing_rate(dt))) 468 481 """ 469 482 return self.spike_histogram(binwidth, normalized=True, display=display) … … 475 488 fano = numpy.var(firing_rate)/numpy.mean(firing_rate) 476 489 return fano 477 478 490 491 479 492 def pairwise_correlation(self): 480 493 pass … … 521 534 def population2spikelist(output, N, dt , t_start, t_stop): 522 535 """ 523 WARNING: all times in ms in PyNN, in seconds here. 524 536 TODO sl2pynn 525 537 """ 526 538 import os, tempfile … … 529 541 output_filename=os.path.join(tmpdir,'output.gdf') 530 542 output.printSpikes(output_filename)# 531 output_DATA = tmpfile2spikelist(output_filename, N= N, dt = dt, t_start=t_start, t_stop=t_stop)543 output_DATA = loadSpikeList(output_filename, N= N, dt = dt, t_start=t_start, t_stop=t_stop) 532 544 os.remove(output_filename) 533 545 os.rmdir(tmpdir) … … 538 550 myfile = open(filename, "r", 10000) 539 551 contents = myfile.readlines() 540 myfile.close() 552 myfile.close() 541 553 data = [] 542 554 for line in contents: … … 557 569 since last event, neuron_id); neuron_id and time are integers 558 570 559 All times in seconds.571 All times in milliseconds. 560 572 561 573 The PyNN-NEST format (with compatible_output=True) is: … … 565 577 566 578 """ 579 if isinstance(id_list,int): # allows to just specify the number of neurons 580 id_list = range(id_list) 567 581 spikes = readSpikeFile(filename) 568 582 return SpikeList(spikes, id_list, dt, t_start, t_stop)

