.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/hh_psc_alpha.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_hh_psc_alpha.py: Example using Hodgkin-Huxley neuron ----------------------------------- .. 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%2Fhh_psc_alpha.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 produces a rate-response (FI) curve of the Hodgkin-Huxley neuron ``hh_psc_alpha`` in response to a range of different current (DC) stimulations. The result is plotted using matplotlib. Since a DC input affects only the neuron's channel dynamics, this routine does not yet check correctness of synaptic response. .. GENERATED FROM PYTHON SOURCE LINES 33-74 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy as np nest.set_verbosity("M_WARNING") nest.ResetKernel() simtime = 1000 # Amplitude range, in pA dcfrom = 0 dcstep = 20 dcto = 2000 h = 0.1 # simulation step size in mS neuron = nest.Create("hh_psc_alpha") sr = nest.Create("spike_recorder") sr.record_to = "memory" nest.Connect(neuron, sr, syn_spec={"weight": 1.0, "delay": h}) # Simulation loop n_data = int(dcto / float(dcstep)) amplitudes = np.zeros(n_data) event_freqs = np.zeros(n_data) for i, amp in enumerate(range(dcfrom, dcto, dcstep)): neuron.I_e = float(amp) print(f"Simulating with current I={amp} pA") nest.Simulate(1000) # one second warm-up time for equilibrium state sr.n_events = 0 # then reset spike counts nest.Simulate(simtime) # another simulation call to record firing rate n_events = sr.n_events amplitudes[i] = amp event_freqs[i] = n_events / (simtime / 1000.0) plt.plot(amplitudes, event_freqs) plt.show() .. _sphx_glr_download_auto_examples_hh_psc_alpha.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: hh_psc_alpha.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: hh_psc_alpha.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_