Changeset 123
- Timestamp:
- 07/05/07 16:18:54 (1 year ago)
- Files:
-
- branches/0.3/test/VAbenchmarks.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.3/test/VAbenchmarks.py
r76 r123 1 1 # coding: utf-8 2 2 """ 3 This is an implemention of benchmarks 1 and 2 from the Brette et al. (2007) 4 review paper (Journal of Computational Neuroscience, in press). 3 5 4 This is an attempt to implement the FACETS review paper benchmarks 1 and 2: 5 6 The IF network is based on the CUBA and COBA models of Vogels & Abbott (J 7 Neurosci, 2005). The model consists of a network of excitatory and 6 The IF network is based on the CUBA and COBA models of Vogels & Abbott 7 (J. Neurosci, 2005). The model consists of a network of excitatory and 8 8 inhibitory neurons, connected via current-based "exponential" 9 9 synapses (instantaneous rise, exponential decay). 10 11 NOTE: the benchmark specifies an initial 50 ms external spike input, but12 this has not been implemented (not necessary for sustained firing).13 10 14 11 Andrew Davison, UNIC, CNRS … … 22 19 from NeuroTools.stgen import StGen 23 20 24 if hasattr(sys,"argv"): # run using python21 if hasattr(sys,"argv"): 25 22 if len(sys.argv) < 2: 26 print "Usage: python VAbenchmarks.py <simulator> <benchmark>\n\n<simulator> is either neuron, nest or pcsim\n<benchmark> is either CUBA or COBA." 23 print """Usage: python VAbenchmarks.py <simulator> <benchmark> 24 25 <simulator> is either neuron, nest or pcsim 26 <benchmark> is either CUBA or COBA.""" 27 27 sys.exit(1) 28 28 simulator = sys.argv[-2] 29 29 benchmark = sys.argv[-1] 30 else:31 benchmark = "CUBA"32 simulator = "oldneuron" # run using nrngui -python33 30 exec("from pyNN.%s import *" % simulator) 34 31 … … 46 43 rate = 20 # (Hz) frequency of the random stimulation 47 44 48 dt = 0.1 # (ms) simulation timestep45 dt = 0.1 # (ms) simulation timestep 49 46 tstop = 4000 # (ms) simulaton duration 50 47 … … 75 72 tau_inh = 10 # (ms) 76 73 77 ### what is the synaptic delay???78 79 74 # === Calculate derived parameters ============================================= 80 75 81 76 area = area*1e-8 # convert to cm² 82 77 cm = cm*area*1000 # convert to nF 83 Rm = 1e-6/(g_leak*area) # membrane resistance in M Ω78 Rm = 1e-6/(g_leak*area) # membrane resistance in M⊠84 79 assert tau_m == cm*Rm # just to check 85 80 n_exc = int(round((n*r_ei/(1+r_ei)))) # number of excitatory cells 86 81 n_inh = n - n_exc # number of inhibitory cells 87 82 if benchmark == "COBA": 88 celltype = IF_cond_alpha # Since for the moment no IF_cond_exp model is available for nest89 w_exc = Gexc 83 celltype = IF_cond_alpha # Since for the moment no IF_cond_exp model 84 w_exc = Gexc # is available for nest 90 85 w_inh = Ginh 91 86 elif benchmark == "CUBA": … … 98 93 99 94 node_id = setup(timestep=dt,min_delay=0.1,max_delay=0.1) 100 #if simulator=='nest':101 # pynest.showNESTStatus()102 95 103 96 if (benchmark == "CUBA"): … … 113 106 'cm' : cm, 'tau_refrac' : t_refrac, 114 107 'e_rev_E' : Erev_exc, 'e_rev_I' : Erev_inh} 115 116 Timer.start()117 108 118 109 print "%d Creating cell populations..." % node_id … … 130 121 131 122 print "%d Connecting populations..." % node_id 132 connections = {'e2e' : Projection(exc_cells, exc_cells,'fixedProbability', pconn, target='excitatory',rng=rng), 133 'e2i' : Projection(exc_cells, inh_cells,'fixedProbability', pconn, target='excitatory',rng=rng), 134 'i2e' : Projection(inh_cells, exc_cells,'fixedProbability', pconn, target='inhibitory',rng=rng), 135 'i2i' : Projection(inh_cells, inh_cells,'fixedProbability', pconn, target='inhibitory',rng=rng)} 123 connections = { 124 'e2e' : Projection(exc_cells, exc_cells,'fixedProbability', pconn, target='excitatory',rng=rng), 125 'e2i' : Projection(exc_cells, inh_cells,'fixedProbability', pconn, target='excitatory',rng=rng), 126 'i2e' : Projection(inh_cells, exc_cells,'fixedProbability', pconn, target='inhibitory',rng=rng), 127 'i2i' : Projection(inh_cells, inh_cells,'fixedProbability', pconn, target='inhibitory',rng=rng)} 136 128 if (benchmark == "COBA"): 137 129 connections['ext2e'] = Projection(ext_stim, exc_cells,'fixedProbability', 0.001, target='excitatory') 138 130 connections['ext2i'] = Projection(ext_stim, inh_cells,'fixedProbability', 0.001, target='excitatory') 139 140 131 141 132 print "%d Setting weights..." % node_id … … 148 139 connections['ext2i'].setWeights(1.) 149 140 150 #for prj in connections.keys():151 # connections[prj].saveConnections('VAbenchmark_%s_%s_%s.conn' % (benchmark,prj,simulator))152 153 141 print "%d Number of neurons: %d excitatory %d inhibitory" % (node_id, n_exc, n_inh) 154 print "%d Number of connections: %d eâe %d eâi %d iâe %d iâi" % (node_id, len(connections['e2e']), len(connections['e2i']), len(connections['i2e']), len(connections['i2i'])) 155 print node_id, "Build time:", int(Timer.elapsedTime()), "seconds" 156 142 print "%d Number of connections: %d eâe %d eâi %d iâe %d iâi" % (node_id, len(connections['e2e']), 143 len(connections['e2i']), 144 len(connections['i2e']), 145 len(connections['i2i'])) 157 146 158 147 # === Setup recording ========================================================== 148 159 149 print "%d Setting up recording..." % node_id 160 150 exc_cells.record() … … 166 156 167 157 print "%d Running..." % node_id 168 Timer.reset() 169 for i in range(10): 170 run(i/10.0*tstop) 171 print "Run time:", int(Timer.elapsedTime()), "seconds" 158 run(tstop) 172 159 173 160 print "Mean firing rates (spikes/s): (exc) %4.1f (inh) %4.1f" % \ … … 177 164 178 165 print "%d Writing data to file..." % node_id 179 Timer.reset() 166 180 167 exc_cells.printSpikes("VAbenchmark_%s_exc_%s.ras" % (benchmark,simulator)) 181 168 inh_cells.printSpikes("VAbenchmark_%s_inh_%s.ras" % (benchmark,simulator)) 182 169 exc_cells.print_v("VAbenchmark_%s_exc_%s.v" % (benchmark,simulator),compatible_output=True) 183 print "Time to print spikes:", int(Timer.elapsedTime()), "seconds"184 185 170 186 171 # === Finished with simulator ================================================== 187 172 188 if "neuron" in simulator: # send e-mail when simulation finished, since it takes ages.189 pyNN.utility.notify("Simulation of Vogels-Abbott %s benchmark with pyNN.%s finished." % (benchmark,simulator))190 173 end()

