Changeset 1026
- Timestamp:
- 12/08/11 11:16:40 (6 months ago)
- Location:
- branches/neo_output/src
- Files:
-
- 5 modified
-
nest/__init__.py (modified) (2 diffs)
-
nest/recording.py (modified) (5 diffs)
-
nest/simulator.py (modified) (1 diff)
-
neuron/recording.py (modified) (2 diffs)
-
standardmodels/cells.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/neo_output/src/nest/__init__.py
r1025 r1026 34 34 NEST_SYNAPSE_TYPES = nest.Models(mtype='synapses') 35 35 36 STATE_VARIABLE_MAP = {"v": "V_m", "w": "w"} 36 STATE_VARIABLE_MAP = {"v": "V_m", "w": "w", "gsyn_exc": "g_ex", 37 "gsyn_inh": "g_in"} 37 38 logger = logging.getLogger("PyNN") 38 39 … … 286 287 287 288 def _set_initial_value_array(self, variable, value): 288 if variable in STATE_VARIABLE_MAP: 289 variable = STATE_VARIABLE_MAP[variable] 290 nest.SetStatus(self.local_cells.tolist(), variable, value) 289 variable = STATE_VARIABLE_MAP.get(variable, variable) 290 try: 291 nest.SetStatus(self.local_cells.tolist(), variable, value) 292 except nest.NESTError, e: 293 logger.warning("NEST does not allow setting an initial value for %s" % variable) # assuming this is an "Unused dictionary items" error - should really check 291 294 292 295 -
branches/neo_output/src/nest/recording.py
r1025 r1026 19 19 VARIABLE_MAP = {'v': 'V_m', 'gsyn_exc': 'g_ex', 'gsyn_inh': 'g_in'} 20 20 REVERSE_VARIABLE_MAP = dict((v,k) for k,v in VARIABLE_MAP.items()) 21 SCALE_FACTORS = {'v': 1, 'gsyn_exc': 0.001, 'gsyn_inh': 0.001} 21 22 22 23 logger = logging.getLogger("PyNN") … … 55 56 each neuron, ids as keys. 56 57 """ 58 scale_factor = SCALE_FACTORS.get(variable, 1) 59 nest_variable = VARIABLE_MAP.get(variable, variable) 57 60 events = nest.GetStatus(self.device,'events')[0] 58 61 ids = events['senders'] 59 values = events[ variable]62 values = events[nest_variable] * scale_factor # I'm hoping numpy optimises for the case where scale_factor = 1, otherwise should avoid this multiplication in that case 60 63 data = {} 61 64 for id in desired_ids: 62 65 data[id] = values[ids==id] 66 if variable != 'spikes': 67 initial_value = id.get_initial_value(variable) 68 data[id] = numpy.concatenate(([initial_value], data[id])) 63 69 return data 64 70 65 71 66 72 class SpikeDetector(RecordingDevice): … … 115 121 current_variables.add(VARIABLE_MAP.get(variable, variable)) 116 122 _set_status(self.device, {'record_from': list(current_variables)}) 117 118 119 123 120 124 … … 416 420 for id in self.filter_recorded('spikes', filter_ids)] 417 421 else: 418 data = self._multimeter.get_data( VARIABLE_MAP.get(variable, variable),422 data = self._multimeter.get_data(variable, 419 423 self.filter_recorded(variable, filter_ids)) 420 segment.analogsignals = [424 segment.analogsignals.extend( 421 425 neo.AnalogSignal(data[id], 422 426 units=recording.UNITS_MAP.get(variable, 'dimensionless'), … … 426 430 source_population=self.population.label, 427 431 source_id=int(id)) 428 for id in self.filter_recorded(variable, filter_ids) ]432 for id in self.filter_recorded(variable, filter_ids)) 429 433 return segment 430 434 -
branches/neo_output/src/nest/simulator.py
r1025 r1026 126 126 gid = self 127 127 try: 128 #nest does not like numpy array and so we will convert them to lists whenever we encounter one 129 for key in parameters: 130 if type(parameters[key]) == numpy.ndarray: 131 parameters[key] = parameters[key].tolist() 128 #nest does not like numpy array if numpy was not available when it was compiled, and so we will convert them to lists whenever we encounter one 129 # to avoid this inefficiency, would be better to check at import time that NEST has been built with numpy support and raise an Exception if it hasn't 130 for key in parameters: 131 if type(parameters[key]) == numpy.ndarray: 132 parameters[key] = parameters[key].tolist() 132 133 nest.SetStatus([gid], [parameters]) 133 134 except: # I can't seem to catch the NESTError that is raised, hence this roundabout way of doing it. -
branches/neo_output/src/neuron/recording.py
r1008 r1026 145 145 else: 146 146 signal = lambda id: id._cell.traces[variable] 147 segment.analogsignals = [147 segment.analogsignals.extend( 148 148 neo.AnalogSignal(get_signal(id), # assuming not using cvode, otherwise need to use IrregularlySampledAnalogSignal 149 149 units=recording.UNITS_MAP.get(variable, 'dimensionless'), … … 153 153 source_population=self.population.label, 154 154 source_id=int(id)) 155 for id in self.filter_recorded(variable, filter_ids) 156 ] 155 for id in self.filter_recorded(variable, filter_ids)) 157 156 assert segment.analogsignals[0].t_stop - simulator.state.t*pq.ms < simulator.state.dt*pq.ms 158 157 # need to add `Unit` and `RecordingChannel` objects -
branches/neo_output/src/standardmodels/cells.py
r1025 r1026 101 101 default_initial_values = { 102 102 'v': -65.0, #'v_rest', 103 'gsyn_exc': 0.0, 104 'gsyn_inh': 0.0, 103 105 } 104 106 … … 125 127 default_initial_values = { 126 128 'v': -65.0, #'v_rest', 129 'gsyn_exc': 0.0, 130 'gsyn_inh': 0.0, 127 131 } 128 132 … … 162 166 default_initial_values = { 163 167 'v': -65.0, #'v_rest', 168 'gsyn_exc': 0.0, 169 'gsyn_inh': 0.0, 164 170 } 165 171 … … 187 193 default_initial_values = { 188 194 'v': -65.0, #'v_rest', 195 'gsyn_exc': 0.0, 196 'gsyn_inh': 0.0, 189 197 } 190 198 … … 213 221 default_initial_values = { 214 222 'v': -65.0, #'v_rest', 223 'gsyn_exc': 0.0, 224 'gsyn_inh': 0.0, 215 225 } 216 226 … … 248 258 'v': -65.0, #'v_rest', 249 259 'w': 0.0, 260 'gsyn_exc': 0.0, 261 'gsyn_inh': 0.0, 250 262 } 251 263 … … 283 295 'v': -65.0, #'v_rest', 284 296 'w': 0.0, 297 'gsyn_exc': 0.0, 298 'gsyn_inh': 0.0, 285 299 } 286 300
