.. 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 Click :ref:`here ` 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 ----------------------------------------- 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-42 .. code-block:: default from stimulus_params import stim_dict from network_params import net_dict from sim_params import sim_dict import network import nest import numpy as np import time time_start = time.time() .. GENERATED FROM PYTHON SOURCE LINES 43-51 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 51-67 .. code-block:: default 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 68-74 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 74-82 .. code-block:: default 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-110 .. code-block:: default 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)) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _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-python :download:`Download Python source code: run_microcircuit.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: run_microcircuit.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_