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.

In my research, I found myself repeatedly needing to find a minimal circuit (connectivity-wise) that contains the smallest subcircuit containing all paths between a set of source and sink neurons (nodes, whatever). 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).

Written in Rust, exposed in Python.

Design

We support two main "modes", where the user passes in edge information as a list of tuples [(pre_1, post_1, pre_1, post_2, ...)] and as a np.ndarray of 2 dimensions. Under the hood, both use the same code, but there is a shim layer as rust doesn't have function overloads.

Functions

isolate_subcircuit(
    edge_list: list[tuple[int, int]]
    sources: set[int],
    sinks: set[int],
    max_depth: int,
    max_paths: int,
    nid_to_cidx_map: dict[int,int] | None
)
isolate_subcircuit_np(
    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_list: list[tuple[int, int]],
)
map_neuron_ids_to_cmat_idxs_np(
  edge_array: np.ndarray[u64, u64],
)


adjacency_map_from_edge_list(
  edge_list=list[tuple[int, int]],
  nid_to_cidx_map=dict[int, int] | None
)

adjacency_map_from_edge_list_np(
  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 whatever code using git add ...

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

Note: 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.3.3.tar.gz (42.9 kB 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.3.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

circuit_rs-0.3.3-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl (392.7 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ i686

circuit_rs-0.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

circuit_rs-0.3.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl (392.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ i686

circuit_rs-0.3.3-cp313-cp313-macosx_11_0_arm64.whl (317.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

circuit_rs-0.3.3-cp313-cp313-macosx_10_12_x86_64.whl (329.5 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

circuit_rs-0.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (364.1 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

circuit_rs-0.3.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl (392.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ i686

circuit_rs-0.3.3-cp312-cp312-macosx_11_0_arm64.whl (316.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

circuit_rs-0.3.3-cp312-cp312-macosx_10_12_x86_64.whl (329.2 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for circuit_rs-0.3.3.tar.gz
Algorithm Hash digest
SHA256 7848b98de13c9adadae925e4be820e8e5c120a91e41c1d50482cce027f75c262
MD5 8a517b1f33cb03cb41e18ae09b593c88
BLAKE2b-256 168485b0231d35b99752b2af33269603175a1452f623ab673520894414bda30e

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3.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.3.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f8ca377e18359151cf6b593fffa7fde5621ddb3feca5c61cba85b583a082086
MD5 fc69d40cec10ccf9cc20b04740a6ac3c
BLAKE2b-256 1a33e7d578c089469870acf4903d6a72d1188db4d1619e67aaec0572ed87e847

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp314-cp314-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c1aaf079c689a1ec0905f6b5754a36989dcba95503372e1f81b4f95b6b7b0e89
MD5 12cbae01e8b6b1a50f3852199af33adf
BLAKE2b-256 5d1cb613d443591edc748ddbf411864fa54e748f5cec91792fe7a186f9b9e71d

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8dd36e65ad42b5e272010d664044470686ecdbc2a6349895a1941edc14ccbbb5
MD5 6150e3ceaf120ebf6e6496380cc62c08
BLAKE2b-256 0d93086743c612f6121e2e7232b1d1fd3269b896c32c029610ace2dc387528e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp313-cp313-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 97b878a381539ecbc7e0abac24f395c00f0a369e7e4e672d80d80f808068fbf9
MD5 5d54d412b7088de9ec5d0fbbfb680720
BLAKE2b-256 687bedec630a0f1b9268697d02699a4f7ee579a76fbc781ad56ce1b5c0fd51fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dba6adbfec91605fc0e21bae7937abbc2e907b26c7b39ef40985e76255a235a1
MD5 b9b79fc2eb72cab37078d424f327ea66
BLAKE2b-256 d7f5bffef70b016b7e8961c6c08c1bd4dea52eace024cb5b9629ab46f08d0d83

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e59bb9f7b9d403960f3e561c727afef881638c961c2094a4457661754684634b
MD5 f78322fa77b3f8bff553cfe245b8a5f9
BLAKE2b-256 7e05246c3d8cee1bb8480c35a7370f7e82f65e98d9e4a8821b211b9624f0d7c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 71ac1916ea29635e7d406a4dbfe53f9455e5b529a405816fb08047d58d833551
MD5 4812938aa3c52108466686dbb883b10c
BLAKE2b-256 30f2e2be4786ace36deb1a95469e21349bcdc99d919f6dc08898bba0a9a0a661

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 cfd570af1e7ca7e386ad1309f83ff15bc7dcefa7ad16e3181461326ac62f1e2a
MD5 542c123af4f99dc2894263c828a8d347
BLAKE2b-256 37e641b7c3d0c7bac69097154be9257a82a601d6c3f116f44fd55bc2e3ee577d

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c2887bece56e857db57bc49245b0e39af6a06ca2a5965e7983e8ebf488437ba6
MD5 56fd88ab0fd3e928d73e2e573b490aba
BLAKE2b-256 170437af31e19b707078bab06d8763d15424e2b2afb09dea9e3135aa5bea7a9a

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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.3.3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for circuit_rs-0.3.3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f98fa6acf3654fdfb512b8b6b7b91fe6f117b4f0e96831a7a57a928590bae94d
MD5 22756116e30ea55984e3984998bdfc28
BLAKE2b-256 247324c81ab42db15dbf1906157cf61fd768543bb2e0bc0b924d633070aae38c

See more details on using hashes here.

Provenance

The following attestation bundles were made for circuit_rs-0.3.3-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