.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/compartmental_model/receptors_and_current.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_compartmental_model_receptors_and_current.py: Constructing and simulating compartmental models with different receptor types ------------------------------------------------------------------------------ .. 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%2Fcompartmental_model%2Freceptors_and_current.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 example demonstrates how to initialize a three-compartment model with different receptor types. Each compartment receives a different receptor. The output shows the voltage in each of the three compartments. :Authors: WAM Wybo .. GENERATED FROM PYTHON SOURCE LINES 31-37 .. code-block:: Python import matplotlib.pyplot as plt import nest nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 38-39 somatic and dendritic parameters .. GENERATED FROM PYTHON SOURCE LINES 39-54 .. code-block:: Python soma_params = { "C_m": 10.0, # [pF] Capacitance "g_C": 0.0, # soma has no parent "g_L": 1.0, # [nS] Leak conductance "e_L": -70.0, # [mV] leak reversal "v_comp": -70.0, # [mV] voltage initialization } dend_params = { "C_m": 0.1, # [pF] Capacitance "g_C": 0.1, # [nS] Coupling conductance to parent (soma here) "g_L": 0.1, # [nS] Leak conductance "e_L": -70.0, # [mV] leak reversal "v_comp": -70.0, # [mV] voltage initialization } .. GENERATED FROM PYTHON SOURCE LINES 55-56 create a model with three compartments .. GENERATED FROM PYTHON SOURCE LINES 56-63 .. code-block:: Python cm = nest.Create("cm_default") cm.compartments = [ {"parent_idx": -1, "params": soma_params}, {"parent_idx": 0, "params": dend_params}, {"parent_idx": 0, "params": dend_params}, ] .. GENERATED FROM PYTHON SOURCE LINES 64-65 spike threshold .. GENERATED FROM PYTHON SOURCE LINES 65-67 .. code-block:: Python nest.SetStatus(cm, {"V_th": -50.0}) .. GENERATED FROM PYTHON SOURCE LINES 68-73 - GABA receptor in compartment 0 (soma) - AMPA receptor in compartment 1 note that it is also possible to specify the receptor parameters, if we want to overwrite the default values - AMPA+NMDA receptor in compartment 2 .. GENERATED FROM PYTHON SOURCE LINES 73-79 .. code-block:: Python receptors = [ {"comp_idx": 0, "receptor_type": "GABA"}, {"comp_idx": 1, "receptor_type": "AMPA", "params": {"tau_r_AMPA": 0.2, "tau_d_AMPA": 3.0, "e_AMPA": 0.0}}, {"comp_idx": 2, "receptor_type": "AMPA_NMDA"}, ] cm.receptors = receptors .. GENERATED FROM PYTHON SOURCE LINES 80-82 receptors get assigned an index which corresponds to the order in which they are added. For clearer bookkeeping, we explicitly define these indices here. .. GENERATED FROM PYTHON SOURCE LINES 82-84 .. code-block:: Python syn_idx_GABA, syn_idx_AMPA, syn_idx_NMDA = 0, 1, 2 .. GENERATED FROM PYTHON SOURCE LINES 85-86 create three spike generators .. GENERATED FROM PYTHON SOURCE LINES 86-92 .. code-block:: Python sg1 = nest.Create("spike_generator", 1, {"spike_times": [101.0, 105.0, 106.0, 110.0, 150.0]}) sg2 = nest.Create( "spike_generator", 1, {"spike_times": [115.0, 155.0, 160.0, 162.0, 170.0, 254.0, 260.0, 272.0, 278.0]} ) sg3 = nest.Create("spike_generator", 1, {"spike_times": [250.0, 255.0, 260.0, 262.0, 270.0]}) .. GENERATED FROM PYTHON SOURCE LINES 93-94 connect the spike generators to the receptors .. GENERATED FROM PYTHON SOURCE LINES 94-104 .. code-block:: Python nest.Connect( sg1, cm, syn_spec={"synapse_model": "static_synapse", "weight": 0.1, "delay": 0.5, "receptor_type": syn_idx_AMPA} ) nest.Connect( sg2, cm, syn_spec={"synapse_model": "static_synapse", "weight": 0.2, "delay": 0.5, "receptor_type": syn_idx_NMDA} ) nest.Connect( sg3, cm, syn_spec={"synapse_model": "static_synapse", "weight": 0.3, "delay": 0.5, "receptor_type": syn_idx_GABA} ) .. GENERATED FROM PYTHON SOURCE LINES 105-106 create and connect a current generator to compartment 1 .. GENERATED FROM PYTHON SOURCE LINES 106-109 .. code-block:: Python dcg = nest.Create("dc_generator", {"amplitude": 1.0}) nest.Connect(dcg, cm, syn_spec={"synapse_model": "static_synapse", "weight": 1.0, "delay": 0.1, "receptor_type": 1}) .. GENERATED FROM PYTHON SOURCE LINES 110-111 create and connect a multimeter to measure the three compartmental voltages .. GENERATED FROM PYTHON SOURCE LINES 111-123 .. code-block:: Python mm = nest.Create("multimeter", 1, {"record_from": ["v_comp0", "v_comp1", "v_comp2"], "interval": 0.1}) nest.Connect(mm, cm) nest.Simulate(400.0) res = nest.GetStatus(mm, "events")[0] plt.plot(res["times"], res["v_comp0"], c="b", label="v_comp0") plt.plot(res["times"], res["v_comp1"], c="r", label="v_comp1") plt.plot(res["times"], res["v_comp2"], c="g", label="v_comp2") plt.legend() plt.show() .. _sphx_glr_download_auto_examples_compartmental_model_receptors_and_current.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: receptors_and_current.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: receptors_and_current.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_