- Timestamp:
- 11/10/10 16:12:06 (19 months ago)
- Location:
- branches/nativemodels
- Files:
-
- 2 added
- 7 modified
-
examples/native_nest.py (added)
-
examples/native_neuron.py (added)
-
src/common.py (modified) (4 diffs)
-
src/nest/__init__.py (modified) (4 diffs)
-
src/nest/electrodes.py (modified) (1 diff)
-
src/nest/simulator.py (modified) (1 diff)
-
src/neuron/__init__.py (modified) (2 diffs)
-
src/neuron/electrodes.py (modified) (1 diff)
-
src/neuron/simulator.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/nativemodels/src/common.py
r809 r817 70 70 """ 71 71 if hasattr(target_cell, 'local') and target_cell.local and hasattr(target_cell, 'cellclass'): 72 if isinstance(target_cell.cellclass, type):73 is_conductance = target_cell.cellclass.conductance_based74 else: # where cellclass is a string, i.e. for native cell types in NEST75 is_conductance = "cond" in target_cell.cellclass72 # if isinstance(target_cell.cellclass, type): 73 is_conductance = target_cell.cellclass.conductance_based 74 # else: # where cellclass is a string, i.e. for native cell types in NEST 75 # is_conductance = "cond" in target_cell.cellclass 76 76 else: 77 77 is_conductance = None … … 759 759 Connect a current source to all cells in the Population. 760 760 """ 761 if 'v' not in self.celltype.recordable: 761 # if 'v' not in self.celltype.recordable: 762 if not self.celltype.injectable: 762 763 raise TypeError("Can't inject current into a spike source.") 763 764 current_source.inject_into(self) … … 786 787 nPop = 0 787 788 788 def __init__(self, size, cellclass, cellparams=None, structure=None, 789 label=None): 789 def __init__(self, size, celltype, structure=None, label=None): 790 790 """ 791 791 Create a population of neurons all of the same type. … … 822 822 self.size = size 823 823 self.label = label or 'population%d' % Population.nPop 824 if isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType): 825 self.celltype = cellclass(cellparams) 826 else: 827 self.celltype = cellclass 824 # if isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType): 825 # self.celltype = cellclass(cellparams) 826 # else: 827 # self.celltype = cellclass 828 self.celltype = celltype 828 829 self._structure = structure or space.Line() 829 830 self._positions = None 830 self.cellparams = cellparams831 # self.cellparams = cellparams 831 832 # Build the arrays of cell ids 832 833 # Cells on the local node are represented as ID objects, other cells by integers 833 834 # All are stored in a single numpy array for easy lookup by address 834 835 # The local cells are also stored in a list, for easy iteration 835 self._create_cells(cell class, cellparams, size)836 self._create_cells(celltype, size) 836 837 self.initial_values = {} 837 838 for variable, value in self.celltype.default_initial_values.items(): -
branches/nativemodels/src/nest/__init__.py
r804 r817 167 167 recorder_class = Recorder 168 168 169 def _create_cells(self, cell class, cellparams, n):169 def _create_cells(self, celltype, n): 170 170 """ 171 171 Create cells in NEST. … … 178 178 # perhaps should check for that 179 179 assert n > 0, 'n must be a positive integer' 180 if isinstance(cellclass, basestring): # celltype is not a standard cell 181 nest_model = cellclass 182 cell_parameters = cellparams or {} 183 elif isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType): 184 celltype = cellclass(cellparams) 185 nest_model = celltype.nest_name[simulator.state.spike_precision] 186 cell_parameters = celltype.parameters 187 else: 188 raise Exception("Invalid cell type: %s" % type(cellclass)) 180 # if isinstance(cellclass, basestring): # celltype is not a standard cell 181 # nest_model = cellclass 182 # cell_parameters = cellparams or {} 183 # elif isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType): 184 nest_model = celltype.nest_name[simulator.state.spike_precision] 185 # cell_parameters = celltype.parameters 186 # else: 187 # raise Exception("Invalid cell type: %s" % type(cellclass)) 189 188 try: 190 189 self.all_cells = nest.Create(nest_model, n) … … 193 192 raise errors.InvalidModelError("%s Have you compiled NEST with the GSL (Gnu Scientific Library)?" % err) 194 193 raise errors.InvalidModelError(err) 195 if cell_parameters:196 try:197 nest.SetStatus(self.all_cells, [cell_parameters])198 except nest.NESTError:199 print "NEST error when trying to set the following dictionary: %s" % cell_parameters200 raise194 # if cell_parameters: 195 try: 196 nest.SetStatus(self.all_cells, [celltype.parameters]) 197 except nest.NESTError: 198 print "NEST error when trying to set the following dictionary: %s" % cell_parameters 199 raise 201 200 self.first_id = self.all_cells[0] 202 201 self.last_id = self.all_cells[-1] … … 283 282 value = rarr #numpy.array(rarr) 284 283 assert len(rarr) == len(self.local_cells), "%d != %d" % (len(rarr), len(self.local_cells)) 285 nest.SetStatus(self.local_cells.tolist(), STATE_VARIABLE_MAP[variable], value) 284 if variable in STATE_VARIABLE_MAP: 285 variable = STATE_VARIABLE_MAP[variable] 286 nest.SetStatus(self.local_cells.tolist(), variable, value) 286 287 self.initial_values[variable] = core.LazyArray(self.size, value) 287 288 -
branches/nativemodels/src/nest/electrodes.py
r711 r817 24 24 """Inject this current source into some cells.""" 25 25 for id in cell_list: 26 if id.local and 'v' not in id.cellclass.recordable:26 if id.local and not id.cellclass.injectable: #'v' not in id.cellclass.recordable: 27 27 raise TypeError("Can't inject current into a spike source.") 28 28 if isinstance(cell_list, Population): -
branches/nativemodels/src/nest/simulator.py
r792 r817 272 272 273 273 try: 274 nest.DivergentConnect([source], targets, weights, delays, self.synapse_model) 274 nest.DivergentConnect([source], targets, weights, delays, self.synapse_model) 275 raise 275 276 except nest.NESTError, e: 276 277 raise errors.ConnectionError("%s. source=%s, targets=%s, weights=%s, delays=%s, synapse model='%s'" % ( -
branches/nativemodels/src/neuron/__init__.py
r799 r817 105 105 recorder_class = Recorder 106 106 107 def __init__(self, size, cell class, cellparams=None, structure=None,107 def __init__(self, size, celltype, structure=None, 108 108 label=None): 109 109 __doc__ = common.Population.__doc__ 110 common.Population.__init__(self, size, cell class, cellparams, structure, label)110 common.Population.__init__(self, size, celltype, structure, label) 111 111 simulator.initializer.register(self) 112 112 113 def _create_cells(self, cell class, cellparams, n):113 def _create_cells(self, celltype, n): 114 114 """ 115 115 Create cells in NEURON. … … 123 123 # perhaps should check for that 124 124 assert n > 0, 'n must be a positive integer' 125 if isinstance(cellclass, basestring): # cell defined in hoc template126 try:127 cell_model = getattr(h, cellclass)128 except AttributeError:129 raise errors.InvalidModelError("There is no hoc template called %s" % cellclass)130 cell_parameters = cellparams or {}131 elif isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType):132 celltype = cellclass(cellparams)133 cell_model = celltype.model134 cell_parameters = celltype.parameters135 else:136 cell_model = cellclass137 cell_parameters = cellparams125 # if isinstance(cellclass, basestring): # cell defined in hoc template 126 # try: 127 # cell_model = getattr(h, cellclass) 128 # except AttributeError: 129 # raise errors.InvalidModelError("There is no hoc template called %s" % cellclass) 130 # cell_parameters = cellparams or {} 131 # elif isinstance(cellclass, type) and issubclass(cellclass, standardmodels.StandardCellType): 132 # celltype = cellclass(cellparams) 133 cell_model = celltype.model 134 cell_parameters = celltype.parameters 135 # else: 136 # cell_model = cellclass 137 # cell_parameters = cellparams 138 138 self.first_id = simulator.state.gid_counter 139 139 self.last_id = simulator.state.gid_counter + n - 1 -
branches/nativemodels/src/neuron/electrodes.py
r747 r817 67 67 for id in cell_list: 68 68 if id.local: 69 if 'v' not in id.cellclass.recordable: 69 # if 'v' not in id.cellclass.recordable: 70 if not id.cellclass.injectable: 70 71 raise TypeError("Can't inject current into a spike source.") 71 72 iclamp = h.IClamp(0.5, sec=id._cell.source_section) -
branches/nativemodels/src/neuron/simulator.py
r774 r817 152 152 class _State(object): 153 153 """Represent the simulator state.""" 154 max_delay = numpy.inf 154 155 155 156 def __init__(self): … … 440 441 if self.synapse_model == 'Tsodyks-Markram' and 'TM' not in self.synapse_type: 441 442 self.synapse_type += '_TM' 442 synapse_object = getattr(target._cell, self.synapse_type) 443 if "." in self.synapse_type: 444 section, synapse_type = self.synapse_type.split(".") 445 synapse_object = getattr(getattr(target._cell, section), synapse_type) 446 else: 447 synapse_object = getattr(target._cell, self.synapse_type) 443 448 nc = state.parallel_context.gid_connect(int(source), synapse_object) 444 449 nc.weight[0] = weight
