select_nodes_by_mask

select_nodes_by_mask#

class brainpy.state.spatial.select_nodes_by_mask(layer, anchor, mask)[source]#

Local indices of the nodes lying inside mask anchored at anchor (NEST SelectNodesByMask).

The mask is evaluated with anchor as the (single) source node and every layer node as a candidate target, so directional masks (box / rectangular / rotated ellipses) respect the target - anchor displacement.

Parameters:
  • layer (Layer) – A concrete position layer.

  • anchor (sequence or Quantity) – The reference point (ndim,) the mask is centred on. Bare floats are micrometres.

  • mask (object) – Any spatial mask exposing contains(pre_pos, post_pos) -> bool (n_pre, n_post).

Returns:

The population-local indices (ascending) of the selected nodes.

Return type:

numpy.ndarray

Examples

>>> from brainpy import state as bp
>>> layer = bp.spatial.grid([3, 3], extent=[2.0, 2.0])
>>> bp.spatial.select_nodes_by_mask(layer, [0.0, 0.0], bp.spatial.circular(0.7)).tolist()
[1, 3, 4, 5, 7]