Changeset 123

Show
Ignore:
Timestamp:
07/05/07 16:18:54 (1 year ago)
Author:
apdavison
Message:

VAbenchmarks.py modified temporarily for inclusion in the CNS*07 poster

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.3/test/VAbenchmarks.py

    r76 r123  
    11# coding: utf-8 
    22""" 
     3This is an implemention of benchmarks 1 and 2 from the Brette et al. (2007) 
     4review paper (Journal of Computational Neuroscience, in press). 
    35 
    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 
     6The 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 
    88inhibitory neurons, connected via current-based "exponential" 
    99synapses (instantaneous rise, exponential decay). 
    10  
    11 NOTE: the benchmark specifies an initial 50 ms external spike input, but 
    12 this has not been implemented (not necessary for sustained firing). 
    1310 
    1411Andrew Davison, UNIC, CNRS 
     
    2219from NeuroTools.stgen import StGen 
    2320 
    24 if hasattr(sys,"argv"):     # run using python 
     21if hasattr(sys,"argv"): 
    2522    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.""" 
    2727        sys.exit(1) 
    2828    simulator = sys.argv[-2] 
    2929    benchmark = sys.argv[-1] 
    30 else: 
    31     benchmark = "CUBA" 
    32     simulator = "oldneuron"    # run using nrngui -python 
    3330exec("from pyNN.%s import *" % simulator) 
    3431 
     
    4643rate     = 20    # (Hz) frequency of the random stimulation 
    4744 
    48 dt       = 0.1  # (ms) simulation timestep 
     45dt       = 0.1  # (ms) simulation timestep 
    4946tstop    = 4000  # (ms) simulaton duration 
    5047 
     
    7572tau_inh  = 10    # (ms) 
    7673 
    77 ### what is the synaptic delay??? 
    78  
    7974# === Calculate derived parameters ============================================= 
    8075 
    8176area  = area*1e-8                     # convert to cm² 
    8277cm    = cm*area*1000                  # convert to nF 
    83 Rm    = 1e-6/(g_leak*area)            # membrane resistance in MΩ 
     78Rm    = 1e-6/(g_leak*area)            # membrane resistance in M℩ 
    8479assert tau_m == cm*Rm                 # just to check 
    8580n_exc = int(round((n*r_ei/(1+r_ei)))) # number of excitatory cells    
    8681n_inh = n - n_exc                     # number of inhibitory cells 
    8782if benchmark == "COBA": 
    88     celltype = IF_cond_alpha          # Since for the moment no IF_cond_exp model is available for nest  
    89     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 
    9085    w_inh = Ginh 
    9186elif benchmark == "CUBA": 
     
    9893 
    9994node_id = setup(timestep=dt,min_delay=0.1,max_delay=0.1) 
    100 #if simulator=='nest': 
    101 #    pynest.showNESTStatus() 
    10295 
    10396if (benchmark == "CUBA"): 
     
    113106    'cm'         : cm,       'tau_refrac' : t_refrac, 
    114107    'e_rev_E'    : Erev_exc, 'e_rev_I'    : Erev_inh} 
    115      
    116 Timer.start() 
    117108 
    118109print "%d Creating cell populations..." % node_id 
     
    130121 
    131122print "%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)} 
     123connections = { 
     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)} 
    136128if (benchmark == "COBA"): 
    137129    connections['ext2e'] = Projection(ext_stim, exc_cells,'fixedProbability', 0.001, target='excitatory') 
    138130    connections['ext2i'] = Projection(ext_stim, inh_cells,'fixedProbability', 0.001, target='excitatory') 
    139  
    140131 
    141132print "%d Setting weights..." % node_id 
     
    148139    connections['ext2i'].setWeights(1.) 
    149140 
    150 #for prj in connections.keys(): 
    151 #    connections[prj].saveConnections('VAbenchmark_%s_%s_%s.conn' % (benchmark,prj,simulator)) 
    152  
    153141print "%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                                                    
     142print "%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'])) 
    157146 
    158147# === Setup recording ========================================================== 
     148 
    159149print "%d Setting up recording..." % node_id 
    160150exc_cells.record() 
     
    166156 
    167157print "%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" 
     158run(tstop) 
    172159 
    173160print "Mean firing rates (spikes/s): (exc) %4.1f (inh) %4.1f" % \ 
     
    177164 
    178165print "%d Writing data to file..." % node_id 
    179 Timer.reset() 
     166 
    180167exc_cells.printSpikes("VAbenchmark_%s_exc_%s.ras" % (benchmark,simulator)) 
    181168inh_cells.printSpikes("VAbenchmark_%s_inh_%s.ras" % (benchmark,simulator)) 
    182169exc_cells.print_v("VAbenchmark_%s_exc_%s.v" % (benchmark,simulator),compatible_output=True) 
    183 print "Time to print spikes:", int(Timer.elapsedTime()), "seconds" 
    184  
    185170 
    186171# === Finished with simulator ================================================== 
    187172 
    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)) 
    190173end()