def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): # Make a deep copy of synapse type # so projection can independently change parameters synapse_type = deepcopy(synapse_type) common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) # Initialise the context stack ContextMixin.__init__(self, {}) # Native projections list. Remains empty if no projections are generated. self._sub_projections = [] self.use_sparse = connector.use_sparse # Generate name stem for sub-projections created from this projection # **NOTE** superclass will always populate label PROPERTY # with something moderately useful i.e. at least unique self._genn_label_stem =\ "projection_%u_%s" % (Projection._nProj, sanitize_label(self.label)) # Add projection to the simulator self._simulator.state.projections.append(self)
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) self.nest_synapse_model = self.synapse_type._get_nest_synapse_model() self.nest_synapse_label = Projection._nProj self.synapse_type._set_tau_minus(self.post.local_cells) self._sources = [] self._connections = None # This is used to keep track of common synapse properties (to my # knowledge they only become apparent once connections are created # within nest --obreitwi, 13-02-14) self._common_synapse_properties = {} self._common_synapse_property_names = None # Create connections connector.connect(self)
def test_really_simple0(self): A = numpy.zeros((3, )) B = numpy.zeros((3, 5)) D = DistanceMatrix(B, Space()) D.set_source(A) assert_arrays_almost_equal(D.as_array(), numpy.zeros((5, ), float), 1e-12)
def __init__(self, presynaptic_neurons, postsynaptic_neurons, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): """ Create a new projection, connecting the pre- and post-synaptic neurons. """ for prefix, pop in zip(("pre", "post"), (presynaptic_neurons, postsynaptic_neurons)): if not isinstance(pop, (BasePopulation, Assembly)): raise errors.ConnectionError("%ssynaptic_neurons must be a Population, PopulationView or Assembly, not a %s" % (prefix, type(pop))) if isinstance(postsynaptic_neurons, Assembly): if not postsynaptic_neurons._homogeneous_synapses: raise errors.ConnectionError('Projection to an Assembly object can be made only with homogeneous synapses types') self.pre = presynaptic_neurons # } these really self.source = source # } should be self.post = postsynaptic_neurons # } read-only self.receptor_type = receptor_type or 'excitatory' # TO FIX: if weights are negative, default should be 'inhibitory' if self.receptor_type not in postsynaptic_neurons.receptor_types: valid_types = postsynaptic_neurons.receptor_types assert len(valid_types) > 0 errmsg = "User gave synapse_type=%s, synapse_type must be one of: '%s'" raise errors.ConnectionError(errmsg % (self.receptor_type, "', '".join(valid_types))) self.label = label self.space = space self._connector = connector self.synapse_type = synapse_type or self._static_synapse_class() assert isinstance(self.synapse_type, models.BaseSynapseType), \ "The synapse_type argument must be a models.BaseSynapseType object, not a %s" % type(synapse_type) if label is None: if self.pre.label and self.post.label: self.label = "%s→%s" % (self.pre.label, self.post.label) Projection._nProj += 1
def __init__(self, p_connect, weights=0.0, delays=1, allow_self_connections=True, space=Space(), safe=True, verbose=False, generate_on_machine=False): """ For each pair of pre-post cells, the connection probability is constant. :param p_connect: a float between zero and one. Each potential connection is created with this probability. :param allow_self_connections: if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population. :param safe: if True, check that weights and delays have valid values. If False, this check is skipped. :param space: a Space object, needed if you wish to specify distance- dependent weights or delays - not implemented :param verbose: """ CommonFixedProbabilityConnector.__init__( self, p_connect=p_connect, allow_self_connections=allow_self_connections, safe=safe, verbose=verbose, generate_on_machine=generate_on_machine) self.set_weights_and_delays(weights, delays) self.set_space(space)
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source=None, receptor_type=None, space=Space(), label=None): common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) self.connections = None self._n_connections = 0 # create one Synapses object per pre-post population pair # there will be multiple such pairs if either `presynaptic_population` # or `postsynaptic_population` is an Assembly. if isinstance(self.pre, common.Assembly): presynaptic_populations = self.pre.populations else: presynaptic_populations = [self.pre] if isinstance(self.post, common.Assembly): postsynaptic_populations = self.post.populations assert self.post._homogeneous_synapses, "Inhomogeneous assemblies not yet supported" else: postsynaptic_populations = [self.post] self._brian_synapses = defaultdict(dict) for i, pre in enumerate(presynaptic_populations): for j, post in enumerate(postsynaptic_populations): # complete the synapse type equations according to the # post-synaptic response type psv = post.celltype.post_synaptic_variables[self.receptor_type] weight_units = post.celltype.conductance_based and uS or nA self.synapse_type._set_target_type(weight_units) equation_context = { "syn_var": psv, "weight_units": weight_units } pre_eqns = self.synapse_type.pre % equation_context if self.synapse_type.post: post_eqns = self.synapse_type.post % equation_context else: post_eqns = None model = self.synapse_type.eqs % equation_context # create the brian Synapses object. syn_obj = brian.Synapses(pre.brian_group, post.brian_group, model=model, pre=pre_eqns, post=post_eqns, code_namespace={"exp": numpy.exp}) self._brian_synapses[i][j] = syn_obj simulator.state.network.add(syn_obj) # connect the populations connector.connect(self) # special-case: the Tsodyks-Markram short-term plasticity model takes # a parameter value from the post-synaptic response model if isinstance(self.synapse_type, TsodyksMarkramSynapse): self._set_tau_syn_for_tsodyks_markram()
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source=None, receptor_type=None, space=Space(), label=None): common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) self._simulator.state.net.projections.append(self)
def __init__(self, p_connect, allow_self_connections=True, weights=0.0, delays=None, space=Space(), safe=True, verbose=False): """ Create a new connector. `p_connect` -- a float between zero and one. Each potential connection is created with this probability. `allow_self_connections` -- if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population. `weights` -- may either be a float, a RandomDistribution object, a list/ 1D array with at least as many items as connections to be created. Units nA. `delays` -- as `weights`. If `None`, all synaptic delays will be set to the global minimum delay. `space` -- a `Space` object, needed if you wish to specify distance- dependent weights or delays """ Connector.__init__(self, weights, delays, space, safe, verbose) assert isinstance(allow_self_connections, bool) self.allow_self_connections = allow_self_connections self.p_connect = float(p_connect) assert 0 <= self.p_connect
def __init__(self, d_expression, allow_self_connections=True, weights=0.0, delays=None, space=Space(), safe=True, verbose=False, n_connections=None): """ Create a new connector. `d_expression` -- the right-hand side of a valid python expression for probability, involving 'd', e.g. "exp(-abs(d))", or "d<3" `n_connections` -- The number of efferent synaptic connections per neuron. `space` -- a Space object. `weights` -- may either be a float, a RandomDistribution object, a list/ 1D array with at least as many items as connections to be created, or a distance expression as for `d_expression`. Units nA. `delays` -- as `weights`. If `None`, all synaptic delays will be set to the global minimum delay. """ Connector.__init__(self, weights, delays, space, safe, verbose) assert isinstance(d_expression, str) try: if not expand_distances(d_expression): d = 0 assert 0 <= eval(d_expression), eval(d_expression) d = 1e12 assert 0 <= eval(d_expression), eval(d_expression) except ZeroDivisionError, err: raise ZeroDivisionError("Error in the distance expression %s. %s" % (d_expression, err))
def __init__(self, weights=0.0, delays=None, space=Space(), safe=True, verbose=False): self.weights = weights self.space = space self.safe = safe self.verbose = verbose min_delay = common.get_min_delay() if delays is None: self.delays = min_delay else: if core.is_listlike(delays): if min(delays) < min_delay: raise errors.ConnectionError( "smallest delay (%g) is smaller than minimum delay (%g)" % (min(delays), min_delay)) elif not (isinstance(delays, basestring) or isinstance(delays, RandomDistribution)): if delays < min_delay: raise errors.ConnectionError( "delay (%g) is smaller than minimum delay (%g)" % (delays, min_delay)) self.delays = delays
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): Connector.__init__(self, weights, delays, space, safe) if isinstance(projection.rng, random.NativeRNG): raise Exception("Use of NativeRNG not implemented.") else: self.rng = projection.rng self.local = projection.post._mask_local self.N = projection.post.size self.weights_generator = WeightGenerator(weights, self.local, projection, safe) self.delays_generator = DelayGenerator(delays, self.local, safe) self.probas_generator = ProbaGenerator( RandomDistribution('uniform', (0, 1), rng=self.rng), self.local) self._distance_matrix = None self.projection = projection self.candidates = projection.post.local_cells self.size = self.local.sum() self.allow_self_connections = allow_self_connections
def __init__(self, weights=0.0, delays=1, allow_self_connections=True, space=Space(), safe=True, verbose=None, generate_on_machine=False): """ :param allow_self_connections: if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population. :type allow_self_connections: bool :param space: a Space object, needed if you wish to specify distance- dependent weights or delays :param safe: if True, check that weights and delays have valid values. If False, this check is skipped. :param verbose: """ CommonAllToAllConnector.__init__( self, allow_self_connections=allow_self_connections, safe=safe, verbose=verbose, generate_on_machine=generate_on_machine) self.set_space(space) self.set_weights_and_delays(weights, delays)
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): # Make a deep copy of synapse type # so projection can independently change parameters synapse_type = deepcopy(synapse_type) common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) # Initialise the context stack ContextMixin.__init__(self, {}) # **TODO** leave type up to Connector types self.use_sparse = (False if isinstance(connector, AllToAllConnector) else True) # Generate name stem for sub-projections created from this projection # **NOTE** superclass will always populate label PROPERTY # with something moderately useful i.e. at least unique self._genn_label_stem =\ "projection_%u_%s" % (Projection._nProj, sanitize_label(self.label)) # Add projection to the simulator self._simulator.state.projections.append(self)
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): Connector.__init__(self, weights, delays, space, safe) if isinstance(projection.rng, random.NativeRNG): raise Exception("Use of NativeRNG not implemented.") else: self.rng = projection.rng self.local = numpy.ones(len(projection.pre), bool) self.N = projection.pre.size self.weights_generator = WeightGenerator(weights, self.local, projection, safe) self.delays_generator = DelayGenerator(delays, self.local, safe) self.probas_generator = ProbaGenerator( RandomDistribution('uniform', (0, 1), rng=self.rng), self.local) self.distance_matrix = DistanceMatrix(projection.pre.positions, self.space, self.local) self.projection = projection self.allow_self_connections = allow_self_connections
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): Connector.__init__(self, weights, delays, space, safe) if isinstance(projection.rng, random.NativeRNG): raise Exception("Use of NativeRNG not implemented.") else: self.rng = projection.rng self.N = projection.pre.size idx = numpy.arange(self.N * rank(), self.N * (rank() + 1)) self.M = num_processes() * self.N self.local = numpy.ones(self.N, bool) self.local_long = numpy.zeros(self.M, bool) self.local_long[idx] = True self.weights_generator = WeightGenerator(weights, self.local_long, projection, safe) self.delays_generator = DelayGenerator(delays, self.local_long, safe) self.probas_generator = ProbaGenerator( random.RandomDistribution('uniform', (0, 1), rng=self.rng), self.local_long) self.distance_matrix = DistanceMatrix(projection.pre.positions, self.space, self.local) self.projection = projection self.candidates = projection.pre.all_cells self.allow_self_connections = allow_self_connections
def __init__(self, degree, rewiring, allow_self_connections=True, weights=0.0, delays=None, space=Space(), safe=True, verbose=False, n_connections=None): """ Create a new connector. `degree` -- the region lenght where nodes will be connected locally `rewiring` -- the probability of rewiring each eadges `space` -- a Space object. `allow_self_connections` -- if the connector is used to connect a Population to itself, this flag determines whether a neuron is allowed to connect to itself, or only to other neurons in the Population. `n_connections` -- The number of efferent synaptic connections per neuron. `weights` -- may either be a float, a RandomDistribution object, a list/ 1D array with at least as many items as connections to be created, or a DistanceDependence object. Units nA. `delays` -- as `weights`. If `None`, all synaptic delays will be set to the global minimum delay. """ Connector.__init__(self, weights, delays, space, safe, verbose) assert 0 <= rewiring <= 1 assert isinstance(allow_self_connections, bool) self.rewiring = rewiring self.d_expression = "d < %g" % degree self.allow_self_connections = allow_self_connections self.n_connections = n_connections
def __init__(self, width, height, channel, height_bits, channel_bits=1, event_bits=0, weights=1.0, delays=1., space=Space(), safe=True, verbose=False, generate_on_machine=False): """ """ CommonMappingConnector.__init__( self, width=width, height=height, channel=channel, height_bits=height_bits, channel_bits=channel_bits, event_bits=event_bits, safe=safe, verbose=verbose, random_number_class=RandomDistribution, generate_on_machine=generate_on_machine) self.set_weights_and_delays(weights, delays) self.set_space(space)
def scenario4(sim): """ Network with spatial structure """ init_logging(logfile=None, debug=True) sim.setup() rng = NumpyRNG(seed=76454, parallel_safe=False) input_layout = RandomStructure(boundary=Cuboid(width=500.0, height=500.0, depth=100.0), origin=(0, 0, 0), rng=rng) inputs = sim.Population(100, sim.SpikeSourcePoisson(rate=RandomDistribution('uniform', [3.0, 7.0], rng=rng)), structure=input_layout, label="inputs") output_layout = Grid3D(aspect_ratioXY=1.0, aspect_ratioXZ=5.0, dx=10.0, dy=10.0, dz=10.0, x0=0.0, y0=0.0, z0=200.0) outputs = sim.Population(200, sim.EIF_cond_exp_isfa_ista(), initial_values = {'v': RandomDistribution('normal', [-65.0, 5.0], rng=rng), 'w': RandomDistribution('normal', [0.0, 1.0], rng=rng)}, structure=output_layout, # 10x10x2 grid label="outputs") logger.debug("Output population positions:\n %s", outputs.positions) DDPC = sim.DistanceDependentProbabilityConnector input_connectivity = DDPC("0.5*exp(-d/100.0)", rng=rng) recurrent_connectivity = DDPC("sin(pi*d/250.0)**2", rng=rng) depressing = sim.TsodyksMarkramSynapse(weight=RandomDistribution('normal', (0.1, 0.02), rng=rng), delay="0.5 + d/100.0", U=0.5, tau_rec=800.0, tau_facil=0.0) facilitating = sim.TsodyksMarkramSynapse(weight=0.05, delay="0.2 + d/100.0", U=0.04, tau_rec=100.0, tau_facil=1000.0) input_connections = sim.Projection(inputs, outputs, input_connectivity, receptor_type='excitatory', synapse_type=depressing, space=Space(axes='xy'), label="input connections") recurrent_connections = sim.Projection(outputs, outputs, recurrent_connectivity, receptor_type='inhibitory', synapse_type=facilitating, space=Space(periodic_boundaries=((-100.0, 100.0), (-100.0, 100.0), None)), # should add "calculate_boundaries" method to Structure classes label="recurrent connections") outputs.record('spikes') outputs.sample(10, rng=rng).record('v') sim.run(1000.0) data = outputs.get_data() sim.end() return data
def __init__( self, degree, rewiring, allow_self_connections=True, space=Space(), safe=True, verbose=False, n_connections=None): # pylint: disable=too-many-arguments super(SmallWorldConnector, self).__init__( degree=degree, rewiring=rewiring, allow_self_connections=allow_self_connections, safe=safe, verbose=verbose, n_connections=n_connections)
def __init__(self, presynaptic_neurons, postsynaptic_neurons, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): """ Create a new projection, connecting the pre- and post-synaptic neurons. """ if not hasattr(self, "_simulator"): errmsg = "`common.Projection` should not be instantiated directly. " \ "You should import Projection from a PyNN backend module, " \ "e.g. pyNN.nest or pyNN.neuron" raise Exception(errmsg) for prefix, pop in zip(("pre", "post"), (presynaptic_neurons, postsynaptic_neurons)): if not isinstance(pop, (BasePopulation, Assembly)): raise errors.ConnectionError( "%ssynaptic_neurons must be a Population, PopulationView or Assembly, not a %s" % (prefix, type(pop))) if isinstance(postsynaptic_neurons, Assembly): if not postsynaptic_neurons._homogeneous_synapses: raise errors.ConnectionError( 'Projection to an Assembly object can be made only with homogeneous synapses types' ) self.pre = presynaptic_neurons # } these really self.source = source # } should be self.post = postsynaptic_neurons # } read-only if receptor_type == "default": receptor_type = None self.receptor_type = receptor_type or sorted( postsynaptic_neurons.receptor_types)[0] # TO FIX: if weights are negative, default should be the first inhibitory receptor type, # not necessarily the first in alphabetical order. # Should perhaps explicitly specify the default type(s) if self.receptor_type not in postsynaptic_neurons.receptor_types: valid_types = postsynaptic_neurons.receptor_types assert len(valid_types) > 0 errmsg = "User gave receptor_types=%s, receptor_types must be one of: '%s'" raise errors.ConnectionError( errmsg % (self.receptor_type, "', '".join(valid_types))) self.label = label self.space = space self._connector = connector self.synapse_type = synapse_type or self._static_synapse_class() assert isinstance(self.synapse_type, models.BaseSynapseType), \ "The synapse_type argument must be a models.BaseSynapseType object, not a %s" % type(synapse_type) if label is None: if self.pre.label and self.post.label: self.label = u"%s→%s" % (self.pre.label, self.post.label) self.initial_values = {} self.annotations = {} Projection._nProj += 1
def __init__(self, presynaptic_neurons, postsynaptic_neurons, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): """ Create a new projection, connecting the pre- and post-synaptic neurons. :param presynaptic_neurons: Population, PopulationView or Assembly object. :param postsynaptic_neurons: Population, PopulationView or Assembly object. :param connector: a Connector object, encapsulating the algorithm to use for connecting the neurons. :param synapse_type: a SynapseType object specifying which synaptic connection mechanisms to use, defaults to None :param source: string specifying which attribute of the presynaptic cell signals action potentials. This is only needed for multicompartmental cells with branching axons or dendrodendritic synapses. All standard cells have a single source, and this is the default, defaults to None :param receptor_type: string specifying which synaptic receptor_type type on the postsynaptic cell to connect to. For standard cells, this can be 'excitatory' or 'inhibitory'. For non-standard cells, it could be 'NMDA', etc. If receptor_type is not given, the default values of 'excitatory' is used, defaults to None :param space: Space object, determining how distances should be calculated for distance-dependent wiring schemes or parameter values, defaults to Space() :param label: a name for the projection (one will be auto-generated if this is not supplied), defaults to None """ super(Projection, self).__init__(presynaptic_neurons, postsynaptic_neurons, connector, synapse_type, source, receptor_type, space, label) self.connections = [] connector.connect(self) self._simulator.state.projections.append(self)
def __init__(self, presynaptic_neurons, postsynaptic_neurons, connector, synapse_type=None, source=None, receptor_type=None, space=Space(), label=None): """ Create a new projection, connecting the pre- and post-synaptic neurons. """ if not hasattr(self, "_simulator"): errmsg = "`common.Projection` should not be instantiated directly. " \ "You should import Projection from a PyNN backend module, " \ "e.g. pyNN.nest or pyNN.neuron" raise Exception(errmsg) for prefix, pop in zip(("pre", "post"), (presynaptic_neurons, postsynaptic_neurons)): if not isinstance(pop, (BasePopulation, Assembly)): raise errors.ConnectionError( "%ssynaptic_neurons must be a Population, PopulationView or Assembly, not a %s" % (prefix, type(pop))) if isinstance(postsynaptic_neurons, Assembly): if not postsynaptic_neurons._homogeneous_synapses: raise errors.ConnectionError( 'Projection to an Assembly object can be made only with homogeneous synapses types') self.pre = presynaptic_neurons # } these really self.source = source # } should be self.post = postsynaptic_neurons # } read-only self.label = label self.space = space if not isinstance(connector, Connector): raise TypeError( "The connector argument should be an instance of a subclass of Connector. " f"The argument provided was of type '{type(connector).__name__}'." ) self._connector = connector self.synapse_type = synapse_type or self._static_synapse_class() if not isinstance(self.synapse_type, models.BaseSynapseType): raise TypeError( "The synapse_type argument should be an instance of a subclass of BaseSynapseType. " f"The argument provided was of type '{type(synapse_type).__name__}'" ) self.receptor_type = receptor_type if self.receptor_type in ("default", None): self._guess_receptor_type() if self.receptor_type not in postsynaptic_neurons.receptor_types: valid_types = postsynaptic_neurons.receptor_types assert len(valid_types) > 0 errmsg = "User gave receptor_types=%s, receptor_types must be one of: '%s'" raise errors.ConnectionError(errmsg % (self.receptor_type, "', '".join(valid_types))) if label is None: if self.pre.label and self.post.label: self.label = u"%s→%s" % (self.pre.label, self.post.label) self.initial_values = {} self.annotations = {} Projection._nProj += 1
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source=None, receptor_type=None, space=Space(), label=None): common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) ## Create connections self.connections = [] connector.connect(self)
def __init__(self, projection, weights=0.0, delays=None, allow_self_connections=True, space=Space(), safe=True): ProbabilisticConnector.__init__(self, projection, weights, delays, allow_self_connections, space, safe)
def __init__( self, degree, rewiring, allow_self_connections=True, space=Space(), safe=True, verbose=False, n_connections=None, weights=0.0, delays=1): # pylint: disable=too-many-arguments super(SmallWorldConnector, self).__init__( degree=degree, rewiring=rewiring, allow_self_connections=allow_self_connections, safe=safe, verbose=verbose, n_connections=n_connections) self.set_weights_and_delays(weights, delays)
def __init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source=None, receptor_type=None, space=Space(), label=None): common.Projection.__init__(self, presynaptic_population, postsynaptic_population, connector, synapse_type, source, receptor_type, space, label) nml_doc = simulator._get_nml_doc() net = nml_doc.networks[0] nml_proj_id = self.label.replace(u'\u2192','__TO__') syn_id = 'syn__%s'%nml_proj_id logger.debug("Creating Synapse: %s; %s; %s" % (receptor_type, synapse_type.parameter_space, connector)) celltype = postsynaptic_population.celltype.__class__.__name__ logger.debug("Post cell: %s" % (celltype)) syn = None if receptor_type == 'inhibitory': tau_key = 'tau_syn_I' erev_key = 'e_rev_I' else: tau_key = 'tau_syn_E' erev_key = 'e_rev_E' if 'cond_exp' in celltype: syn = neuroml.ExpCondSynapse(id=syn_id) syn.__setattr__('e_rev', postsynaptic_population.celltype.parameter_space[erev_key].base_value) nml_doc.exp_cond_synapses.append(syn) if 'cond_alpha' in celltype: syn = neuroml.AlphaCondSynapse(id=syn_id) syn.__setattr__('e_rev', postsynaptic_population.celltype.parameter_space[erev_key].base_value) nml_doc.alpha_cond_synapses.append(syn) if 'curr_exp' in celltype: syn = neuroml.ExpCurrSynapse(id=syn_id) nml_doc.exp_curr_synapses.append(syn) if 'curr_alpha' in celltype: syn = neuroml.AlphaCurrSynapse(id=syn_id) nml_doc.alpha_curr_synapses.append(syn) syn.tau_syn = postsynaptic_population.celltype.parameter_space[tau_key].base_value self.pre_pop_comp = '%s_%s'%(presynaptic_population.celltype.__class__.__name__, presynaptic_population.label) self.post_pop_comp = '%s_%s'%(postsynaptic_population.celltype.__class__.__name__, postsynaptic_population.label) logger.debug("Creating Projection: %s" % (nml_proj_id)) self.projection = neuroml.Projection(id=nml_proj_id, presynaptic_population=presynaptic_population.label, postsynaptic_population=postsynaptic_population.label, synapse=syn_id) net.projections.append(self.projection) ## Create connections self.connections = [] connector.connect(self)
def __init__(self, weights=0.0, delays=None, space=Space(), safe=True, verbose=False): self.weights = weights self.space = space self.safe = safe self.verbose = verbose self.delays = delays
def nearest(self, position): """ Return the neuron closest to the specified position. """ if self._structure is None: raise ValueError("attempted to retrieve positions " "for an unstructured population") elif self._positions is None: self._structure.generate_positions(self._vertex.n_atoms) position_diff = numpy.empty(self._positions.shape) position_diff.fill(position) distances = Space.distances(self._positions, position_diff) return distances.argmin()
def __init__(self, weights=0.0, delays=None, space=Space(), safe=True, verbose=False): """ Create a new connector. `weights` -- may either be a float, a RandomDistribution object, a list/ 1D array with at least as many items as connections to be created. Units nA. `delays` -- as `weights`. If `None`, all synaptic delays will be set to the global minimum delay. """ Connector.__init__(self, weights, delays, space, verbose) self.space = space self.safe = safe
def __init__(self, weights=0.0, delays=None, space=Space(), safe=True, verbose=False): self.weights = weights self.space = space self.safe = safe self.verbose = verbose min_delay = common.get_min_delay() if delays is None: self.delays = min_delay else: if core.is_listlike(delays): assert min(delays) >= min_delay elif not (isinstance(delays, basestring) or isinstance(delays, RandomDistribution)): assert delays >= min_delay self.delays = delays
def nearest(self, position): """ return the neuron closest to the specified position. Added functionality 23 November 2014 ADR """ if self._structure is None: raise ValueError("attempted to retrieve positions " "for an un-structured population") elif self._positions is None: self._structure.generate_positions(self._vertex.n_atoms) position_diff = numpy.empty(self._positions.shape) position_diff.fill(position) distances = Space.distances(self._positions, position_diff) return distances.argmin()