Changeset 708
- Timestamp:
- 02/12/10 16:02:09 (2 years ago)
- Location:
- trunk
- Files:
-
- 12 modified
-
doc/dynamicsynapses.txt (modified) (1 diff)
-
doc/fileformats.txt (modified) (1 diff)
-
doc/highlevelapi.txt (modified) (4 diffs)
-
doc/lowlevelapi.txt (modified) (2 diffs)
-
doc/testdocs.py (modified) (1 diff)
-
examples/VAbenchmarks.py (modified) (3 diffs)
-
examples/tools/VAbenchmark_graphs.py (modified) (2 diffs)
-
setup.py (modified) (1 diff)
-
src/brian/electrodes.py (modified) (2 diffs)
-
src/nest/simulator.py (modified) (3 diffs)
-
src/neuroml.py (modified) (9 diffs)
-
src/pcsim/electrodes.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/dynamicsynapses.txt
r632 r708 73 73 >>> prj.getSynapseDynamics('tau_rec')[:5] 74 74 [50.0, 50.0, 50.0, 50.0, 50.0] 75 >>> from pyNN.random import RandomDistribution 75 76 >>> distr = RandomDistribution('normal', [0.02, 0.05]) 76 77 >>> prj2.randomizeSynapseDynamics('w_max', distr) 77 78 >>> prj2.getSynapseDynamics('w_max')[:5] 78 aofuha79 [-0.056605932509016577, 0.063197908706714212, 0.034940801886916589, 0.010755581262934901, 0.011700727992415299] 79 80 80 81 There are a number of examples of networks using synaptic plasticity in the ``examples`` directory of the source distribution. -
trunk/doc/fileformats.txt
r707 r708 23 23 >>> p.printSpikes(spike_file) 24 24 >>> spike_file.close() 25 >>> vm_file = HDF5ArrayFile("my_Vm_data.h5" )25 >>> vm_file = HDF5ArrayFile("my_Vm_data.h5", "w") 26 26 >>> p.print_v(vm_file) 27 27 >>> vm_file.close() -
trunk/doc/highlevelapi.txt
r707 r708 75 75 Traceback (most recent call last): 76 76 File "<stdin>", line 1, in ? 77 File "/usr/lib/python/site-packages/pyNN/ nest1.py", line 457, in __getitem__78 id = self. cell[addr]79 IndexError: index (999) out of range (0<=index< =10) in dimension 077 File "/usr/lib/python/site-packages/pyNN/common.py", line 794, in __getitem__ 78 id = self.all_cells[addr] 79 IndexError: index (999) out of range (0<=index<10) in dimension 0 80 80 81 81 as will giving the wrong number of dimensions in the address. … … 107 107 Traceback (most recent call last): 108 108 File "<stdin>", line 1, in <module> 109 File "/ home/andrew/dev/pyNN/neuron/__init__.py", line 759, in index109 File "/usr/lib/python/site-packages/pyNN/neuron/__init__.py", line 759, in index 110 110 return self.fullgidlist[n] 111 111 IndexError: index out of bounds … … 228 228 File "<stdin>", line 1, in <module> 229 229 sine_wave.inject_into(p2) 230 File "/ home/andrew/dev/pyNN/neuron/electrodes.py", line 67, in inject_into230 File "/usr/lib/python/site-packages/pyNN/neuron/electrodes.py", line 67, in inject_into 231 231 raise TypeError("Can't inject current into a spike source.") 232 232 TypeError: Can't inject current into a spike source. … … 359 359 File "<stdin>", line 1, in <module> 360 360 invalid_prj = Projection(p2, p3, OneToOneConnector()) 361 File "/ home/andrew/dev/pyNN/neuron/__init__.py", line 220, in __init__361 File "/usr/lib/python/site-packages/pyNN/neuron/__init__.py", line 220, in __init__ 362 362 method.connect(self) 363 File "/ home/andrew/dev/pyNN/connectors.py", line 281, in connect363 File "/usr/lib/python/site-packages/pyNN/connectors.py", line 281, in connect 364 364 raise common.InvalidDimensionsError("OneToOneConnector does not support 365 365 presynaptic and postsynaptic Populations of different sizes.") -
trunk/doc/lowlevelapi.txt
r707 r708 61 61 stored in the ``default_values`` of the standard cell class, e.g.:: 62 62 63 >>> IF_curr_alpha.default_parameters #doctest "+NORMALIZE_WHITESPACE63 >>> IF_curr_alpha.default_parameters #doctest: +NORMALIZE_WHITESPACE 64 64 {'tau_refrac': 0.0, 'tau_m': 20.0, 'i_offset': 0.0, 'cm': 1.0, 'v_init': -65.0, 65 65 'v_thresh': -50.0, 'tau_syn_E': 0.5, 'v_rest': -65.0, 'tau_syn_I': 0.5, … … 75 75 Traceback (most recent call last): 76 76 File "<stdin>", line 1, in ? 77 File "/usr/lib/python/site-packages/pyNN/nest1.py", line 228, in create 77 File "/usr/lib/python/site-packages/pyNN/common.py", line 655, in create 78 all_cells, mask_local, first_id, last_id = simulator.create_cells(cellclass, cellparams, n) 79 File "/home/andrew/dev/pyNN/neuron/simulator.py", line 287, in create_cells 78 80 celltype = cellclass(cellparams) 79 File "/usr/lib/python/site-packages/pyNN/ne st1.py", line 68, in __init__80 c ommon.IF_curr_alpha.__init__(self,parameters) # checks supplied parameters and adds default81 File "/usr/lib/python/site-packages/pyNN/common.py", line 113, in __init__82 self.parameters = self. checkParameters(parameters, with_defaults=True)83 File "/usr/lib/python/site-packages/pyNN/common.py", line 99, in checkParameters84 raise NonExistentParameterError(k )85 NonExistentParameterError: foo 81 File "/usr/lib/python/site-packages/pyNN/neuron/cells.py", line 442, in __init__ 82 cells.IF_curr_alpha.__init__(self, parameters) # checks supplied parameters and adds default 83 File "/usr/lib/python/site-packages/pyNN/common.py", line 460, in __init__ 84 self.parameters = self.__class__.checkParameters(parameters, with_defaults=True) 85 File "/usr/lib/python/site-packages/pyNN/common.py", line 504, in checkParameters 86 raise NonExistentParameterError(k, cls) 87 NonExistentParameterError: foo (valid parameters for IF_curr_alpha are: cm, i_offset, tau_m, tau_refrac, tau_syn_E, tau_syn_I, v_init, v_reset, v_rest, v_thresh) 86 88 >>> create(IF_curr_alpha, cellparams={'tau_m': 'bar'}) 87 89 Traceback (most recent call last): -
trunk/doc/testdocs.py
r707 r708 10 10 11 11 optionflags = doctest.IGNORE_EXCEPTION_DETAIL+doctest.NORMALIZE_WHITESPACE 12 #optionflags = doctest.NORMALIZE_WHITESPACE12 optionflags = doctest.NORMALIZE_WHITESPACE 13 13 14 14 class MyOutputChecker(doctest.OutputChecker): -
trunk/examples/VAbenchmarks.py
r705 r708 144 144 connections['ext2i'] = Projection(ext_stim, inh_cells, ext_conn, target='excitatory') 145 145 146 for prj in connections.keys():147 connections[prj].saveConnections('Results/VAbenchmark_%s_%s_%s_np%d.conn' % (benchmark, prj, simulator_name, np))148 149 146 # === Setup recording ========================================================== 150 147 print "%s Setting up recording..." % node_id … … 154 151 exc_cells.record_v(vrecord_list) 155 152 156 buildCPUTime = timer.elapsedTime() 153 buildCPUTime = timer.diff() 154 155 # === Save connections to file ================================================= 156 157 for prj in connections.keys(): 158 connections[prj].saveConnections('Results/VAbenchmark_%s_%s_%s_np%d.conn' % (benchmark, prj, simulator_name, np)) 159 saveCPUTime = timer.diff() 157 160 158 161 # === Run simulation =========================================================== 159 162 print "%d Running simulation..." % node_id 160 timer.reset()161 163 162 164 run(tstop) 163 165 164 simCPUTime = timer. elapsedTime()165 166 E_ rate = exc_cells.meanSpikeCount()*1000./tstop167 I_ rate = inh_cells.meanSpikeCount()*1000./tstop166 simCPUTime = timer.diff() 167 168 E_count = exc_cells.meanSpikeCount() 169 I_count = inh_cells.meanSpikeCount() 168 170 169 171 # === Print results to file ==================================================== 170 172 171 173 print "%d Writing data to file..." % node_id 172 timer.reset()173 174 174 175 if not(os.path.isdir('Results')): … … 178 179 inh_cells.printSpikes("Results/VAbenchmark_%s_inh_%s_np%d.ras" % (benchmark, simulator_name, np)) 179 180 exc_cells.print_v("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator_name, np)) 180 writeCPUTime = timer.elapsedTime() 181 182 tmp_string = "%d eâe %d eâi %d iâe %d iâi" % (connections['e2e'].size(), 183 connections['e2i'].size(), 184 connections['i2e'].size(), 185 connections['i2i'].size()) 186 187 def nprint(s): 188 """Small function to display information only on node 0.""" 189 if (node_id == 0): 190 print s 191 192 nprint("\n--- Vogels-Abbott Network Simulation ---") 193 nprint("Nodes : %d" % np) 194 nprint("Simulation type : %s" % benchmark) 195 nprint("Number of Neurons : %d" % n) 196 nprint("Number of Synapses : %s" % tmp_string) 197 nprint("Excitatory conductance : %g nS" % Gexc) 198 nprint("Inhibitory conductance : %g nS" % Ginh) 199 nprint("Excitatory rate : %g Hz" % E_rate) 200 nprint("Inhibitory rate : %g Hz" % I_rate) 201 nprint("Build time : %g s" % buildCPUTime) 202 nprint("Simulation time : %g s" % simCPUTime) 203 nprint("Writing time : %g s" % writeCPUTime) 181 writeCPUTime = timer.diff() 182 183 connections = "%d eâe %d eâi %d iâe %d iâi" % (connections['e2e'].size(), 184 connections['e2i'].size(), 185 connections['i2e'].size(), 186 connections['i2i'].size()) 187 188 if node_id == 0: 189 print "\n--- Vogels-Abbott Network Simulation ---" 190 print "Nodes : %d" % np 191 print "Simulation type : %s" % benchmark 192 print "Number of Neurons : %d" % n 193 print "Number of Synapses : %s" % connections 194 print "Excitatory conductance : %g nS" % Gexc 195 print "Inhibitory conductance : %g nS" % Ginh 196 print "Excitatory rate : %g Hz" % (E_count*1000.0/tstop,) 197 print "Inhibitory rate : %g Hz" % (I_count*1000.0/tstop,) 198 print "Build time : %g s" % buildCPUTime 199 print "Save connections time : %g s" % saveCPUTime 200 print "Simulation time : %g s" % simCPUTime 201 print "Writing time : %g s" % writeCPUTime 204 202 205 203 -
trunk/examples/tools/VAbenchmark_graphs.py
r705 r708 4 4 5 5 import pylab, sys 6 import numpy 6 7 from NeuroTools import signals, plotting 7 8 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas … … 69 70 70 71 # Plot membrane potential trace 71 allvdata = pylab.load("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator, num_nodes), comments='#')72 allvdata = numpy.loadtxt("Results/VAbenchmark_%s_exc_%s_np%d.v" % (benchmark, simulator, num_nodes), comments='#') 72 73 cell_ids = allvdata[:,1].astype(int) 73 74 allvdata = allvdata[:,0] -
trunk/setup.py
r706 r708 41 41 setup( 42 42 name = "PyNN", 43 version = "0.6 pre",43 version = "0.6.0pre", 44 44 package_dir={'pyNN': 'src'}, 45 45 packages = ['pyNN','pyNN.nest', 'pyNN.pcsim', 'pyNN.neuron', 'pyNN.brian', 'pyNN.recording'], -
trunk/src/brian/electrodes.py
r626 r708 6 6 StepCurrentSource -- a step-wise time-varying current. 7 7 8 $Id :$8 $Id$ 9 9 """ 10 10 … … 33 33 def inject_into(self, cell_list): 34 34 """Inject this current source into some cells.""" 35 for cell in cell_list: 36 if 'v' not in cell.cellclass.recordable: 37 raise TypeError("Can't inject current into a spike source.") 35 38 self.cell_list.extend(cell_list) 36 39 -
trunk/src/nest/simulator.py
r702 r708 271 271 def __getitem__(self, i): 272 272 """Return the `i`th connection on the local MPI node.""" 273 if i < len(self): 274 return Connection(self, i) 275 else: 276 raise IndexError("%d > %d" % (i, len(self)-1)) 273 if isinstance(i, int): 274 if i < len(self): 275 return Connection(self, i) 276 else: 277 raise IndexError("%d > %d" % (i, len(self)-1)) 278 elif isinstance(i, slice): 279 if i.stop < len(self): 280 return [Connection(self, j) for j in range(i.start, i.stop, i.step or 1)] 281 else: 282 raise IndexError("%d > %d" % (i.stop, len(self)-1)) 283 277 284 278 285 def __len__(self): … … 395 402 396 403 if parameter_name not in ('weight', 'delay'): 397 if parameter_name in self.parent.synapse_dynamics.fast.translations: 398 parameter_name = self.parent.synapse_dynamics.fast.translations[parameter_name]["translated_name"] # this is a hack that works because there are no units conversions 404 translated_name = None 405 if self.parent.synapse_dynamics.fast and parameter_name in self.parent.synapse_dynamics.fast.translations: 406 translated_name = self.parent.synapse_dynamics.fast.translations[parameter_name]["translated_name"] # this is a hack that works because there are no units conversions 407 elif self.parent.synapse_dynamics.slow: 408 for component_name in "timing_dependence", "weight_dependence", "voltage_dependence": 409 component = getattr(self.parent.synapse_dynamics.slow, component_name) 410 if component and parameter_name in component.translations: 411 translated_name = component.translations[parameter_name]["translated_name"] 412 break 413 if translated_name: 414 parameter_name = translated_name 399 415 else: 400 416 raise Exception("synapse type does not have an attribute '%s', or else this attribute is not accessible." % parameter_name) … … 468 484 #translation = self.parent.synapse_dynamics.reverse_translate({name: value}) 469 485 #name, value = translation.items()[0] 470 name = self.parent.synapse_dynamics.fast.translations[name]["translated_name"] # a hack 486 translated_name = None 487 if self.parent.synapse_dynamics.fast: 488 if name in self.parent.synapse_dynamics.fast.translations: 489 translated_name = self.parent.synapse_dynamics.fast.translations[name]["translated_name"] # a hack 490 if translated_name is None: 491 if self.parent.synapse_dynamics.slow: 492 for component_name in "timing_dependence", "weight_dependence", "voltage_dependence": 493 component = getattr(self.parent.synapse_dynamics.slow, component_name) 494 if component and name in component.translations: 495 translated_name = component.translations[name]["translated_name"] 496 break 497 if translated_name: 498 name = translated_name 471 499 472 500 i = 0 -
trunk/src/neuroml.py
r705 r708 7 7 from pyNN import common, connectors, cells 8 8 import math 9 #import numpy, types, sys, shutil 9 import numpy 10 10 import sys 11 11 sys.path.append('/usr/lib/python%s/site-packages/oldxml' % sys.version[:3]) # needed for Ubuntu … … 24 24 neuroml_xsd="http://www.neuroml.org/NeuroMLValidator/NeuroMLFiles/Schemata/v"+neuroml_ver+"/Level3/NeuroML_Level3_v"+neuroml_ver+".xsd" 25 25 26 strict = False 27 26 28 # ============================================================================== 27 29 # Utility classes 28 30 # ============================================================================== 29 31 30 class ID( common.IDMixin):32 class ID(int, common.IDMixin): 31 33 """ 32 34 Instead of storing ids as integers, we store them as ID objects, … … 38 40 39 41 def __init__(self, n): 40 common.IDMixin.__init__(self , n)42 common.IDMixin.__init__(self) 41 43 42 44 # ============================================================================== … … 179 181 return cell_node, channel_nodes, synapse_nodes 180 182 183 184 class NotImplementedModel(object): 185 186 def __init__(self): 187 if strict: 188 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 189 190 def build_nodes(self): 191 cell_node = build_node(':not_implemented_cell', name=self.label) 192 doc_node = build_node('meta:notes', "PyNN %s cell type not implemented" % self.__class__.__name__) 193 return cell_node, [], [] 194 195 181 196 # ============================================================================== 182 197 # Standard cells 183 198 # ============================================================================== 184 199 185 class IF_curr_exp(cells.IF_curr_exp ):200 class IF_curr_exp(cells.IF_curr_exp, NotImplementedModel): 186 201 """Leaky integrate and fire model with fixed threshold and 187 202 decaying-exponential post-synaptic current. (Separate synaptic currents for 188 203 excitatory and inhibitory synapses""" 189 204 205 n = 0 206 translations = common.build_translations(*[(name, name) 207 for name in cells.IF_curr_exp.default_parameters]) 208 190 209 def __init__(self, parameters): 191 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 192 193 class IF_curr_alpha(cells.IF_curr_alpha): 210 NotImplementedModel.__init__(self) 211 cells.IF_curr_exp.__init__(self, parameters) 212 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 213 self.synapse_type = "doub_exp_syn" 214 self.__class__.n += 1 215 216 class IF_curr_alpha(cells.IF_curr_alpha, NotImplementedModel): 194 217 """Leaky integrate and fire model with fixed threshold and alpha-function- 195 218 shaped post-synaptic current.""" 196 219 220 n = 0 221 translations = common.build_translations(*[(name, name) 222 for name in cells.IF_curr_alpha.default_parameters]) 223 197 224 def __init__(self, parameters): 198 raise Exception('Cell type %s is not available in NeuroML' % self.__class__.__name__) 225 NotImplementedModel.__init__(self) 226 cells.IF_curr_exp.__init__(self, parameters) 227 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 228 self.synapse_type = "doub_exp_syn" 229 self.__class__.n += 1 199 230 200 231 class IF_cond_exp(cells.IF_cond_exp, IF_base): … … 226 257 self.__class__.n += 1 227 258 228 class SpikeSourcePoisson(cells.SpikeSourcePoisson ):259 class SpikeSourcePoisson(cells.SpikeSourcePoisson, NotImplementedModel): 229 260 """Spike source, generating spikes according to a Poisson process.""" 230 261 262 n = 0 263 translations = common.build_translations(*[(name, name) 264 for name in cells.SpikeSourcePoisson.default_parameters]) 265 231 266 def __init__(self, parameters): 232 raise Exception('Cell type %s not yet implemented' % self.__class__.__name__)267 NotImplementedModel.__init__(self) 233 268 cells.SpikeSourcePoisson.__init__(self, parameters) 234 235 236 class SpikeSourceArray(cells.SpikeSourceArray): 269 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 270 self.__class__.n += 1 271 272 273 class SpikeSourceArray(cells.SpikeSourceArray, NotImplementedModel): 237 274 """Spike source generating spikes at the times given in the spike_times array.""" 238 275 276 n = 0 277 translations = common.build_translations(*[(name, name) 278 for name in cells.SpikeSourcePoisson.default_parameters]) 279 239 280 def __init__(self, parameters): 240 raise Exception('Cell type %s not yet implemented' % self.__class__.__name__) 241 cells.SpikeSourceArray.__init__(self, parameters) 281 NotImplementedModel.__init__(self) 282 cells.SpikeSourceARRAY.__init__(self, parameters) 283 self.label = '%s%d' % (self.__class__.__name__, self.__class__.n) 284 self.__class__.n += 1 242 285 243 286 … … 253 296 simulator but not by others. 254 297 """ 255 global xmldoc, xmlfile, populations_node, projections_node, inputs_node, cells_node, channels_node, neuromlNode 298 global xmldoc, xmlfile, populations_node, projections_node, inputs_node, cells_node, channels_node, neuromlNode, strict 256 299 xmlfile = extra_params['file'] 257 300 if isinstance(xmlfile, basestring): 258 301 xmlfile = open(xmlfile, 'w') 302 if 'strict' in extra_params: 303 strict = extra_params['strict'] 259 304 dt = timestep 260 305 xmldoc = xml.dom.minidom.Document() … … 296 341 def num_processes(): 297 342 return 1 343 common.num_processes = num_processes 344 345 def rank(): 346 return 0 347 common.rank = rank 298 348 299 349 … … 388 438 channels_node.appendChild(synapse_node) 389 439 440 self.first_id = 0 441 self.last_id = self.size-1 442 self.all_cells = numpy.array([ID(id) for id in range(self.first_id, self.last_id+1)], dtype=ID).reshape(dims) 443 self._mask_local = numpy.ones_like(self.all_cells).astype(bool) 444 self.local_cells = self.all_cells[self._mask_local] 445 446 def _record(self, variable, record_from=None, rng=None, to_file=True): 447 """ 448 Private method called by record() and record_v(). 449 """ 450 pass 451 452 def meanSpikeCount(self): 453 return -1 454 455 def printSpikes(self, file, gather=True, compatible_output=True): 456 pass 457 458 def print_v(self, file, gather=True, compatible_output=True): 459 pass 390 460 391 461 class AlltoAllConnector(connectors.AllToAllConnector): … … 531 601 Projection.n += 1 532 602 533 534 # ============================================================================== 603 def saveConnections(self, filename, gather=True, compatible_output=True): 604 pass 605 606 def __len__(self): 607 return 0 # needs implementing properly 608 609 # ============================================================================== -
trunk/src/pcsim/electrodes.py
r705 r708 19 19 def inject_into(self, cell_list): 20 20 """Inject this current source into some cells.""" 21 print "injecting current source into cells: %s" % str(cell_list)22 21 if simulator.state.num_processes == 1: 23 22 delay = 0.0 … … 25 24 delay = simulator.state.min_delay # perhaps it would be better to replicate the current source on each node, to avoid this delay 26 25 for cell in cell_list: 27 print cell, cell.local, cell.cellclass.recordable28 26 if cell.local and 'v' not in cell.cellclass.recordable: 29 27 raise TypeError("Can't inject current into a spike source.") 30 28 c = simulator.net.connect(self.input_node, cell, pypcsim.StaticAnalogSynapse(delay=0.001*delay)) 31 29 self.connections.append(c) 32 print "connected current source to cell %s" % cell33 30 34 31
