Skip to main content

A library for doing efficient operations on neural circuits

Project description

rusted_circuits

Exposing useful operations to manipulate the neural circuits that can be derived from Flywire, a project which maps out the Drosophila brain.

Context

In my research, I found myself repeatedly needing to find a minimal circuit (connectivity-wise) from a given set of source and sink nodes. Specifically, I needed to identify the smallest subcircuit containing all nodes on all simple paths between a set of (source, sink) nodes. The python code I used was too slow, even considering various biological priors (e.g. I think it's possible to traverse from most neurons to almost any other within 5 jumps, and if you can't then it's probably not possible), and existing solutions such as networkx-all_simple_paths, and rustworkx-all_simple_paths only consider single source-sink pairs at a time, so I'd need rerun the algorithm #Source * #Sink times, but by writing my own script, I only needed to run it #Source times. Also, those libraries return lists-of-lists, which can cause lots of memory to build up and since I only care about the nodes and not the actual path, I figure I can avoid that expense.

Design

We accept numpy arrays of 2D where column 1 is the pre-synaptic and column 2 is the post-synaptic.

Functions

isolate_subcircuit(
    edge_array: np.ndarray[u64, u64]
    sources: set[int],
    sinks: set[int],
    max_depth: int,
    max_paths: int,
    nid_to_cidx_map: dict[int,int] | None
  
)
  
map_neuron_ids_to_cmat_idxs(
  edge_array: np.ndarray[u64, u64],
)

adjacency_map_from_edge_list(
  edge_array=np.ndarray[u64, u64],
  nid_to_cidx_map=dict[int, int] | None
)

Example

Smallest Subcircuit

Here is a simple working example, where we have a linear path from source (1) to sink (5)

edge_list = np.asarray([(1, 2), (2, 3), (3, 4), (4, 5)])
sources = {1}
sinks = {5}
max_depth = 10
max_paths = 100

# The nid_to_cidx_map is optional, and if it is not specified, we derive the mapping of the neuron-id-to-connectivity-matrix-index.
nid_to_cidx_map = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50}

# Expected: all nodes on the path from source to sink
expected = {10, 20, 30, 40, 50}
actual_np = isolate_subcircuit_np_edgelist(edge_list, sources, sinks, max_depth, max_paths, nid_to_cidx_map)

# -OR-, from a list
actual_list = isolate_subcircuit(edge_list.tolist(), sources, sinks, max_depth, max_paths, nid_to_cidx_map)

Maintainers

  1. Add code/documentation changes via git add ...

  2. Attach a commit message e.g. git commit -m '...'

Note: in step 3, replace VERSION_NUMBER below by an actual version number e.g. v0.1.0

  1. git tag $VERSION_NUMBER

  2. Modify Cargo.toml, the version to be the same (not strictly necessary, but it's just nicer).

  3. git push origin $VERSION_NUMBER

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

circuit_rs-0.4.0.tar.gz (50.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (358.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl (387.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ i686

circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (358.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (388.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

circuit_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl (313.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

circuit_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl (324.3 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (358.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (389.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

circuit_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl (313.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

circuit_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl (324.1 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file circuit_rs-0.4.0.tar.gz.

File metadata

  • Download URL: circuit_rs-0.4.0.tar.gz
  • Upload date:
  • Size: 50.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for circuit_rs-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a0bdf9f8b452d6e8baa298b00c3a88126a32823fbc75e6514546adcc0c225195
MD5 8f3866f6376517e44935f7689d1fc7bd
BLAKE2b-256 1b7341caa5af9d67b237a08a86555587c8a3f640c93623fe978b762523c8ab0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0.tar.gz:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c7d7987acf835b3afd752788dd11c73d9739a77e01ffc67bc66746ad0f63aee
MD5 665e0ab85b5ada343f4ebbce52fb14c0
BLAKE2b-256 20984515724d3d8a0b7e55c7c62238cb7adb1e65cce16a8d1b61a87bba6d77d6

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 6f056abd1efad9445c5bfdb785c7d82380931fe148aaae73044f9f46c6953b70
MD5 454ac5106775b9ae80f5ae96583a8d44
BLAKE2b-256 e92bdb0b9ad699a2f08dc99b00b5577e20e240e718c8ecc3036d70b508c13809

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4730c07fd80f2b8100b5c92e5c4e5fb56b28a58518eb8961aafbd76143115ad4
MD5 e9c8f03f0cc81bbbbc466295106e3ff3
BLAKE2b-256 b5b6da9b8b7d1f6109bda247bb2c672b5012a317259b264d7a9ca1cd46c5d37d

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7359ea441ecfd85eafaa0b7f9d0e58e8ca9bf748d14df90463cf0004407ccd3e
MD5 b8d2efeb2cf893e834595ac2427f28a4
BLAKE2b-256 ec37112bf30ec1333b7fe9847f6cb7ee2907574f5ccacf168a091a313b37b5a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a8f416c1df0886ed345c6cf1b9b1ec8c45452b744ce07c922531d1a4ee332587
MD5 544940840398a8b7e2c5690e99a38b11
BLAKE2b-256 f036c43f204aec7bbde8e4963ddbb16048fe2ea262bc5228d16e75902380c729

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 bc68d70f5ccb1457f460157658c01386429a01307446bc0273a462df474a9e39
MD5 db1d8882c09a590591adb133afb91e32
BLAKE2b-256 57a0bf609662bd740fa7b080fc0538354526f2f3c329a429e7dcfd4fa7a83351

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92d2dde77de7b1dc8224fd7e34cba06e39fc856b05599f019f36018d9b345d35
MD5 e80231fcef2e69276349e15ee52c2c90
BLAKE2b-256 b92d05de8f5f751c4bd3293226dd40a9a8e5d0f7a5a3d9cd27f603902aa76f47

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7a321a6b7a76c964512dcb50798d1f85c187f72ae86f59a59a23ebbaa5cfb051
MD5 5ff4183e1817606633b9d2fec5611ed7
BLAKE2b-256 0173d07c309d7ebf301b42f48943e868621dc1ad7362a296262bb01796942a23

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bb7ed68511dd447fbdd1d762884ee68c9c6229746768a3f619b5d3b10d5bf8ee
MD5 0f5207ddf7a73af784eb71b3f5ac86cc
BLAKE2b-256 a7663427d1566542b36e154d4eebb25ef12aca47c076cd0443689afeeb9dfc02

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file circuit_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ab5b034fb1a2e905639398fb5cfa75da9ae6a5f9508158d220a5ee2aab5ab761
MD5 866ddf582203e4314df3c7ee1fce0862
BLAKE2b-256 1feb00c7daf5798e3944db1843e232f37081b717611c1b504807a1c9fd0f0be3

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl:

Publisher: CI.yml on oahmedlab/circuit-rs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page