def setup(self): self.source = MockID(252) self.target = MockID(539) self.nc = h.NetCon(self.source._cell.source, self.target._cell.synapse, sec=self.source._cell.source_section) self.nc.delay = 1.0 self.c = simulator.Connection(self.source, self.target, self.nc)
def setUp(self): self.pre = 0 self.post = 1 self.c = simulator.Connection(MockProjection(), self.pre, self.post, weight=0.123, delay=0.321)
def _divergent_connect(self, source, targets, weights, delays): """ Connect a neuron to one or more other neurons with a static connection. `source` -- the ID of the pre-synaptic cell. `targets` -- a list/1D array of post-synaptic cell IDs, or a single ID. `weight` -- a list/1D array of connection weights, or a single weight. Must have the same length as `targets`. `delays` -- a list/1D array of connection delays, or a single delay. Must have the same length as `targets`. """ if not isinstance( source, int) or source > simulator.state.gid_counter or source < 0: errmsg = "Invalid source ID: %s (gid_counter=%d)" % ( source, simulator.state.gid_counter) raise errors.ConnectionError(errmsg) if not core.is_listlike(targets): targets = [targets] if isinstance(weights, float): weights = [weights] if isinstance(delays, float): delays = [delays] assert len(targets) > 0 for target in targets: if not isinstance(target, common.IDMixin): raise errors.ConnectionError("Invalid target ID: %s" % target) assert len(targets) == len(weights) == len(delays), "%s %s %s" % ( len(targets), len(weights), len(delays)) self._resolve_synapse_type() for target, weight, delay in zip(targets, weights, delays): if target.local: if "." in self.synapse_type: section, synapse_type = self.synapse_type.split(".") synapse_object = getattr(getattr(target._cell, section), synapse_type) else: synapse_object = getattr(target._cell, self.synapse_type) nc = simulator.state.parallel_context.gid_connect( int(source), synapse_object) nc.weight[0] = weight # if we have a mechanism (e.g. from 9ML) that includes multiple # synaptic channels, need to set nc.weight[1] here if nc.wcnt() > 1 and hasattr(target._cell, "type"): nc.weight[1] = target._cell.type.synapse_types.index( self.synapse_type) nc.delay = delay # nc.threshold is supposed to be set by ParallelContext.threshold, called in _build_cell(), above, but this hasn't been tested self.connections.append( simulator.Connection(source, target, nc))
def _convergent_connect(self, sources, target, weights, delays): """ Connect a neuron to one or more other neurons with a static connection. `sources` -- a list/1D array of pre-synaptic cell IDs, or a single ID. `target` -- the ID of the post-synaptic cell. `weight` -- a list/1D array of connection weights, or a single weight. Must have the same length as `targets`. `delays` -- a list/1D array of connection delays, or a single delay. Must have the same length as `targets`. """ if not isinstance( target, int) or target > simulator.state.gid_counter or target < 0: errmsg = "Invalid target ID: %s (gid_counter=%d)" % ( target, simulator.state.gid_counter) raise errors.ConnectionError(errmsg) if not core.is_listlike(sources): sources = [sources] if isinstance(weights, float): weights = [weights] if isinstance(delays, float): delays = [delays] assert len(sources) > 0 for source in sources: if not isinstance(source, common.IDMixin): raise errors.ConnectionError("Invalid source ID: %s" % source) assert len(sources) == len(weights) == len(delays), "%s %s %s" % ( len(sources), len(weights), len(delays)) if target.local: for source, weight, delay in zip(sources, weights, delays): if self.synapse_type is None: self.synapse_type = weight >= 0 and 'excitatory' or 'inhibitory' if self.synapse_model == 'Tsodyks-Markram' and 'TM' not in self.synapse_type: self.synapse_type += '_TM' synapse_object = getattr(target._cell, self.synapse_type) nc = simulator.state.parallel_context.gid_connect( int(source), synapse_object) nc.weight[0] = weight nc.delay = delay # nc.threshold is supposed to be set by ParallelContext.threshold, called in _build_cell(), above, but this hasn't been tested self.connections.append( simulator.Connection(source, target, nc))