.. 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 Click :ref:`here ` 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 ------------------------------ 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:: default import nest import numpy import matplotlib.pyplot as plt .. GENERATED FROM PYTHON SOURCE LINES 39-40 Assigning the simulation parameters to variables. .. GENERATED FROM PYTHON SOURCE LINES 40-44 .. code-block:: default 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:: default 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:: default d_e = 5. # 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-81 .. code-block:: default 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. # noise parameter } .. GENERATED FROM PYTHON SOURCE LINES 82-86 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 86-95 .. code-block:: default 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 96-97 Creation of the nodes using ``Create``. .. GENERATED FROM PYTHON SOURCE LINES 97-102 .. code-block:: default n_e = nest.Create(neuron_model, NE, neuron_params) n_i = nest.Create(neuron_model, NI, neuron_params) .. GENERATED FROM PYTHON SOURCE LINES 103-105 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 105-109 .. code-block:: default 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:: default 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:: default 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:: default 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:: default 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:: default 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: lin_rate_ipn_network.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: lin_rate_ipn_network.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_