.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/Potjans_2014/run_microcircuit.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_Potjans_2014_run_microcircuit.py: PyNEST Microcircuit: Run Simulation ----------------------------------------- .. 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%2FPotjans_2014%2Frun_microcircuit.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 is an example script for running the microcircuit model and generating basic plots of the network activity. .. GENERATED FROM PYTHON SOURCE LINES 31-32 Import the necessary modules and start the time measurements. .. GENERATED FROM PYTHON SOURCE LINES 32-44 .. code-block:: Python import time import nest import network import numpy as np from network_params import net_dict from sim_params import sim_dict from stimulus_params import stim_dict time_start = time.time() .. GENERATED FROM PYTHON SOURCE LINES 45-53 Initialize the network with simulation, network and stimulation parameters, then create and connect all nodes, and finally simulate. The times for a presimulation and the main simulation are taken independently. A presimulation is useful because the spike activity typically exhibits a startup transient. In benchmark simulations, this transient should be excluded from a time measurement of the state propagation phase. Besides, statistical measures of the spike activity should only be computed after the transient has passed. .. GENERATED FROM PYTHON SOURCE LINES 53-69 .. code-block:: Python net = network.Network(sim_dict, net_dict, stim_dict) time_network = time.time() net.create() time_create = time.time() net.connect() time_connect = time.time() net.simulate(sim_dict["t_presim"]) time_presimulate = time.time() net.simulate(sim_dict["t_sim"]) time_simulate = time.time() .. GENERATED FROM PYTHON SOURCE LINES 70-76 Plot a spike raster of the simulated neurons and a box plot of the firing rates for each population. For visual purposes only, spikes 100 ms before and 100 ms after the thalamic stimulus time are plotted here by default. The computation of spike rates discards the presimulation time to exclude initialization artifacts. .. GENERATED FROM PYTHON SOURCE LINES 76-82 .. code-block:: Python raster_plot_interval = np.array([stim_dict["th_start"] - 100.0, stim_dict["th_start"] + 100.0]) firing_rates_interval = np.array([sim_dict["t_presim"], sim_dict["t_presim"] + sim_dict["t_sim"]]) net.evaluate(raster_plot_interval, firing_rates_interval) time_evaluate = time.time() .. GENERATED FROM PYTHON SOURCE LINES 83-85 Summarize time measurements. Rank 0 usually takes longest because of the data evaluation and print calls. .. GENERATED FROM PYTHON SOURCE LINES 85-96 .. code-block:: Python print( "\nTimes of Rank {}:\n".format(nest.Rank()) + " Total time: {:.3f} s\n".format(time_evaluate - time_start) + " Time to initialize: {:.3f} s\n".format(time_network - time_start) + " Time to create: {:.3f} s\n".format(time_create - time_network) + " Time to connect: {:.3f} s\n".format(time_connect - time_create) + " Time to presimulate: {:.3f} s\n".format(time_presimulate - time_connect) + " Time to simulate: {:.3f} s\n".format(time_simulate - time_presimulate) + " Time to evaluate: {:.3f} s\n".format(time_evaluate - time_simulate) ) .. _sphx_glr_download_auto_examples_Potjans_2014_run_microcircuit.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_microcircuit.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: run_microcircuit.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_