def _init_bioproperties(self, population): ''' Set the population attribute and link each neuron to its group. ''' if issubclass(population.__class__, NeuralPop): if population.is_valid: self._population = population nodes = population.size # create the delay attribute Connections.delays(self) else: raise AttributeError("NeuralPop is not valid (not all \ neurons are associated to a group).") else: raise AttributeError("Expected NeuralPop but received \ {}".format(pop.__class__.__name__))
def set_delays(self, delay=None, elist=None, distribution=None, parameters=None, noise_scale=None): ''' Set the delay for spike propagation between neurons. ..todo :: take elist into account in Connections.delays Parameters ---------- delay : float or class:`numpy.array`, optional (default: None) Value or list of delays (for user defined delays). elist : class:`numpy.array`, optional (default: None) List of the edges (for user defined delays). distribution : class:`string`, optional (default: None) Type of distribution (choose among "constant", "uniform", "gaussian", "lognormal", "lin_corr", "log_corr"). parameters : dict, optional (default: {}) Dictionary containing the properties of the delay distribution. noise_scale : class:`int`, optional (default: None) Scale of the multiplicative Gaussian noise that should be applied on the delays. ''' if isinstance(delay, float): size = self.edge_nb() if elist is None else len(elist) delay = np.repeat(delay, size) elif not hasattr(delay, "__len__") and delay is not None: raise AttributeError('''Invalid `delay` value: must be either float, array-like or None.''') if distribution is None: distribution = self._w["distribution"] if parameters is None: parameters = self._w return Connections.delays(self, elist=elist, dlist=delay, distribution=distribution, parameters=parameters, noise_scale=noise_scale)
def make_network(graph, neural_pop): ''' Turn a :class:`~nngt.Graph` object into a :class:`~nngt.Network`, or a :class:`~nngt.SpatialGraph` into a :class:`~nngt.SpatialNetwork`. Parameters ---------- graph : :class:`~nngt.Graph` or :class:`~nngt.SpatialGraph` Graph to convert neural_pop : :class:`~nngt.NeuralPop` Population to associate to the new :class:`~nngt.Network` Notes ----- In-place operation that directly converts the original graph. ''' if isinstance(graph, SpatialGraph): graph.__class__ = SpatialNetwork else: graph.__class__ = Network graph.population = neural_pop Connections.delays(graph)