.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/lin_rate_ipn_network.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_lin_rate_ipn_network.py: Network of linear rate neurons ------------------------------ .. only:: html ---- Run this example as a Jupyter notebook: .. card:: :width: 25% :margin: 2 :text-align: center :link: https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fnest%2Fnest-simulator-examples&urlpath=lab%2Ftree%2Fnest-simulator-examples%2Fnotebooks%2Fnotebooks%2Flin_rate_ipn_network.ipynb&branch=main :link-alt: JupyterHub service .. image:: https://nest-simulator.org/TryItOnEBRAINS.png .. grid:: 1 1 1 1 :padding: 0 0 2 0 .. grid-item:: :class: sd-text-muted :margin: 0 0 3 0 :padding: 0 0 3 0 :columns: 4 See :ref:`our guide ` for more information and troubleshooting. ---- This script simulates an excitatory and an inhibitory population of ``lin_rate_ipn`` neurons with delayed excitatory and instantaneous inhibitory connections. The rate of all neurons is recorded using a multimeter. The resulting rate for one excitatory and one inhibitory neuron is plotted. .. GENERATED FROM PYTHON SOURCE LINES 33-38 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy .. GENERATED FROM PYTHON SOURCE LINES 39-40 Assigning the simulation parameters to variables. .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: Python dt = 0.1 # the resolution in ms T = 100.0 # Simulation time in ms .. GENERATED FROM PYTHON SOURCE LINES 45-46 Definition of the number of neurons .. GENERATED FROM PYTHON SOURCE LINES 46-52 .. code-block:: Python order = 50 NE = int(4 * order) # number of excitatory neurons NI = int(1 * order) # number of inhibitory neurons N = int(NE + NI) # total number of neurons .. GENERATED FROM PYTHON SOURCE LINES 53-54 Definition of the connections .. GENERATED FROM PYTHON SOURCE LINES 54-66 .. code-block:: Python d_e = 5.0 # delay of excitatory connections in ms g = 5.0 # ratio inhibitory weight/excitatory weight epsilon = 0.1 # connection probability w = 0.1 / numpy.sqrt(N) # excitatory connection strength KE = int(epsilon * NE) # number of excitatory synapses per neuron (outdegree) KI = int(epsilon * NI) # number of inhibitory synapses per neuron (outdegree) K_tot = int(KI + KE) # total number of synapses per neuron connection_rule = "fixed_outdegree" # connection rule .. GENERATED FROM PYTHON SOURCE LINES 67-68 Definition of the neuron model and its neuron parameters .. GENERATED FROM PYTHON SOURCE LINES 68-82 .. code-block:: Python neuron_model = "lin_rate_ipn" # neuron model neuron_params = { "linear_summation": True, # type of non-linearity (not affecting linear rate models) "tau": 10.0, # time constant of neuronal dynamics in ms "mu": 2.0, # mean input "sigma": 5.0 # noise parameter } .. GENERATED FROM PYTHON SOURCE LINES 83-87 Configuration of the simulation kernel by the previously defined time resolution used in the simulation. Setting ``print_time`` to True prints the already processed simulation time as well as its percentage of the total simulation time. .. GENERATED FROM PYTHON SOURCE LINES 87-96 .. code-block:: Python nest.ResetKernel() nest.resolution = dt nest.use_wfr = False nest.print_time = True nest.overwrite_files = True print("Building network") .. GENERATED FROM PYTHON SOURCE LINES 97-98 Creation of the nodes using ``Create``. .. GENERATED FROM PYTHON SOURCE LINES 98-103 .. code-block:: Python n_e = nest.Create(neuron_model, NE, neuron_params) n_i = nest.Create(neuron_model, NI, neuron_params) .. GENERATED FROM PYTHON SOURCE LINES 104-106 To record from the rate neurons a ``multimeter`` is created and the parameter ``record_from`` is set to `rate` as well as the recording interval to `dt` .. GENERATED FROM PYTHON SOURCE LINES 106-109 .. code-block:: Python mm = nest.Create("multimeter", params={"record_from": ["rate"], "interval": dt}) .. GENERATED FROM PYTHON SOURCE LINES 110-115 Specify synapse and connection dictionaries: Connections originating from excitatory neurons are associated with a delay `d` (``rate_connection_delayed``). Connections originating from inhibitory neurons are not associated with a delay (``rate_connection_instantaneous``). .. GENERATED FROM PYTHON SOURCE LINES 115-121 .. code-block:: Python syn_e = {"weight": w, "delay": d_e, "synapse_model": "rate_connection_delayed"} syn_i = {"weight": -g * w, "synapse_model": "rate_connection_instantaneous"} conn_e = {"rule": connection_rule, "outdegree": KE} conn_i = {"rule": connection_rule, "outdegree": KI} .. GENERATED FROM PYTHON SOURCE LINES 122-123 Connect rate units .. GENERATED FROM PYTHON SOURCE LINES 123-129 .. code-block:: Python nest.Connect(n_e, n_e, conn_e, syn_e) nest.Connect(n_i, n_i, conn_i, syn_i) nest.Connect(n_e, n_i, conn_i, syn_e) nest.Connect(n_i, n_e, conn_e, syn_i) .. GENERATED FROM PYTHON SOURCE LINES 130-131 Connect recording device to rate units .. GENERATED FROM PYTHON SOURCE LINES 131-134 .. code-block:: Python nest.Connect(mm, n_e + n_i) .. GENERATED FROM PYTHON SOURCE LINES 135-136 Simulate the network .. GENERATED FROM PYTHON SOURCE LINES 136-139 .. code-block:: Python nest.Simulate(T) .. GENERATED FROM PYTHON SOURCE LINES 140-141 Plot rates of one excitatory and one inhibitory neuron .. GENERATED FROM PYTHON SOURCE LINES 141-162 .. code-block:: Python data = mm.events senders = data["senders"] rate = data["rate"] times = data["times"] ne_0_id = n_e[0].global_id ni_0_id = n_i[0].global_id where_sender_is_ne_0 = numpy.where(senders == ne_0_id) where_sender_is_ni_0 = numpy.where(senders == ni_0_id) rate_ex = rate[where_sender_is_ne_0] rate_in = rate[where_sender_is_ni_0] times = times[where_sender_is_ne_0] plt.figure() plt.plot(times, rate_ex, label="excitatory") plt.plot(times, rate_in, label="inhibitory") plt.xlabel("time (ms)") plt.ylabel("rate (a.u.)") plt.show() .. _sphx_glr_download_auto_examples_lin_rate_ipn_network.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: lin_rate_ipn_network.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: lin_rate_ipn_network.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_