.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/spatial/nodes_source_target.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_nodes_source_target.py: Spatial networks: Showcase of PlotTargets, PlotSources, GetTargetNodes, GetSourceNodes -------------------------------------------------------------------------------------- .. 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%2Fnodes_source_target.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. ---- Anno Christopher Kurth, INM-6 .. GENERATED FROM PYTHON SOURCE LINES 28-71 .. code-block:: Python import nest from matplotlib import pyplot as plt # create a spatial population s_nodes = nest.Create("iaf_psc_alpha", positions=nest.spatial.grid(shape=[11, 11], extent=[11.0, 11.0])) # connectivity specifications with a mask conndict = { "rule": "pairwise_bernoulli", "p": 1.0, "mask": {"rectangular": {"lower_left": [-1.0, -1.0], "upper_right": [1.0, 1.0]}, "anchor": [3.0, 3.0]}, } # get center element center_neuron = nest.FindCenterElement(s_nodes) # connect population s_nodes with itself according to the given # specifications nest.Connect(s_nodes, s_nodes, conndict) # Plot target neurons of center neuron fig = nest.PlotLayer(s_nodes, nodesize=80, nodecolor="coral") nest.PlotTargets(center_neuron, s_nodes, fig=fig) plt.title("Target neurons of center neuron") plt.show() # Plot source neurons of center neuron fig = nest.PlotLayer(s_nodes, nodesize=80, nodecolor="coral") nest.PlotSources(s_nodes, center_neuron, fig=fig) plt.title("Source neurons of center neuron") plt.show() print("Target neurons of center neuron") print(nest.GetTargetNodes(center_neuron, s_nodes)) print("Source neurons of center neuron") print(nest.GetSourceNodes(s_nodes, center_neuron)) print("Positions of target neurons of center neuron") print(nest.GetTargetPositions(center_neuron, s_nodes)) print("Positions of source neurons of center neuron") print(nest.GetSourcePositions(s_nodes, center_neuron)) .. _sphx_glr_download_auto_examples_spatial_nodes_source_target.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: nodes_source_target.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: nodes_source_target.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_