Skip to main content

A fast, chunked, memory-bounded Rust engine for electrophysiology (Neuropixels) signal processing, with Python bindings.

Project description

Segovia — a fast, memory-bounded Rust engine for electrophysiology signal processing, Neuropixels-scale, callable from Python

CI crates.io PyPI docs.rs License: AGPL-3.0-or-later Status: pre-release PRs welcome

A fast, chunked, memory-bounded Rust engine for electrophysiology signal processing — Neuropixels-scale, callable from Python.

Segovia is a lazy-evaluated, chunked, concurrent compute engine for massive multi-channel electrophysiology time-series (Neuropixels-scale: 30 kHz × thousands of channels). It is written in Rust, exposed to Python via PyO3, and built to slot into the existing neuroscience stack — SpikeInterface, SpikeGLX, Zarr, and NWB — rather than replace it. The aim is out-of-core, bounded-memory streaming preprocessing (bandpass filtering, common-median referencing, whitening) with GIL-released shared-memory threads instead of the process-pool / pickle / per-process-copy model that makes Python spike-sorting pipelines run out of memory.

Status

Early development — pre-MVP. This repository is currently architecture docs plus a project scaffold; the compute engine is not built yet and nothing is published to crates.io or PyPI. The install and quickstart below describe the target API, not a shipped one. Follow the roadmap for progress. The whole premise rests on one make-or-break benchmark — see The benchmark gate.

Contents

Why Segovia

A neuroscience lab can record a brain faster than its software can read it back. A single high-density Neuropixels probe writes roughly 80 GB/hour (~22 MB/s); standard Python pipelines load that at double size and then copy it wholesale into every worker process. Documented failures include a 26 GiB memory error filtering a modest recording and a 102 GiB blow-up during motion correction. The data is fine — the plumbing leaks.

Segovia targets that plumbing. It is CPU-first (the workload is IO/memory-bound, so a GPU would spend more time waiting on the PCIe bus than computing), reuses mature Rust storage crates (zarrs, hdf5-metno, arrow-rs) instead of reinventing them, and earns its keep through one concrete advantage: true shared-memory threading in Rust with the GIL released. This is out-of-core spike-sorting preprocessing — bounded memory regardless of recording length, real-time capable, and callable from the Python tools researchers already use.

How it works

flowchart LR
    A["Storage<br/>SpikeGLX .bin · Zarr · NWB/HDF5"] --> B["Chunked source<br/>channels × samples tiles"]
    B --> C["Op chain<br/>bandpass → CMR → whiten → detect"]
    C --> D["Sink<br/>zero-copy NumPy / Arrow"]
    C -. "Rayon over chunks, GIL released" .-> C
    style A fill:#0B1020,stroke:#5A6B8C,color:#F5F7FA
    style B fill:#0B1020,stroke:#5A6B8C,color:#F5F7FA
    style C fill:#0B1020,stroke:#CE422B,color:#F5F7FA
    style D fill:#0B1020,stroke:#DEA584,color:#F5F7FA

Data is read in chunks (spans of channels × samples), streamed through an operation chain, and returned to Python zero-copy. Only a bounded window is ever resident in memory — the metaphor is the Aqueduct of Segovia, a continuous stream carried span-by-span across a row of stone arches.

Install

Not yet published — this is the planned install once the first release ships.

pip install segovia
cargo add segovia

Quickstart

Target API (illustrative, not yet shipped). Read a SpikeGLX recording, run the bandpass → common-median-reference → whiten chain in bounded memory, and get a zero-copy NumPy result.

import segovia

recording = segovia.read_spikeglx("data/probe0.imec0.ap.bin")

filtered = (
    recording
    .bandpass(low=300, high=6000)
    .common_median_reference()
    .whiten()
)

chunk = filtered.to_numpy(start=0, end=30_000)

The benchmark gate

Segovia's existence hinges on one measurable claim (call it SC1): on a real 1-hour Neuropixels recording, the Rust bandpass + CMR + whiten chain must run in under 2 GB of peak memory and be faster than the equivalent spikeinterface(n_jobs=N) call on Windows and macOS. If that cannot be shown, the premise is wrong and the project says so. This benchmark is built first, not last. Result: pending — see the roadmap.

Architecture

The full architecture document set lives in docs/architecture/:

Roadmap

ROADMAP.md is the single source of truth for version and scope. In short: learn the domain and de-risk the toolchain (M0–2), prove the benchmark win (M2–4, the go/no-go gate), grow into a real engine with a Python API (M4–7), add breadth and correctness (M7–10), and ship as a SpikeInterface preprocessing backend (M10–12). A deferred, gated single-cell vertical sits beyond that — see docs/future/leukemia-direction.md.

Why the name

Segovia is named for Claudio Segovia, a friend who died of leukemia at 26. The name also evokes the Aqueduct of Segovia — a continuous stream carried across a long row of segmented stone arches, which is exactly this engine's chunked, span-by-span streaming model.

The connection is honest, not a marketing claim. An electrophysiology engine does not cure cancer, and saying otherwise would be dishonest. But the underlying computational problem — data too large for memory, and a Python layer that copies it until it chokes — is shared with single-cell genomics, the computational backbone of modern leukemia research (clonal evolution, drug resistance, CAR-T). Segovia's core is kept domain-neutral so the same machinery could one day help with that work too: aided by the tool, not a tool made for it. That direction is deliberately deferred and gated — the honest details, including disconfirming evidence, are in docs/future/leukemia-direction.md.

Contributing

Contributions are welcome — see CONTRIBUTING.md. The project is Windows-first, uses a Rust + PyO3 + maturin toolchain, conventional commits, and STAR-format PRs.

Citation

If you use Segovia in your research, please cite it via CITATION.cff (GitHub shows a "Cite this repository" button). A DOI will be added on the first archived release.

License

Segovia is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).

This is deliberate: Segovia is free for everyone — researchers, individuals, and non-profits — and the copyleft terms keep it that way. Anyone who distributes Segovia, or runs a modified version as a network service, must release their complete corresponding source under the same license, so the project cannot be taken closed-source or proprietary.

Unless you explicitly state otherwise, any contribution you submit for inclusion is licensed under AGPL-3.0-or-later, without any additional terms or conditions.

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

segovia-0.1.0.tar.gz (196.8 kB view details)

Uploaded Source

Built Distributions

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

segovia-0.1.0-cp38-abi3-win_amd64.whl (190.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

segovia-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (335.6 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

segovia-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (293.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file segovia-0.1.0.tar.gz.

File metadata

  • Download URL: segovia-0.1.0.tar.gz
  • Upload date:
  • Size: 196.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for segovia-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6a6c5290a44043c7faf7222e69461ca9e11d2d5ad83d8171a709458ec9c383d5
MD5 8bfe566f83f825c05be63a927a5439ff
BLAKE2b-256 7d4972a4ebccbf5ee304264f2c584566051d0db55ad9f0970b2a06fb89552af3

See more details on using hashes here.

Provenance

The following attestation bundles were made for segovia-0.1.0.tar.gz:

Publisher: release.yml on fcarvajalbrown/Segovia

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

File details

Details for the file segovia-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

  • Download URL: segovia-0.1.0-cp38-abi3-win_amd64.whl
  • Upload date:
  • Size: 190.1 kB
  • Tags: CPython 3.8+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for segovia-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 baf361513417d8ceeafc283c5fa15a83879fa89939c972462e19a9eb4a3940fb
MD5 8da7979636e17648c22f116864d0e7de
BLAKE2b-256 4563c7cdc968ed79cb819141079426424760f0b41334040966c9abbe86c652d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for segovia-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: release.yml on fcarvajalbrown/Segovia

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

File details

Details for the file segovia-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for segovia-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a0bb8175d5f024b1ca8708d91a639dad33191a5d054081bf03497565ad7368f
MD5 e49ed579497cd6141a26e0a33b0d432e
BLAKE2b-256 150ad34fe7a1cd97f645f9c715de804261d07d26d7078e26ee11f3532a3b6759

See more details on using hashes here.

Provenance

The following attestation bundles were made for segovia-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on fcarvajalbrown/Segovia

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

File details

Details for the file segovia-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for segovia-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 abb8ded3c8992cc729e31b4c1ae81cc3648d70174e61f9c5779fe55e037e0337
MD5 cab3b07bf4897ad67a2d90bf5383ebce
BLAKE2b-256 29cfe537360ee91fb7e34db6ab389864a6d4daa2085aadb287d2a254c772bf6b

See more details on using hashes here.

Provenance

The following attestation bundles were made for segovia-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on fcarvajalbrown/Segovia

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