.. 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 Click :ref:`here ` 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 ---------------------------------------------------------------- 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:: default import nest import matplotlib.pyplot as plt nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 38-39 somatic and dendritic parameters .. GENERATED FROM PYTHON SOURCE LINES 39-52 .. code-block:: default soma_params = { 'C_m': 10.0, # [pF] Capacitance 'g_C': 0.0, # soma has no parent 'g_L': 1., # [nS] Leak conductance 'e_L': -70.0 # [mV] leak reversal } 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 } .. GENERATED FROM PYTHON SOURCE LINES 53-54 create a model with three compartments .. GENERATED FROM PYTHON SOURCE LINES 54-61 .. code-block:: default 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 62-63 spike threshold .. GENERATED FROM PYTHON SOURCE LINES 63-65 .. code-block:: default nest.SetStatus(cm, {'V_th': -50.}) .. GENERATED FROM PYTHON SOURCE LINES 66-71 - 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 71-77 .. code-block:: default receptors = [ {"comp_idx": 0, "receptor_type": "GABA"}, {"comp_idx": 1, "receptor_type": "AMPA", "params": {"tau_r_AMPA": .2, "tau_d_AMPA": 3., "e_AMPA": 0.}}, {"comp_idx": 2, "receptor_type": "AMPA_NMDA"} ] cm.receptors = receptors .. GENERATED FROM PYTHON SOURCE LINES 78-80 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 80-82 .. code-block:: default syn_idx_GABA, syn_idx_AMPA, syn_idx_NMDA = 0, 1, 2 .. GENERATED FROM PYTHON SOURCE LINES 83-84 create three spike generators .. GENERATED FROM PYTHON SOURCE LINES 84-88 .. code-block:: default sg1 = nest.Create('spike_generator', 1, {'spike_times': [101., 105., 106., 110., 150.]}) sg2 = nest.Create('spike_generator', 1, {'spike_times': [115., 155., 160., 162., 170., 254., 260., 272., 278.]}) sg3 = nest.Create('spike_generator', 1, {'spike_times': [250., 255., 260., 262., 270.]}) .. GENERATED FROM PYTHON SOURCE LINES 89-90 connect the spike generators to the receptors .. GENERATED FROM PYTHON SOURCE LINES 90-97 .. code-block:: default nest.Connect(sg1, cm, syn_spec={ 'synapse_model': 'static_synapse', 'weight': .1, 'delay': 0.5, 'receptor_type': syn_idx_AMPA}) nest.Connect(sg2, cm, syn_spec={ 'synapse_model': 'static_synapse', 'weight': .2, 'delay': 0.5, 'receptor_type': syn_idx_NMDA}) nest.Connect(sg3, cm, syn_spec={ 'synapse_model': 'static_synapse', 'weight': .3, 'delay': 0.5, 'receptor_type': syn_idx_GABA}) .. GENERATED FROM PYTHON SOURCE LINES 98-99 create and connect a current generator to compartment 1 .. GENERATED FROM PYTHON SOURCE LINES 99-103 .. code-block:: default dcg = nest.Create('dc_generator', {'amplitude': 1.}) nest.Connect(dcg, cm, syn_spec={ 'synapse_model': 'static_synapse', 'weight': 1., 'delay': 0.1, 'receptor_type': 1}) .. GENERATED FROM PYTHON SOURCE LINES 104-105 create and connect a multimeter to measure the three compartmental voltages .. GENERATED FROM PYTHON SOURCE LINES 105-117 .. code-block:: default mm = nest.Create('multimeter', 1, {'record_from': ['v_comp0', 'v_comp1', 'v_comp2'], 'interval': .1}) nest.Connect(mm, cm) nest.Simulate(400.) 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: receptors_and_current.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: receptors_and_current.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_