.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/ignore_and_spike_mechanism.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_ignore_and_spike_mechanism.py: Ignore-and-spike mechanism 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%2Fignore_and_spike_mechanism.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 demonstrates the ignore-and-spike mechanism, which causes a neuron to spike at defined intervals with a specified initial offset, ignoring spikes from its internal dynamics. Two neurons are simulated: one with the ignore-and-spike mechanism enabled and one without. Both receive the same external current, and their spike times are recorded and compared. .. GENERATED FROM PYTHON SOURCE LINES 36-39 First, we import all necessary modules for simulation, analysis and plotting. Additionally, we set the verbosity to suppress info messages and reset the kernel. .. GENERATED FROM PYTHON SOURCE LINES 39-46 .. code-block:: Python import matplotlib.pyplot as plt import nest nest.verbosity = nest.VerbosityLevel.WARNING nest.ResetKernel() .. GENERATED FROM PYTHON SOURCE LINES 47-48 Second, we set the simulation resolution. .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python nest.set(resolution=0.1) .. GENERATED FROM PYTHON SOURCE LINES 52-56 Third, we create two neurons and a spike recorder. The first neuron uses the ignore-and-spike mechanism to fire at regular intervals (every 10 ms, starting at 5 ms). The second neuron behaves normally, responding to its internal dynamics. .. GENERATED FROM PYTHON SOURCE LINES 56-69 .. code-block:: Python nrn_regular = nest.Create("iaf_psc_delta") nrn_ignore_spike = nest.Create( "iaf_psc_delta", params=dict( ignore_and_spike=True, ignore_and_spike_offset=5.0, ignore_and_spike_interval=10.0, ), ) spike_recorder = nest.Create("spike_recorder") .. GENERATED FROM PYTHON SOURCE LINES 70-73 Fourth, we set the same external current for both neurons. Without the ignore-and-spike mechanism, this would cause irregular spiking based on the neuron's membrane dynamics. .. GENERATED FROM PYTHON SOURCE LINES 73-77 .. code-block:: Python nrn_regular.I_e = 400.0 nrn_ignore_spike.I_e = 400.0 .. GENERATED FROM PYTHON SOURCE LINES 78-79 Fifth, we connect both neurons to the spike recorder. .. GENERATED FROM PYTHON SOURCE LINES 79-83 .. code-block:: Python nest.Connect(nrn_regular, spike_recorder) nest.Connect(nrn_ignore_spike, spike_recorder) .. GENERATED FROM PYTHON SOURCE LINES 84-85 Now we simulate the network for 100 ms. .. GENERATED FROM PYTHON SOURCE LINES 85-88 .. code-block:: Python nest.Simulate(100.0) .. GENERATED FROM PYTHON SOURCE LINES 89-92 Finally, we retrieve the spike times and plot them as a raster plot. The neuron with ignore-and-spike enabled should show perfectly regular spikes at 5, 15, 25, 35, ... ms, regardless of the external input. .. GENERATED FROM PYTHON SOURCE LINES 92-114 .. code-block:: Python events = spike_recorder.get("events") senders = events["senders"] times = events["times"] fig, ax = plt.subplots(figsize=(6, 2)) fig.subplots_adjust(left=0.3, right=0.95) ax.scatter(times, senders, marker="|", color="#3455B4", s=300) ax.set_xlabel("Time (ms)") ax.set_yticks([nrn_regular.global_id, nrn_ignore_spike.global_id]) ax.set_yticklabels(["Regular neuron", "Ignore-and-spike\nneuron"], ha="center") ax.tick_params(axis="y", pad=50) ax.set_xticks(range(0, 105, 5)) ax.set_xlim(0, 100) ax.set_ylim(0.5, 2.5) ax.spines[["top", "right"]].set_visible(False) ax.grid(True, alpha=0.3) fig.tight_layout() plt.show() .. _sphx_glr_download_auto_examples_ignore_and_spike_mechanism.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ignore_and_spike_mechanism.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ignore_and_spike_mechanism.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ignore_and_spike_mechanism.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_