Changeset 326
- Timestamp:
- 11/12/08 19:49:46 (2 months ago)
- Files:
-
- trunk/examples/parameter_search/parameter_search_example.py (modified) (1 diff)
- trunk/examples/retina/benchmark_linear.py (modified) (3 diffs, 1 prop)
- trunk/examples/retina/benchmark_noise.py (modified) (2 diffs, 1 prop)
- trunk/examples/retina/benchmark_retina.py (modified) (10 diffs, 1 prop)
- trunk/examples/retina/make_all.py (modified) (1 prop)
- trunk/examples/retina/results/fig-benchmark_linear.png (modified) (previous)
- trunk/examples/retina/results/fig-benchmark_noise.png (modified) (previous)
- trunk/examples/retina/retina.py (modified) (4 diffs, 1 prop)
- trunk/examples/retina/test_parallel.py (modified) (1 prop)
- trunk/examples/single_neuron/CRF_neuron_vs_signal.py (modified) (2 diffs, 1 prop)
- trunk/examples/single_neuron/playing_with_simple_single_neuron.py (modified) (1 prop)
- trunk/examples/single_neuron/simple_single_neuron.py (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/parameter_search/parameter_search_example.py
r301 r326 49 49 """ 50 50 #set up the network 51 import pyNN.ne uronas sim51 import pyNN.nest2 as sim 52 52 sim.setup(dt = 0.01, min_delay = 1., max_delay = 1., debug = False, 53 53 quit_on_end = False) trunk/examples/retina/benchmark_linear.py
- Property svn:keywords set to Id
r220 r326 19 19 20 20 N, N_exp = 1000, 6 21 p = ParameterSet({})22 21 t_smooth = 100. # width (in ms) of the integration window 23 22 from retina import * 24 23 retina = Retina(N) 24 retina.params['amplitude'] = 1 25 snr = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 26 p = ParameterSpace({'snr' : ParameterRange(list(snr))}) 27 25 28 26 29 name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part … … 33 36 34 37 except: 35 snr = retina.params['snr']* numpy.linspace(0.1,2.0,N_exp) 36 p.snr = ParameterRange(list(snr)) 38 37 39 # calculates the dimension of the parameter space 38 40 results_dim, results_label = p.parameter_space_dimension_labels() … … 78 80 79 81 """ 80 pylab.close('all') 81 pylab.rcParams.update(pylab_params(fig_width_pt = 497.9/2., ratio = 1.)) 82 pylab.figure(num = 1, dpi=150, facecolor='w', edgecolor='k') 83 Lmargin, Rmargin, dmargin, umargin = 0.2, 0.05, 0.15, 0.05 84 pylab.axes([Lmargin, dmargin , 1.0 - Rmargin- Lmargin,1.0-umargin-dmargin]) # [left, bottom, width, height] 82 #pylab.close('all') 83 #pylab.rcParams.update(pylab_params(fig_width_pt = 497.9/2., ratio = 1.)) 84 pylab.figure(1) 85 fmax = numpy.max([numpy.max(temporal_OFF[:]),numpy.max(temporal_ON[:])]) 85 86 87 pylab.subplot(211) 86 88 for i_exp in range(N_exp): 87 pylab.plot(lower_edges, # TODO add a half bin 88 temporal_ON[i_exp])#, 89 # label= 'snr=' + str(benchmark.get('experiments')[experiment]['snr'])) 90 #pylab.subplot(121) 91 #pylab.title('time course')# ON 89 pylab.plot(lower_edges[:-1] + t_smooth/2, # TODO add a half bin 90 temporal_ON[i_exp])# 92 91 pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 93 pylab.ylabel('Firing frequency (Hz)') 92 pylab.ylabel('ON Firing frequency (Hz/neuron)') 93 pylab.axis([0, retina.params.simtime, 0.0, fmax]) 94 pylab.subplot(212) 95 for i_exp in range(N_exp): 96 pylab.plot(lower_edges[:-1] + t_smooth/2, # TODO add a half bin 97 temporal_OFF[i_exp], 98 label= 'snr= %5.3f' % p.snr._values[i_exp] ) 99 pylab.xticks( numpy.round(numpy.linspace(0, retina.params.simtime, 5),0) ) 100 pylab.ylabel('OFF Firing frequency (Hz/neuron)') 94 101 pylab.xlabel('time (ms)') 95 pylab.axis( 'tight')102 pylab.axis([0, retina.params.simtime, 0.0, fmax ]) 96 103 97 #pylab.legend()104 pylab.legend(loc='upper right') 98 105 99 #pylab.subplot(122)100 #pylab.title('time course OFF')101 #pylab.xticks( numpy.linspace(0, simtime, 5) )102 #pylab.ylabel('firing frequency (Hz)')103 #pylab.axis('tight')104 #pylab.xlabel('time (ms)')105 #pylab.legend()106 106 107 pylab.savefig('results/fig-' + name + '.pdf') 108 pylab.savefig('results/fig-' + name + '.png', dpi = 300) 107 if 0: 108 pylab.ion() 109 #pylab.show() 110 else: 111 pylab.savefig('results/fig-' + name + '.pdf') 112 pylab.savefig('results/fig-' + name + '.png', dpi = 300) 109 113 110 #TODO: make a plot showing it's the right point process with a histogramtrunk/examples/retina/benchmark_noise.py
- Property svn:keywords set to Id
r172 r326 25 25 import progressbar # see http://projects.scipy.org/pipermail/scipy-dev/2008-January/008200.html 26 26 27 N, N_exp_noise = 100 , 2228 p = ParameterSet({}) 29 p .noise_std = ParameterRange(list(10.**(numpy.linspace(-.50,1.,N_exp_noise))))27 N, N_exp_noise = 1000, 22 28 29 p = ParameterSpace({'noise_std' : ParameterRange(list(10.**(numpy.linspace(-.50,1.,N_exp_noise))))}) 30 30 31 31 import retina as model 32 33 34 32 retina = model.Retina(N) 35 33 retina.params['snr'] = 0 # no input … … 87 85 pylab.xlabel('Noise amplitude') 88 86 89 pylab.savefig('results/fig-' + name + '.pdf')90 pylab.savefig('results/fig-' + name + '.png', dpi = 300)91 87 88 if 0: 89 pylab.show() 90 else: 91 pylab.savefig('results/fig-' + name + '.pdf') 92 pylab.savefig('results/fig-' + name + '.png', dpi = 300) 93 94 95 #TODO: make a plot showing that spontaneous activity is a point process with a known histogram trunk/examples/retina/benchmark_retina.py
- Property svn:keywords set to Id
r172 r326 28 28 29 29 N, N_snr, N_seeds = 1000, 5, 10 30 p = ParameterSet({}) 30 from retina import * 31 retina = Retina(N) 32 31 33 t_smooth = 100. # ms. integration time to show fiber activity 32 34 33 from retina import * 34 retina = Retina(N) 35 p.snr = ParameterRange(list(retina.params['snr']* numpy.linspace(0.1,2.0,N_snr))) 36 p.kernelseed = ParameterRange(list([retina.params['kernelseed'] + k for k in range(N_seeds)])) 35 p = ParameterSpace({ 36 'snr' : ParameterRange(list(numpy.linspace(0.1,2.0,N_snr))), 37 'kernelseed' : ParameterRange(list([retina.params['kernelseed'] + k for k in range(N_seeds)]))}) 38 37 39 38 40 name = sys.argv[0].split('.')[0] # name of the current script withpout the '.py' part 39 40 41 #### MAKING THE SIMULATIONS ########## 41 42 results = shelve.open('results/mat-' + name) … … 43 44 DATA = results['DATA'] 44 45 except: 45 46 46 47 # calculates the dimension of the parameter space 47 48 results_dim, results_label = p.parameter_space_dimension_labels() … … 55 56 params.update(experiment) # updates what changed in the dictionary 56 57 # simulate the experiment and get its data 57 data = retina.run(params ,verbose=False)58 data = retina.run(params)#,verbose=False) 58 59 # store it 59 60 DATA.append(data)# … … 61 62 62 63 results['DATA'] = DATA 63 64 64 65 pbar.finish() 65 66 66 results.close()67 68 67 ############## PRE-PROCESSING ########################### 69 results = shelve.open('results/mat-' + name)70 68 try: 71 #boing # to force recomputing69 #boing # uncomment to force recomputing 72 70 lower_edges = results['lower_edges'] 73 71 temporal_ON = results['temporal_ON'] … … 77 75 78 76 except: 79 77 80 78 lower_edges = DATA[0]['out_ON_DATA'].time_axis(t_smooth) 81 79 N_smooth = len(lower_edges) 82 80 params = retina.params 83 81 84 82 #N_snr = len(p.snr) 85 83 temporal_ON, temporal_OFF = numpy.zeros((N_smooth,N_snr)), numpy.zeros((N_smooth,N_snr)) 86 84 map_spatial_ON, map_spatial_OFF = numpy.zeros((N,N_snr)), numpy.zeros((N,N_snr)) 87 85 88 86 # 89 87 N_ret, simtime = params['N_ret'], params['simtime'] … … 95 93 id_center = [int(k) for k in numpy.where( r2 < N_ret**2)] 96 94 97 # mean activity accross kernelseeds as a function of SNR 95 # mean activity accross kernelseeds as a function of SNR 98 96 for i_exp, experiment in enumerate(p.iter_inner()): 99 97 # calculating the index in the parameter space … … 104 102 map_spatial_ON[:,index[1]] += DATA[i_exp]['out_ON_DATA'].mean_rates(t_start=simtime/4.,t_stop=3*simtime/4.)/N_seeds 105 103 map_spatial_OFF[:,index[1]] += DATA[i_exp]['out_OFF_DATA'].mean_rates(t_start=simtime/4.,t_stop=3*simtime/4.)/N_seeds 106 104 107 105 results['temporal_ON'] = temporal_ON 108 106 results['map_spatial_OFF'] = map_spatial_OFF … … 110 108 results['map_spatial_ON'] = map_spatial_ON 111 109 110 results.close() 112 111 113 112 ############# MAKING FIGURE ############################ … … 118 117 pylab.ioff() #pylab.ion() # 119 118 120 """ Figure 119 """ Figure 121 120 122 121 Prints to a figure the mean firing rate … … 164 163 pylab.savefig('results/fig-' + name + '.pdf') 165 164 pylab.savefig('results/fig-' + name + '.png', dpi = 300) 166 trunk/examples/retina/make_all.py
- Property svn:keywords set to Id
trunk/examples/retina/retina.py
- Property svn:keywords set to Id
r220 r326 179 179 phr_ON = sim.Population((N,),'dc_generator') 180 180 phr_OFF = sim.Population((N,),'dc_generator') 181 182 181 183 for factor, phr in [(-params['snr'],phr_OFF),(params['snr'],phr_ON)]: 182 184 phr.tset('amplitude', params['amplitude'] * factor ) … … 251 253 print(params['description']) 252 254 print "Number of Neurons : ", N 253 #print "Output rate (ON) : ", out_ON_DATA.meanRate(), "spikes/neuron in ", params['simtime'], "ms"254 #print "Output rate (OFF) : ", out_OFF_DATA.meanSpikeCount(), "spikes/neuron in ",params['simtime'], "ms"255 print "Output rate (ON) : ", out_ON_DATA.mean_rate(), "Hz/neuron in ", params['simtime'], "ms" 256 print "Output rate (OFF) : ", out_OFF_DATA.mean_rate(), "Hz/neuron in ",params['simtime'], "ms" 255 257 print("Build time : %g s" % buildCPUTime) 256 258 print("Simulation time : %g s" % simCPUTime) … … 262 264 if __name__ == '__main__': 263 265 264 ret = Retina(100 0)266 ret = Retina(100) 265 267 out = ret.run(ret.params) 266 268 # plotting … … 268 270 fig = pylab.figure(1) 269 271 z = pylab.subplot(121) 270 out['out_ON_DATA'].raster_plot( id_list=range(20), kwargs={'color':'b'})272 out['out_ON_DATA'].raster_plot(display=z, id_list=range(20), kwargs={'color':'r'}) 271 273 z = pylab.subplot(122) 272 out['out_OFF_DATA'].raster_plot(id_list=range(20),display=z, kwargs={'color':'r'}) 273 274 274 out['out_OFF_DATA'].raster_plot(display=z, id_list=range(20), kwargs={'color':'b'}) 275 fig = pylab.figure(2) 276 z = pylab.subplot(111) 277 out['out_ON_DATA'].firing_rate(ret.params.simtime/100, display=z, kwargs={'label':'ON','color':'r'}) 278 out['out_OFF_DATA'].firing_rate(ret.params.simtime/100, display=z, kwargs={'label':'OFF','color':'b'}) 279 pylab.legend() 280 trunk/examples/retina/test_parallel.py
- Property svn:keywords set to Id
trunk/examples/single_neuron/CRF_neuron_vs_signal.py
- Property svn:keywords set to Id
r315 r326 27 27 28 28 29 p = ParameterSet({})30 N_exp_noise = 1031 29 N_exp_snr = 25 30 N_exp_noise = 9 32 31 33 32 ps = ParameterSpace({ … … 69 68 70 69 #numpy.array(p.noise_std._values),numpy.array(p.snr._values), 71 pylab.plot(CRF.transpose()) #color = (sin(2*pi*noise_list)**2,cos(2*pi*noise_list)**2,1)) 70 #pylab.plot(ps.snr._values,CRF.transpose()) #color = (sin(2*pi*noise_list)**2,cos(2*pi*noise_list)**2,1)) 71 for i_noise, noise in enumerate(ps.noise_std._values): 72 pylab.plot(ps.snr._values,CRF[i_noise,:], label='noise = %5.3f' % noise) 72 73 #pylab.yticks(p.noise_std._values[:2:]) 73 74 pylab.ylabel('Firing Rate (Hz/neuron)') 74 75 #pylab.xticks(p.snr._values[:2:]) 75 76 pylab.xlabel('Signal') 76 #pylab.colorbar() 77 pylab.axis('tight') 78 pylab.savefig('results/fig-' + name + '.pdf') 79 pylab.savefig('results/fig-' + name + '.png') 77 pylab.legend(loc = 'lower right') 78 pylab.axis([numpy.min(ps.snr._values), numpy.max(ps.snr._values), 0.0, numpy.max(CRF[:])]) 79 if 0: 80 pylab.show() 81 else: 82 pylab.savefig('results/fig-' + name + '.pdf') 83 pylab.savefig('results/fig-' + name + '.png') trunk/examples/single_neuron/playing_with_simple_single_neuron.py
- Property svn:keywords set to Id
trunk/examples/single_neuron/simple_single_neuron.py
- Property svn:keywords set to Id

