Skip to main content

Connection-Set Algebra (CSA)

This is a demonstration implementation in Python of the Connection-Set Algebra (Djurfeldt, Mikael (2012), Neuroinformatics)

Code status

Build Status Coverage Status

Purpose

The CSA library provides elementary connection-sets and operators for combining them. It also provides an iteration interface to such connection-sets enabling efficient iteration over existing connections with a small memory footprint also for very large networks. The CSA can be used as a component of neuronal network simulators or other tools.

See the following reference for more information:

Mikael Djurfeldt (2012) "The Connection-set Algebra---A Novel Formalism for the Representation of Connectivity Structure in Neuronal Network Models" Neuroinformatics 10(3), 1539-2791, http://dx.doi.org/10.1007/s12021-012-9146-1

License

CSA is released under the GNU General Public License

Requirements

CSA is dependent on Numpy and Matplotlib

Introduction

A connection set is a set of existing connections between a set of source nodes and a set of target nodes. Typically, source and target nodes are neurons in a neuronal network, but targets could also be particular structures of a neuron, such synaptic sites. Sources and targets are enumerated by integers and a connection is represented by a pair of integers, one denoting the source node and one the target node. Source and target can be (and is often) the same set.

CSA connection sets are usually infinite. This is a simplification compared to the common situation of finite source and target sets in that the sizes of these sets do not need to be considered. Connection sets can have arbitrary values associated with connections. Pure connection sets without any values associated are called masks.

Getting started

Basics

To get access to the CSA in Python, type: ::

from csa import *

The mask representing all possible connections between an infinite source and target set is: ::

full

To display a finite portion of the corresponding connectivity matrix, type: ::

show (full)

One-to-one connectivity (where source node 0 is connected to target node 0, source 1 to target 1 etc) is represented by the mask oneToOne: ::

show (oneToOne)

The default portion displayed by "show" is (0, 29) x (0, 29). (0, 99) x (0, 99) can be displayed using: ::

show (oneToOne, 100, 100)

If source and target set is the same, oneToOne describes self-connections. We can use CSA to compute the set of connections consisting of all possible connections except for self-connections using the set difference operator "-": ::

show (full - oneToOne)

Finite connection sets can be represented using either lists of connections, with connections represented as tuples: ::

show ([(22, 7), (8, 23)])

or using the Cartesian product of intervals: ::

show (cross (range (10), range (20)))

We can form a finite version of the infinite oneToOne by taking the intersection "*" with a finite connection set: ::

  c = cross (range (10), range (10)) * oneToOne
  show (c)

Finite connection sets can be tabulated: ::

tabulate (c)

In Python, finite connection sets provide an iterator interface: ::

for x in cross (range (10), range (10)) * oneToOne:
    print x

Random connectivity and the block operator

Connectivity where the existence of each possible connection is determined by a Bernoulli trial with probability p is expressed with the random mask random (p), e.g.: ::

show (random (0.5))

The block operator expands each connection in the operand into a rectangular block in the resulting connection matrix, e.g.: ::

show (block (5,3) * random (0.5))

Note that "*" here means operator application. There is also a quadratic version of the operator: ::

show (block (10) * random (0.7))

Using intersection and set difference, we can now formulate a more complex mask: ::

show (block (10) * random (0.7) * random (0.5) - oneToOne)

Geometry

In CSA, the basic tool to handle distance dependent connectivity is metrics. Metrics are value sets d (i, j). Metrics can be defined through geometry functions. A geometry function maps an index to a position. We can, for example, assign a random position in the unit square to each index: ::

g = random2d (900)

The positions of the grid described by g have indices from 0 to 899 and can be displayed like this: ::

gplot2d (g, 900)

Alternatively, we can arrange indices in a 30 x 30 grid within the unit square: ::

g = grid2d (30)

We can now define the euclidean metric on this grid: ::

d = euclidMetric2d (g)

An example of a distance dependent connection set is the disc mask Disc (r) * d which connects each index i to all indices j within a distance d (i, j) < r: ::

c = disc (r) * d

To examine the result we can employ the function gplotsel2d (g, c, i) which displays the targets g (j) of i in the connection set c: ::

gplotsel2d (g, c, 434)

In the case where the connection set represents a projection between two different coordinate systems, we define one geometry function for each. In the following example g1 is direction in visual space in arc minutes while g2 is position in the cortical representation of the Macaque fovea in mm: ::

g1 = grid2d (30)
g2 = grid2d (30, x0 = -7.0, xScale = 8.0, yScale = 8.0)

We now define a projection operator which takes visual coordinates into cortical (Dow et al. 1985): ::

import cmath

@ProjectionOperator
def GvspaceToCx (p):
    w = 7.7 * cmath.log (complex (p[0] + 0.33, p[1]))
    return (w.real, w.imag)

To see how the grid g1 is transformed into cortical space, we type: ::

gplot2d (GvspaceToCx * g1, 900)

The inverse projection is defined: ::

@ProjectionOperator
def GcxToVspace (p):
    c = cmath.exp (complex (p[0], p[1]) / 7.7) - 0.33
    return (c.real, c.imag)

Real receptive field sizes vary with eccentricity. Assume, for now, that we want to connect each target index to sources within a disc of constant radius. We then need to project back into visual space and use the disc operator: ::

c = disc (0.1) * euclidMetric2d (g1, GcxToVspace * g2)

Again, we use gplotsel2d to check the result: ::

gplotsel2d (g2, c, 282)

Metadata

Release files for csa 0.1.13

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csa 0.1.13
File Size Uploaded Provenance Actions
csa-0.1.13.tar.gz 39.8 kB Without provenance Details for csa-0.1.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for csa 0.1.13
File Interpreter ABI Platform Actions
csa-0.1.13-py3-none-any.whl Python 3 none any Details for csa-0.1.13-py3-none-any.whl

Total release size: 83.3 kB

Release files / csa-0.1.13.tar.gz

Download URL csa-0.1.13.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ab194303bdb940366f45aad55346d50b2fc3c42c23d6c785f80dea5f5d97d32f
BLAKE2b-256 checksum
How to use checksums
f2e717a650e1e427fe2bf79c45eb8bdd00bb3d8ffbb6346a81f58cf62a24d821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / csa-0.1.13-py3-none-any.whl

Download URL csa-0.1.13-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db78e251409165095bac7e4ab2a4a20a91e027b010db81d7f657a3fc9c3c287a
BLAKE2b-256 checksum
How to use checksums
828b6796178f302cb2c07cfd66cfdd71162f0bbce01d5680314ad656fc065f5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Security for csa 0.1.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page