.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/gap_junctions_two_neurons.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_gap_junctions_two_neurons.py: Gap Junctions: Two neuron example --------------------------------- .. 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%2Fgap_junctions_two_neurons.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 two Hodgkin-Huxley neurons of type ``hh_psc_alpha_gap`` connected by a gap junction. Both neurons receive a constant current of 100.0 pA. The neurons are initialized with different membrane potentials and synchronize over time due to the gap-junction connection. .. GENERATED FROM PYTHON SOURCE LINES 32-39 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 40-42 First we set the resolution of the simulation, create two neurons and create a ``voltmeter`` for recording. .. GENERATED FROM PYTHON SOURCE LINES 42-49 .. code-block:: Python nest.resolution = 0.05 neuron = nest.Create("hh_psc_alpha_gap", 2) vm = nest.Create("voltmeter", params={"interval": 0.1}) .. GENERATED FROM PYTHON SOURCE LINES 50-52 Then we set the constant current input, modify the inital membrane potential of one of the neurons and connect the neurons to the ``voltmeter``. .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python neuron.I_e = 100.0 neuron[0].V_m = -10.0 nest.Connect(vm, neuron, "all_to_all") .. GENERATED FROM PYTHON SOURCE LINES 59-63 In order to create the ``gap_junction`` connection we employ the ``all_to_all`` connection rule: Gap junctions are bidirectional connections, therefore we need to connect `neuron[0]` to `neuron[1]` and `neuron[1]` to `neuron[0]`: .. GENERATED FROM PYTHON SOURCE LINES 63-68 .. code-block:: Python nest.Connect( neuron, neuron, {"rule": "all_to_all", "allow_autapses": False}, {"synapse_model": "gap_junction", "weight": 0.5} ) .. GENERATED FROM PYTHON SOURCE LINES 69-71 Finally we start the simulation and plot the membrane potentials of both neurons. .. GENERATED FROM PYTHON SOURCE LINES 71-84 .. code-block:: Python nest.Simulate(351.0) senders = vm.events["senders"] times = vm.events["times"] v_m_values = vm.events["V_m"] plt.figure(1) plt.plot(times[numpy.where(senders == 1)], v_m_values[numpy.where(senders == 1)], "r-") plt.plot(times[numpy.where(senders == 2)], v_m_values[numpy.where(senders == 2)], "g-") plt.xlabel("time (ms)") plt.ylabel("membrane potential (mV)") plt.show() .. _sphx_glr_download_auto_examples_gap_junctions_two_neurons.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: gap_junctions_two_neurons.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: gap_junctions_two_neurons.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_