Spatially structured network module

Functions relating to spatial properties of nodes

nest.lib.hl_api_spatial.CreateMask(masktype, specs, anchor=None)

Create a spatial mask for connections.

Masks are used when creating connections. A mask describes the area of the pool population that is searched for to connect for any given node in the driver population. Several mask types are available. Examples are the grid region, the rectangular, circular or doughnut region.

The command CreateMask() creates a Mask object which may be combined with other Mask objects using Boolean operators. The mask is specified in a dictionary.

Mask objects can be passed to Connect() in a connection dictionary with the key ‘mask’.

Parameters:
  • masktype (str, ['rectangular' | 'circular' | 'doughnut' | 'elliptical']) – for 2D masks, [‘box’ | ‘spherical’ | ‘ellipsoidal] for 3D masks, [‘grid’] only for grid-based layers in 2D. The mask name corresponds to the geometrical shape of the mask. There are different types for 2- and 3-dimensional layers.

  • specs (dict) – Dictionary specifying the parameters of the provided masktype, see Mask types.

  • anchor ([tuple/list of floats | dict with the keys ‘column’ and ‘row’ (for grid masks only)], optional, default: None) – By providing anchor coordinates, the location of the mask relative to the driver node can be changed. The list of coordinates has a length of 2 or 3 dependent on the number of dimensions.

Returns:

Object representing the mask

Return type:

Mask

See also

Connect

Notes

  • All angles must be given in degrees.

Mask types

Available mask types (masktype) and their corresponding parameter dictionaries:

  • 2D free and grid-based layers
    'rectangular' :
        {'lower_left'   : [float, float],
         'upper_right'  : [float, float],
         'azimuth_angle': float  # default:0.0}
    #or
    'circular' :
        {'radius' : float}
    #or
    'doughnut' :
        {'inner_radius' : float,
         'outer_radius' : float}
    #or
    'elliptical' :
        {'major_axis' : float,
         'minor_axis' : float,
         'azimuth_angle' : float,   # default: 0.0,
         'anchor' : [float, float], # default: [0.0, 0.0]}
    
  • 3D free and grid-based layers
    'box' :
        {'lower_left'  : [float, float, float],
         'upper_right' : [float, float, float],
         'azimuth_angle: float  # default: 0.0,
         'polar_angle  : float  # default: 0.0}
    #or
    'spherical' :
        {'radius' : float}
    #or
    'ellipsoidal' :
        {'major_axis' : float,
         'minor_axis' : float,
         'polar_axis' : float
         'azimuth_angle' : float,   # default: 0.0,
         'polar_angle' : float,     # default: 0.0,
         'anchor' : [float, float, float], # default: [0.0, 0.0, 0.0]}}
    
  • 2D grid-based layers only
    'grid' :
        {'rows' : float,
         'columns' : float}
    

    By default the top-left corner of a grid mask, i.e., the grid mask element with grid index [0, 0], is aligned with the driver node. It can be changed by means of the ‘anchor’ parameter:

    'anchor' :
        {'row' : float,
         'column' : float}
    
Example
import nest

# create a grid-based layer
l = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# create a circular mask
m = nest.CreateMask('circular', {'radius': 0.2})

# connectivity specifications
conndict = {'rule': 'pairwise_bernoulli',
            'p': 1.0,
            'mask': m}

# connect layer l with itself according to the specifications
nest.Connect(l, l, conndict)
nest.lib.hl_api_spatial.Displacement(from_arg, to_arg)

Get vector of lateral displacement from node(s)/Position(s) from_arg to node(s) to_arg.

Displacement is the shortest displacement, taking into account periodic boundary conditions where applicable. If explicit positions are given in the from_arg list, they are interpreted in the to_arg population.

  • If one of from_arg or to_arg has length 1, and the other is longer, the displacement from/to the single item to all other items is given.

  • If from_arg and to_arg both have more than two elements, they have to be of the same length and the displacement between each pair is returned.

Parameters:
  • from_arg (NodeCollection or tuple/list with tuple(s)/list(s) of floats) – NodeCollection of node IDs or tuple/list of position(s)

  • to_arg (NodeCollection) – NodeCollection of node IDs

Returns:

Displacement vectors between pairs of nodes in from_arg and to_arg

Return type:

tuple

See also

Distance

Get lateral distances between nodes.

DumpLayerConnections

Write connectivity information to file.

GetPosition

Return the spatial locations of nodes.

Notes

Example
import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# displacement between node 2 and 3
print(nest.Displacement(s_nodes[1], s_nodes[2]))

# displacment between the position (0.0., 0.0) and node 2
print(nest.Displacement([(0.0, 0.0)], s_nodes[1]))
nest.lib.hl_api_spatial.Distance(from_arg, to_arg)

Get lateral distances from node(s)/position(s) from_arg to node(s) to_arg.

The distance between two nodes is the length of its displacement.

If explicit positions are given in the from_arg list, they are interpreted in the to_arg population. Distance is the shortest distance, taking into account periodic boundary conditions where applicable.

  • If one of from_arg or to_arg has length 1, and the other is longer, the displacement from/to the single item to all other items is given.

  • If from_arg and to_arg both have more than two elements, they have to be of the same length and the distance for each pair is returned.

Parameters:
  • from_arg (NodeCollection or tuple/list with tuple(s)/list(s) of floats) – NodeCollection of node IDs or tuple/list of position(s)

  • to_arg (NodeCollection) – NodeCollection of node IDs

Returns:

Distances between from and to

Return type:

tuple

See also

Displacement

Get vector of lateral displacements between nodes.

DumpLayerConnections

Write connectivity information to file.

GetPosition

Return the spatial locations of nodes.

Notes

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# distance between node 2 and 3
print(nest.Distance(s_nodes[1], s_nodes[2]))

# distance between the position (0.0., 0.0) and node 2
print(nest.Distance([(0.0, 0.0)], s_nodes[1]))
nest.lib.hl_api_spatial.DumpLayerConnections(source_layer, target_layer, synapse_model, outname)

Write connectivity information to file.

This function writes connection information to file for all outgoing connections from the given layers with the given synapse model.

For each connection, one line is stored, in the following format:
source_node_id target_node_id weight delay dx dy [dz]

where (dx, dy [, dz]) is the displacement from source to target node. If targets do not have positions (eg spike recorders outside any layer), NaN is written for each displacement coordinate.

Parameters:
  • source_layers (NodeCollection) – NodeCollection of spatially distributed node IDs

  • target_layers (NodeCollection) – NodeCollection of (spatially distributed) node IDs

  • synapse_model (str) – NEST synapse model

  • outname (str) – Name of file to write to (will be overwritten if it exists)

See also

DumpLayerNodes

Write layer node positions to file.

GetPosition

Return the spatial locations of nodes.

GetConnections

Return connection identifiers between sources and targets

Notes

  • If calling this function from a distributed simulation, this function will write to one file per MPI rank.

  • File names are formed by inserting the MPI Rank into the file name before the file name suffix.

  • Each file stores data for local nodes.

Example
import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

nest.Connect(s_nodes, s_nodes,
             {'rule': 'pairwise_bernoulli', 'p': 1.0},
             {'synapse_model': 'static_synapse'})

# write connectivity information to file
nest.DumpLayerConnections(s_nodes, s_nodes, 'static_synapse', 'conns.txt')
nest.lib.hl_api_spatial.DumpLayerNodes(layer, outname)

Write node ID and position data of layer to file.

Write node ID and position data to outname file. For each node in layer, a line with the following information is written:

node ID x-position y-position [z-position]

If layer contains several node IDs, data for all nodes in layer will be written to a single file.

Parameters:
  • layer (NodeCollection) – NodeCollection of spatially distributed node IDs

  • outname (str) – Name of file to write to (existing files are overwritten)

See also

DumpLayerConnections

Write connectivity information to file.

GetPosition

Return the spatial locations of nodes.

Notes

  • If calling this function from a distributed simulation, this function will write to one file per MPI rank.

  • File names are formed by adding the MPI Rank into the file name before the file name suffix.

  • Each file stores data for nodes local to that file.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# write layer node positions to file
nest.DumpLayerNodes(s_nodes, 'positions.txt')
nest.lib.hl_api_spatial.FindCenterElement(layer)

Return NodeCollection of node closest to center of layer.

Parameters:

layer (NodeCollection) – NodeCollection with spatially distributed node IDs

Returns:

NodeCollection of the node closest to the center of the layer, as specified by layer parameters given in layer.spatial. If several nodes are equally close to the center, an arbitrary one of them is returned.

Return type:

NodeCollection

See also

FindNearestElement

Return the node(s) closest to the location(s) in the given layer.

GetPosition

Return the spatial locations of nodes.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# get NodeCollection of the element closest to the center of the layer
nest.FindCenterElement(s_nodes)
nest.lib.hl_api_spatial.FindNearestElement(layer, locations, find_all=False)

Return the node(s) closest to the locations in the given layer.

This function works for fixed grid layer only.

  • If locations is a single 2-element array giving a grid location, return a NodeCollection of layer elements at the given location.

  • If locations is a list of coordinates, the function returns a list of NodeCollection of the nodes at all locations.

Parameters:
  • layer (NodeCollection) – NodeCollection of spatially distributed node IDs

  • locations (tuple(s)/list(s) of tuple(s)/list(s)) – 2-element list with coordinates of a single position, or list of 2-element list of positions

  • find_all (bool, default: False) – If there are several nodes with same minimal distance, return only the first found, if False. If True, instead of returning a single NodeCollection, return a list of NodeCollection containing all nodes with minimal distance.

Returns:

  • NodeCollectionNodeCollection of node IDs if locations is a 2-element list with coordinates of a single position

  • list – list of NodeCollection if find_all is True or locations contains more than one position

See also

FindCenterElement

Return NodeCollection of node closest to center of layers.

GetPosition

Return the spatial locations of nodes.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# get node ID of element closest to some location
nest.FindNearestElement(s_nodes, [3.0, 4.0], True)
nest.lib.hl_api_spatial.GetPosition(nodes)

Return the spatial locations of nodes.

Parameters:

nodes (NodeCollection) – NodeCollection of nodes we want the positions to

Returns:

Tuple of position with 2- or 3-elements or list of positions

Return type:

tuple or tuple of tuple(s)

See also

Displacement

Get vector of lateral displacement between nodes.

Distance

Get lateral distance between nodes.

DumpLayerConnections

Write connectivity information to file.

DumpLayerNodes

Write node positions to file.

Notes

Example

import nest

# Reset kernel
nest.ResetKernel

# create a NodeCollection with spatial extent
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[5, 5]))

# retrieve positions of all (local) nodes belonging to the population
pos = nest.GetPosition(s_nodes)

# retrieve positions of the first node in the NodeCollection
pos = nest.GetPosition(s_nodes[0])

# retrieve positions of a subset of nodes in the population
pos = nest.GetPosition(s_nodes[2:18])
nest.lib.hl_api_spatial.GetSourceNodes(src_layer, targets, syn_model=None)

Obtain sources of targets in given src_layer population.

For each neuron in targets, this function finds all target elements in src_layer. If syn_model is not given (default), all sources are returned, otherwise only sources connected via the given synapse model.

Parameters:
  • src_layer (NodeCollection) – NodeCollection with node IDs of src_layer

  • targets (NodeCollection) – NodeCollection with node IDs of targets

  • syn_model ([None | str], optional, default: None) – Return only source positions for a given synapse model.

Returns:

Tuple of NodeCollections of source neurons fulfilling the given criteria, one NodeCollection per target node ID in target.

Return type:

tuple of NodeCollection

See also

GetSourcePositions

Obtain positions of sources in a given source layer connected to given target.

GetConnections

Return connection identifiers between sources and targets.

Notes

  • For distributed simulations, this function only returns source on the local MPI process.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'mask': {'rectangular': {'lower_left': [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# get the node IDs of the targets of a source neuron
nest.GetSourceNodes(s_nodes, s_nodes[4])
nest.lib.hl_api_spatial.GetSourcePositions(src_layer, targets, syn_model=None)

Obtain positions of sources to a given NodeCollection of targets.

For each neuron in targets, this function finds all source elements in src_layer. If syn_model is not given (default), all targets are returned, otherwise only sources connected via the given synapse model.

Parameters:
  • src_layer (NodeCollection) – NodeCollection of src_layer

  • targets (NodeCollection) – NodeCollection with node ID(s) of target neurons

  • syn_type ([None | str], optional, default: None) – Return only source positions for a given synapse model.

Returns:

Positions of source neurons fulfilling the given criteria as a nested list, containing one list of positions per node in targets.

Return type:

list of list(s) of tuple(s) of floats

See also

GetSourceNodes

Obtain sources of a NodeCollection of targets in a given source

population.

Notes

  • For distributed simulations, this function only returns sources on the local MPI process.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'mask': {'rectangular': {'lower_left': [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# get the positions of the targets of a source neuron
nest.GetSourcePositions(s_nodes, s_nodes[5])
nest.lib.hl_api_spatial.GetTargetNodes(sources, tgt_layer, syn_model=None)

Obtain targets of sources in given target population.

For each neuron in sources, this function finds all target elements in tgt_layer. If syn_model is not given (default), all targets are returned, otherwise only targets connected via the given synapse model.

Parameters:
  • sources (NodeCollection) – NodeCollection with node IDs of sources

  • tgt_layer (NodeCollection) – NodeCollection with node IDs of tgt_layer

  • syn_model ([None | str], optional, default: None) – Return only target positions for a given synapse model.

Returns:

Tuple of NodeCollections of target neurons fulfilling the given criteria, one NodeCollection per source node ID in sources.

Return type:

tuple of NodeCollection

See also

GetTargetPositions

Obtain positions of targets in a given target layer connected to given source.

GetConnections

Return connection identifiers between sources and targets

Notes

  • For distributed simulations, this function only returns targets on the local MPI process.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'mask': {'rectangular': {'lower_left' : [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# get the node IDs of the targets of a source neuron
nest.GetTargetNodes(s_nodes[4], s_nodes)
nest.lib.hl_api_spatial.GetTargetPositions(sources, tgt_layer, syn_model=None)

Obtain positions of targets to a given NodeCollection of sources.

For each neuron in sources, this function finds all target elements in tgt_layer. If syn_model is not given (default), all targets are returned, otherwise only targets connected via the given syanpse model.

Parameters:
  • sources (NodeCollection) – NodeCollection with node ID(s) of source neurons

  • tgt_layer (NodeCollection) – NodeCollection of tgt_layer

  • syn_type ([None | str], optional, default: None) – Return only target positions for a given synapse model.

Returns:

Positions of target neurons fulfilling the given criteria as a nested list, containing one list of positions per node in sources.

Return type:

list of list(s) of tuple(s) of floats

See also

GetTargetNodes

Obtain targets of a NodeCollection of sources in a given target population.

Notes

  • For distributed simulations, this function only returns targets on the local MPI process.

Example

import nest

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'mask': {'rectangular': {'lower_left' : [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# get the positions of the targets of a source neuron
nest.GetTargetPositions(s_nodes[5], s_nodes)
nest.lib.hl_api_spatial.PlotLayer(layer, fig=None, nodecolor='b', nodesize=20)

Plot all nodes in a layer.

Parameters:
  • layer (NodeCollection) – NodeCollection of spatially distributed nodes

  • fig ([None | matplotlib.figure.Figure object], optional, default: None) – Matplotlib figure to plot to. If not given, a new figure is created.

  • nodecolor ([None | any matplotlib color], optional, default: 'b') – Color for nodes

  • nodesize (float, optional, default: 20) – Marker size for nodes

Return type:

matplotlib.figure.Figure object

See also

PlotProbabilityParameter

Create a plot of the connection probability and/or mask.

PlotTargets

Plot all targets of a given source.

matplotlib.figure.Figure

matplotlib Figure class

Notes

  • Do not use this function in distributed simulations.

Example

import nest
import matplotlib.pyplot as plt

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# plot layer with all its nodes
nest.PlotLayer(s_nodes)
plt.show()
nest.lib.hl_api_spatial.PlotProbabilityParameter(source, parameter=None, mask=None, edges=[-0.5, 0.5, -0.5, 0.5], shape=[100, 100], ax=None, prob_cmap='Greens', mask_color='yellow')

Create a plot of the connection probability and/or mask.

A probability plot is created based on a Parameter and a source. The Parameter should have a distance dependency. The source must be given as a NodeCollection with a single node ID. Optionally a mask can also be plotted.

Parameters:
  • source (NodeCollection) – Single node ID NodeCollection to use as source.

  • parameter (Parameter) – Parameter the probability is based on.

  • mask (Dictionary) – Optional specification of a connection mask. Connections will only be made to nodes inside the mask. See CreateMask() for options on how to specify the mask.

  • edges (list/tuple) – List of four edges of the region to plot. The values are given as [x_min, x_max, y_min, y_max].

  • shape (list/tuple) – Number of Parameter values to calculate in each direction.

  • ax (matplotlib.axes.AxesSubplot,) – A matplotlib axes instance to plot in. If none is given, a new one is created.

nest.lib.hl_api_spatial.PlotSources(src_layer, tgt_nrn, syn_type=None, fig=None, mask=None, probability_parameter=None, tgt_color='red', tgt_size=50, src_color='blue', src_size=20, mask_color='yellow', probability_cmap='Greens')

Plot all sources of target neuron tgt_nrn in a source layer src_layer.

Parameters:
  • src_layer (NodeCollection) – NodeCollection of src_layer

  • tgt_nrn (NodeCollection) – NodeCollection of target neuron (as single-element NodeCollection)

  • syn_type ([None | str], optional, default: None) – Show only targets connected with a given synapse type

  • fig ([None | matplotlib.figure.Figure object], optional, default: None) – Matplotlib figure to plot to. If not given, a new figure is created.

  • mask ([None | dict], optional, default: None) – Draw mask with targets; see PlotProbabilityParameter() for details.

  • probability_parameter ([None | Parameter], optional, default: None) – Draw connection probability with targets; see PlotProbabilityParameter() for details.

  • tgt_color ([None | any matplotlib color], optional, default: 'red') – Color used to mark target node position

  • tgt_size (float, optional, default: 50) – Size of target marker (see scatter for details)

  • src_color ([None | any matplotlib color], optional, default: 'blue') – Color used to mark source node positions

  • src_size (float, optional, default: 20) – Size of source markers (see scatter for details)

  • mask_color ([None | any matplotlib color], optional, default: 'red') – Color used for line marking mask

  • probability_cmap ([None | any matplotlib cmap color], optional, default: 'Greens') – Color used for lines marking probability parameter.

Return type:

matplotlib.figure.Figure object

See also

PlotTargets

Plot all targets of source neuron in a target layer.

GetSourceNodes

Obtain sources of a target in a given source layer.

GetSourcePositions

Obtain positions of sources of target in a given source layer.

probability_parameter

Add indication of connection probability and mask to axes.

PlotLayer

Plot all nodes in a spatially distributed population.

matplotlib.pyplot.scatter

matplotlib scatter plot.

Notes

  • Do not use this function in distributed simulations.

Example
import nest
import matplotlib.pyplot as plt

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'use_on_source': True,
            'mask': {'rectangular': {'lower_left': [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# plot the targets of a source neuron
nest.PlotSources(s_nodes, s_nodes[4])
plt.show()
nest.lib.hl_api_spatial.PlotTargets(src_nrn, tgt_layer, syn_type=None, fig=None, mask=None, probability_parameter=None, src_color='red', src_size=50, tgt_color='blue', tgt_size=20, mask_color='yellow', probability_cmap='Greens')

Plot all targets of source neuron src_nrn in a target layer tgt_layer.

Parameters:
  • src_nrn (NodeCollection) – NodeCollection of source neuron (as single-element NodeCollection)

  • tgt_layer (NodeCollection) – NodeCollection of tgt_layer

  • syn_type ([None | str], optional, default: None) – Show only targets connected with a given synapse type

  • fig ([None | matplotlib.figure.Figure object], optional, default: None) – Matplotlib figure to plot to. If not given, a new figure is created.

  • mask ([None | dict], optional, default: None) – Draw mask with targets; see PlotProbabilityParameter() for details.

  • probability_parameter ([None | Parameter], optional, default: None) – Draw connection probability with targets; see PlotProbabilityParameter() for details.

  • src_color ([None | any matplotlib color], optional, default: 'red') – Color used to mark source node position

  • src_size (float, optional, default: 50) – Size of source marker (see scatter for details)

  • tgt_color ([None | any matplotlib color], optional, default: 'blue') – Color used to mark target node positions

  • tgt_size (float, optional, default: 20) – Size of target markers (see scatter for details)

  • mask_color ([None | any matplotlib color], optional, default: 'red') – Color used for line marking mask

  • probability_cmap ([None | any matplotlib cmap color], optional, default: 'Greens') – Color used for lines marking probability parameter.

Return type:

matplotlib.figure.Figure object

See also

PlotSources

Plot all sources of target neuron in a source layer.

GetTargetNodes

Obtain targets of a sources in a given target layer.

GetTargetPositions

Obtain positions of targets of sources in a given target layer.

probability_parameter

Add indication of connection probability and mask to axes.

PlotLayer

Plot all nodes in a spatially distributed population.

matplotlib.pyplot.scatter

matplotlib scatter plot.

Notes

  • Do not use this function in distributed simulations.

Example
import nest
import matplotlib.pyplot as plt

# create a spatial population
s_nodes = nest.Create('iaf_psc_alpha', positions=nest.spatial.grid(shape=[11, 11], extent=[11., 11.]))

# connectivity specifications with a mask
conndict = {'rule': 'pairwise_bernoulli', 'p': 1.,
            'mask': {'rectangular': {'lower_left' : [-2.0, -1.0],
                                     'upper_right': [2.0, 1.0]}}}

# connect population s_nodes with itself according to the given
# specifications
nest.Connect(s_nodes, s_nodes, conndict)

# plot the targets of a source neuron
nest.PlotTargets(s_nodes[4], s_nodes)
plt.show()
nest.lib.hl_api_spatial.SelectNodesByMask(layer, anchor, mask_obj)

Obtain the node IDs inside a masked area of a spatially distributed population.

The function finds and returns all the node IDs inside a given mask of a layer. The node IDs are returned as a NodeCollection. The function works on both 2-dimensional and 3-dimensional masks and layers. All mask types are allowed, including combined masks.

Parameters:
  • layer (NodeCollection) – NodeCollection with node IDs of the layer to select nodes from.

  • anchor (tuple/list of double) – List containing center position of the layer. This is the point from where we start to search.

  • mask_obj (object) – Mask object specifying chosen area.

Returns:

NodeCollection of nodes/elements inside the mask.

Return type:

NodeCollection