Exemplo n.º 1
0
    def to_nest(self, send_only=None, weights=True):
        '''
        Send the network to NEST.

        .. seealso::
            :func:`~nngt.simulation.make_nest_network` for parameters
        '''
        from nngt.simulation import make_nest_network
        if nngt._config['with_nest']:
            return make_nest_network(self,
                                     send_only=send_only,
                                     weights=weights)
        else:
            raise RuntimeError("NEST is not present.")
Exemplo n.º 2
0
def randomize_neural_states(network, instructions, make_nest=False):
    '''
    Randomize the neural states according to the instructions.

    Parameters
    ----------
    network : :class:`~nngt.Network` subclass instance
        Network that will be simulated.
    instructions : dict
        Variables to initialize. Allowed keys are "V_m" and "w". Values are
        3-tuples of type ``("distrib_name", double, double)``.
    make_nest : bool, optional (default: False)
        If ``True`` and network has not been converted to NEST, automatically
        generate the network, else raises an exception.

    Example
    -------
    python::
        instructions = {
            "V_m": ("uniform", -80., -60.),
            "w": ("normal", 50., 5.)
        }
    '''
    allowed = ("V_m", "w")
    # check whether network is in NEST
    if network._nest_gid is None:
        if make_nest:
            make_nest_network(network)
        else:
            raise AttributeError('`network` has not converted to NEST yet.')
    num_neurons = network.node_nb()
    for key, val in instructions.items():
        if key in allowed:
            state = _generate_random(num_neurons, val)
            nest.SetStatus(list(network.nest_gid), key, state)
        else:
            raise RuntimeError('Only "V_m" and "w" can be randomized.')
Exemplo n.º 3
0
 def test_delays(self, graph, instructions, **kwargs):
     '''
     Test entirely run only if NEST is present on the computer.
     Check that delay distribution generated in NNGT, then in NEST, is
     conform to what was instructed.
     '''
     di_distrib = instructions["weights"]
     distrib = di_distrib["distribution"]
     delays = graph.set_delays(distribution=distrib, parameters=di_distrib)
     ref_result = _results_theo(instructions)
     computed_result = _results_exp(delays, instructions)
     self.assertTrue(np.allclose(ref_result,computed_result,self.tolerance))
     if nngt.config['with_nest']:
         # @todo
         from nngt.simulation import make_nest_network
         subnet, gids = make_nest_network(graph)
Exemplo n.º 4
0
graph = nngt.SpatialNetwork(pop, weight_prop={"distrib":"gaussian", "distrib_prop":{"avg_distrib": 60.}})
#~ graph = nngt.SpatialNetwork(pop, weight_prop={"distrib":"lognormal"})
nngt.generation.connect_neural_types(graph, 1, -1, "erdos_renyi", {"density": 0.035})
#~ nngt.generation.connect_neural_types(graph, 1, 1, "newman_watts", {"coord_nb":10, "proba_shortcut": 0.1})
#~ nngt.generation.connect_neural_types(graph, 1, 1, "random_scale_free", {"in_exp": 2.1, "out_exp": 2.9, "density": 0.065})
nngt.generation.connect_neural_types(graph, 1, 1, "erdos_renyi", {"density": 0.077})
nngt.generation.connect_neural_types(graph, -1, 1, "erdos_renyi", {"density": 0.2})
nngt.generation.connect_neural_types(graph, -1, -1, "erdos_renyi", {"density": 0.04})


#-----------------------------------------------------------------------------#
# NEST objects
#------------------------
#

subnet, gids = make_nest_network(graph)

recorders, record = nngt.simulation.monitor_nodes(gids, ["spike_detector", "multimeter"], [["spikes"], ["V_m"]], network=graph)

nngt.simulation.set_noise(gids, 70., 80.)
nngt.simulation.set_poisson_input(gids[570:870], 44000.)


#-----------------------------------------------------------------------------#
# Names
#------------------------
#

simtime = 1000.
nest.Simulate(simtime)