Skip to content
Snippets Groups Projects
Unverified Commit 689eea33 authored by Simon Frasch's avatar Simon Frasch Committed by GitHub
Browse files

Feature: High-level network specification (#2050)


Implement a high-level network specification as proposed in
#418. It does not include support for gap junctions to allow the use of
domain decomposition for some distributed network generation.
The general idea is a DSL based on set algebra, which operates on the
set of all possible connections, by selecting based on different
criteria, such as the distance between cells or lists of labels. By
operating on all possible connections, a separate definition of cell
populations becomes unnecessary. An example for selecting all inter-cell
connections with a certain source and destination label is:
`(intersect (inter-cell) (source-label \"detector\") (destination-label
\"syn\"))`

For parameters such as weight and delay, a value can be defined in the
DSL in a similar way with the usual mathematical operations available.
An example would be:
`(max 0.1 (exp (mul -0.5 (distance))))`

The position of each connection site is calculated by resolving the
local position on the cell and applying an isometry, which is provided
by a new optional function of the recipe. In contrast to the usage of
policies to select a member within a locset, each site is treated
individually and can be distinguished by its position.

Internally, some steps have been implemented in an attempt to reduce the
overhead of generating connections:
- Pre-select source and destination sites based on the selection to
reduce the sampling space when possible
- If selection is limited to a maximum distance, use an octree for
efficient spatial sampling
- When using MPI, only instantiate local cells and exchange source sites
in a ring communication pattern to overlap communication and sampling.
In addition, this reduces memory usage, since only the current and next
source sites have to be stored in memory during the exchange process.

Custom selection and value functions can still be provided by storing
the wrapped function in a dictionary with an associated label, which can
then be used in the DSL.

Some challenges remain. In particular, how to handle combined explicit
connections returned by `connections_on` and the new way to describe a
network. Also, the use of non-blocking MPI is not easily integrated into
the current context types, and the dry-run context is not supported so
far.


# Example
A (trimmed) example in Python, where a ring connection combined with
random connections based on the distance:
```py
class recipe(arbor.recipe):
    def cell_isometry(self, gid):
        # place cells with equal distance on a circle
        radius = 500.0 # μm
        angle = 2.0 * math.pi * gid / self.ncells
        return arbor.isometry.translate(radius * math.cos(angle), radius * math.sin(angle), 0)

    def network_description(self):
        seed = 42

        # create a chain
        ring = f"(chain (gid-range 0 {self.ncells}))"
        # connect front and back of chain to form ring
        ring = f"(join {ring} (intersect (source-cell {self.ncells - 1}) (destination-cell 0)))"

        # Create random connections with probability inversely proportional to the distance within a
        # radius
        max_dist = 400.0 # μm
        probability = f"(div (sub {max_dist} (distance)) {max_dist})"
        rand = f"(intersect (random {seed} {probability}) (distance-lt {max_dist}))"

        # combine ring with random selection
        s = f"(join {ring} {rand})"
        # restrict to inter-cell connections and certain source / destination labels
        s = f"(intersect {s} (inter-cell) (source-label \"detector\") (destination-label \"syn\"))"

        # normal distributed weight with mean 0.02 μS, standard deviation 0.01 μS
        # and truncated to [0.005, 0.035]
        w = f"(truncated-normal-distribution {seed} 0.02 0.01 0.005 0.035)"
        # fixed delay
        d = "(scalar 5.0)"  # ms delay

        return arbor.network_description(s, w, d, {})
```
Co-authored-by: default avatarThorsten Hater <24411438+thorstenhater@users.noreply.github.com>
parent 9f20e838
No related branches found
No related tags found
No related merge requests found
Showing
with 2697 additions and 38 deletions
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment