brainpy.connect package

formatter functions

ij2mat(i, j[, num_pre, num_post])

Convert i-j connection to matrix connection.

mat2ij(conn_mat)

Get the i-j connections from connectivity matrix.

pre2post(i, j[, num_pre])

Get pre2post connections from i and j indexes.

post2pre(i, j[, num_post])

Get post2pre connections from i and j indexes.

pre2syn(i[, num_pre])

Get pre2syn connections from i and j indexes.

post2syn(j[, num_post])

Get post2syn connections from i and j indexes.

pre_slice_syn(i, j[, num_pre])

Get post slicing connections by pre-synaptic ids.

post_slice_syn(i, j[, num_post])

Get pre slicing connections by post-synaptic ids.

connector methods

Connector()

Abstract connector class.

One2One()

Connect two neuron groups one by one.

All2All([include_self])

Connect each neuron in first group to all neurons in the post-synaptic neuron groups.

GridFour([include_self])

The nearest four neighbors conn method.

GridEight([include_self])

The nearest eight neighbors conn method.

GridN([n, include_self])

The nearest (2*N+1) * (2*N+1) neighbors conn method.

FixedPostNum(num[, include_self, seed])

Connect the post-synaptic neurons with fixed number for each pre-synaptic neuron.

FixedPreNum(num[, include_self, seed])

Connect the pre-synaptic neurons with fixed number for each post-synaptic neuron.

FixedProb(prob[, include_self, seed])

Connect the post-synaptic neurons with fixed probability.

GaussianProb(sigma[, p_min, normalize, …])

Builds a Gaussian conn pattern between the two populations, where the conn probability decay according to the gaussian function.

GaussianWeight(sigma, w_max[, w_min, …])

Builds a Gaussian conn pattern between the two populations, where the weights decay with gaussian function.

DOG(sigmas, ws_max[, w_min, normalize, …])

Builds a Difference-Of-Gaussian (dog) conn pattern between the two populations.

SmallWorld()

ScaleFree()

class brainpy.connectivity.Connector[source]

Abstract connector class.

class brainpy.connectivity.One2One[source]

Connect two neuron groups one by one. This means The two neuron groups should have the same size.

class brainpy.connectivity.All2All(include_self=True)[source]

Connect each neuron in first group to all neurons in the post-synaptic neuron groups. It means this kind of conn will create (num_pre x num_post) synapses.

class brainpy.connectivity.GridFour(include_self=False)[source]

The nearest four neighbors conn method.

class brainpy.connectivity.GridEight(include_self=False)[source]

The nearest eight neighbors conn method.

class brainpy.connectivity.GridN(n=1, include_self=False)[source]

The nearest (2*N+1) * (2*N+1) neighbors conn method.

Parameters
  • N (int) –

    Extend of the conn scope. For example: When N=1,

    [x x x] [x I x] [x x x]

    When N=2,

    [x x x x x] [x x x x x] [x x I x x] [x x x x x] [x x x x x]

  • include_self (bool) – Whether create (i, i) conn ?

class brainpy.connectivity.FixedPostNum(num, include_self=True, seed=None)[source]

Connect the post-synaptic neurons with fixed number for each pre-synaptic neuron.

Parameters
  • num (float, int) – The conn probability (if “num” is float) or the fixed number of connectivity (if “num” is int).

  • include_self (bool) – Whether create (i, i) conn ?

  • seed (None, int) – Seed the random generator.

class brainpy.connectivity.FixedPreNum(num, include_self=True, seed=None)[source]

Connect the pre-synaptic neurons with fixed number for each post-synaptic neuron.

Parameters
  • num (float, int) – The conn probability (if “num” is float) or the fixed number of connectivity (if “num” is int).

  • include_self (bool) – Whether create (i, i) conn ?

  • seed (None, int) – Seed the random generator.

class brainpy.connectivity.FixedProb(prob, include_self=True, seed=None)[source]

Connect the post-synaptic neurons with fixed probability.

Parameters
  • prob (float) – The conn probability.

  • include_self (bool) – Whether create (i, i) conn ?

  • seed (None, int) – Seed the random generator.

class brainpy.connectivity.GaussianProb(sigma, p_min=0.0, normalize=True, include_self=True, seed=None)[source]

Builds a Gaussian conn pattern between the two populations, where the conn probability decay according to the gaussian function.

Specifically,

\[p=\exp(-\frac{(x-x_c)^2+(y-y_c)^2}{2\sigma^2})\]

where \((x, y)\) is the position of the pre-synaptic neuron and \((x_c,y_c)\) is the position of the post-synaptic neuron.

Parameters
  • sigma (float) – Width of the Gaussian function.

  • normalize (bool) – Whether normalize the coordination.

  • include_self (bool) – Whether create the conn at the same position.

  • seed (bool) – The random seed.

class brainpy.connectivity.GaussianWeight(sigma, w_max, w_min=None, normalize=True, include_self=True)[source]

Builds a Gaussian conn pattern between the two populations, where the weights decay with gaussian function.

Specifically,

\[w(x, y) = w_{max} \cdot \exp(-\frac{(x-x_c)^2+(y-y_c)^2}{2\sigma^2})\]

where \((x, y)\) is the position of the pre-synaptic neuron (normalized to [0,1]) and \((x_c,y_c)\) is the position of the post-synaptic neuron (normalized to [0,1]), \(w_{max}\) is the maximum weight. In order to void creating useless synapses, \(w_{min}\) can be set to restrict the creation of synapses to the cases where the value of the weight would be superior to \(w_{min}\). Default is \(0.01 w_{max}\).

Parameters
  • sigma (float) – Width of the Gaussian function.

  • w_max (float) – The weight amplitude of the Gaussian function.

  • w_min (float, None) – The minimum weight value below which synapses are not created (default: 0.01 * w_max).

  • normalize (bool) – Whether normalize the coordination.

  • include_self (bool) – Whether create the conn at the same position.

class brainpy.connectivity.DOG(sigmas, ws_max, w_min=None, normalize=True, include_self=True)[source]

Builds a Difference-Of-Gaussian (dog) conn pattern between the two populations.

Mathematically,

\[w(x, y) = w_{max}^+ \cdot \exp(-\frac{(x-x_c)^2+(y-y_c)^2}{2\sigma_+^2}) - w_{max}^- \cdot \exp(-\frac{(x-x_c)^2+(y-y_c)^2}{2\sigma_-^2})\]

where weights smaller than \(0.01 * abs(w_{max} - w_{min})\) are not created and self-connections are avoided by default (parameter allow_self_connections).

Parameters
  • sigmas (tuple) – Widths of the positive and negative Gaussian functions.

  • ws_max (tuple) – The weight amplitudes of the positive and negative Gaussian functions.

  • w_min (float, None) – The minimum weight value below which synapses are not created (default: \(0.01 * w_{max}^+ - w_{min}^-\)).

  • normalize (bool) – Whether normalize the coordination.

  • include_self (bool) – Whether create the conn at the same position.

class brainpy.connectivity.SmallWorld[source]
class brainpy.connectivity.ScaleFree[source]