.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/spatial/connex_ew.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_spatial_connex_ew.py: Spatial networks: Circular mask and flat probability, with edge wrap -------------------------------------------------------------------- .. 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%2Fspatial%2Fconnex_ew.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. ---- Create two populations of iaf_psc_alpha neurons on a 30x30 grid with edge_wrap, connect with circular mask, flat probability, visualize. BCCN Tutorial @ CNS*09 Hans Ekkehard Plesser, UMB .. GENERATED FROM PYTHON SOURCE LINES 33-42 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy as np nest.ResetKernel() pos = nest.spatial.grid(shape=[30, 30], extent=[3.0, 3.0], edge_wrap=True) .. GENERATED FROM PYTHON SOURCE LINES 43-44 create and connect two populations .. GENERATED FROM PYTHON SOURCE LINES 44-53 .. code-block:: Python a = nest.Create("iaf_psc_alpha", positions=pos) b = nest.Create("iaf_psc_alpha", positions=pos) cdict = {"rule": "pairwise_bernoulli", "p": 0.5, "mask": {"circular": {"radius": 0.5}}} nest.Connect(a, b, conn_spec=cdict, syn_spec={"weight": nest.random.uniform(0.5, 2.0)}) plt.clf() .. GENERATED FROM PYTHON SOURCE LINES 54-55 plot targets of neurons in different grid locations .. GENERATED FROM PYTHON SOURCE LINES 55-77 .. code-block:: Python # first, clear existing figure, get current figure plt.clf() fig = plt.gcf() # plot targets of two source neurons into same figure, with mask for src_index in [30 * 15 + 15, 0]: # obtain node id for center src = a[src_index : src_index + 1] nest.PlotTargets(src, b, mask=cdict["mask"], fig=fig) # beautify plt.axes().set_xticks(np.arange(-1.5, 1.55, 0.5)) plt.axes().set_yticks(np.arange(-1.5, 1.55, 0.5)) plt.grid(True) plt.axis([-2.0, 2.0, -2.0, 2.0]) plt.axes().set_aspect("equal", "box") plt.title("Connection targets") plt.show() # plt.savefig('connex_ew.pdf') .. _sphx_glr_download_auto_examples_spatial_connex_ew.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: connex_ew.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: connex_ew.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_