Projection

Projection#

class braintools.conn.Projection(pre, post, connectivity, *, name=None)#

A connectivity generator bound to a presynaptic and a postsynaptic population.

Parameters:
  • pre (Population) – Source population.

  • post (Population) – Target population (may be pre itself for recurrent connections).

  • connectivity (Connectivity) – Generator called with the populations’ sizes and positions.

  • name (str | None) – Projection name; defaults to f"{pre.name}->{post.name}".

Raises:
  • TypeError – If pre/post are not Population or connectivity is not a Connectivity.

  • ValueError – If connectivity was constructed with a pre_size/post_size whose neuron count differs from the population’s, or name is empty.

See also

Population, Network

Notes

Generators cache their result per (sizes, positions). Sharing one generator instance between two projections with the same sizes therefore gives both the same edges; use one instance per projection for independent draws.

A generator’s allow_self_connections=False (the default of FixedProb) removes the pairs (i, i) when the two sides have the same size. Those pairs are autapses only when pre and post are the same population, so for a projection between two different populations the generator is built from a copy with self-connections allowed (sharing its random state); the passed generator is not modified.

Examples

>>> from braintools.conn import Population, Projection, FixedInDegree
>>> E = Population(80, name='E')
>>> I = Population(20, name='I')
>>> proj = Projection(E, I, FixedInDegree(8, seed=0))
>>> proj.name
'E->I'
>>> proj.build().shape
(80, 20)
build(recompute=False)[source]#

Generate the projection’s connections.

Parameters:

recompute (bool) – Redraw even if the generator has a cached result.

Returns:

Local indices (0 .. pre.num - 1 and 0 .. post.num - 1).

Return type:

ConnectionResult