def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm_params = {
        "record_to": ["memory"],
        "withgid": True,
        "withtime": True,
        "interval": 0.1
    }
    vm = nest.Create("voltmeter", params=vm_params)
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    from nest import visualization
    allnodes = pg + nest.GetLeaves(pop1)[0] + nest.GetLeaves(pop2)[0] + vm
    visualization.plot_network(allnodes, "test_csa.png")

    if havePIL:
        im = Image.open("test_csa.png")
        im.show()

    from nest import voltage_trace
    voltage_trace.from_device(vm)
Example #2
0
def csa_example():

    cs = csa.cset(csa.random(0.1), 10000.0, 1.0)

    pop1 = nest.LayoutNetwork("iaf_neuron", [16])
    pop2 = nest.LayoutNetwork("iaf_neuron", [16])

    nest.PrintNetwork(10)

    nest.CGConnect(pop1, pop2, cs, {"weight": 0, "delay": 1})

    pg = nest.Create("poisson_generator", params={"rate": 80000.0})
    nest.DivergentConnect(pg, nest.GetLeaves(pop1)[0], 1.2, 1.0)

    vm_params = {"record_to": ["memory"], "withgid": True,
                 "withtime": True, "interval": 0.1}
    vm = nest.Create("voltmeter", params=vm_params)
    nest.DivergentConnect(vm, nest.GetLeaves(pop2)[0])

    nest.Simulate(50.0)

    from nest import visualization
    allnodes = pg + nest.GetLeaves(pop1)[0] + nest.GetLeaves(pop2)[0] + vm
    visualization.plot_network(allnodes, "test_csa.png")

    if havePIL:
        im = Image.open("test_csa.png")
        im.show()

    from nest import voltage_trace
    voltage_trace.from_device(vm)
Example #3
0
    def test_plot_network(self):
        """Test plot_network"""
        import nest.visualization as nvis
        nest.ResetKernel()
        sources = nest.Create('iaf_psc_alpha', 10)
        targets = nest.Create('iaf_psc_alpha', 10)
        nest.Connect(sources, targets)

        filename = os.path.join(self.nest_tmpdir(), 'network_plot.png')
        self.filenames.append(filename)
        nvis.plot_network(sources + targets, filename)
        assert os.path.isfile(filename), 'Plot was not created or not saved'
Example #4
0
the neurons of the pre-synaptic population.
"""

pg = nest.Create("poisson_generator", params={"rate": 100000.0})
nest.Connect(pg, pre, "all_to_all")

"""
To measure and record the membrane potentials of the neurons, we
create a `voltmeter` and connect it to all post-synaptic nodes.
"""

vm = nest.Create("voltmeter")
nest.Connect(vm, post, "all_to_all")

"""
We save the whole connection graph of the network as a PNG image
using the `plot_network` function of the `visualization` submodule of
PyNEST.
"""

allnodes = pg + pre + post + vm
visualization.plot_network(allnodes, "csa_example_graph.png")

"""
Finally, we simulate the network for 50 ms. The voltage traces of
the post-synaptic nodes are plotted.
"""

nest.Simulate(50.0)
voltage_trace.from_device(vm)
Example #5
0
"""
To stimulate the network, we create a `poisson_generator` and set it
up to fire with a rate of 100000 spikes per second. It is connected to
the neurons of the pre-synaptic population.
"""

pg = nest.Create("poisson_generator", params={"rate": 100000.0})
nest.Connect(pg, pre, "all_to_all")
"""
To measure and record the membrane potentials of the neurons, we
create a `voltmeter` and connect it to all post-synaptic nodes.
"""

vm = nest.Create("voltmeter")
nest.Connect(vm, post, "all_to_all")
"""
We save the whole connection graph of the network as a PNG image
using the `plot_network` function of the `visualization` submodule of
PyNEST.
"""

allnodes = pg + pre + post + vm
visualization.plot_network(allnodes, "csa_example_graph.png")
"""
Finally, we simulate the network for 50 ms. The voltage traces of
the post-synaptic nodes are plotted.
"""

nest.Simulate(50.0)
voltage_trace.from_device(vm)