Skip to content

Complete cell examples, synapse communication, and network runtime APIs#105

Merged
chaoming0625 merged 39 commits into
mainfrom
integration_order
Jun 14, 2026
Merged

Complete cell examples, synapse communication, and network runtime APIs#105
chaoming0625 merged 39 commits into
mainfrom
integration_order

Conversation

@TLDSZ

@TLDSZ TLDSZ commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR integrates a broad set of multi-compartment modeling updates across cells, synapses, runtime scheduling, and network APIs.

The main goal is to make BrainCell more complete for end-to-end workflows: build biologically detailed cells, validate them against NEURON
references, connect them through synapses, and run small recurrent/network simulations through a first-class braincell.network interface.

Cell and mechanism updates

  • Completes and refreshes cerebellar cell comparison workflows for PC, GoC, GrC, DCN, BC, SC, and IO models.
  • Adds or updates BrainCell/NEURON paired implementations, parameter files, debug workflows, and runnable notebooks.
  • Improves multi-compartment runtime behavior for point mechanisms, channel current ownership, clamp routing, and compartment-level scheduling.
  • Adds support for additional channel/ion variants used by the comparison examples, including nonspecific ion handling and updated cerebellar
    channel implementations.
  • Adds generated morphology and native parser resources for DCN workflows.

Synapse and communication updates

  • Adds synapse comparison examples and runners for validating BrainCell synapse behavior against NEURON.
  • Improves runtime communication between cells, point mechanisms, synapses, and state buffers.
  • Extends event/input routing so synaptic inputs and point clamps can participate consistently in the multi-compartment runtime.
  • Updates comparison utilities and fixtures around synapse and channel workflows.

Network runtime and APIs

  • Adds a new braincell.network package with first-class APIs for:
    • populations
    • explicit connections
    • projections
    • topology helpers
    • connection lowering
    • delayed event delivery
    • network execution
  • Supports fixed-step delayed synaptic event delivery with per-edge/per-contact weights and delays.
  • Adds backend selection for event delivery, including scatter fallback and optional brainevent integration.
  • Adds network runtime/topology tests and design documentation for the new network layer.
  • Updates multi-compartment network examples and benchmarks to demonstrate the new APIs.

Docs, examples, and organization

  • Updates docs and notebooks for cells, mechanisms, filters, visualization, and network workflows.
  • Moves and reorganizes NEURON comparison examples under examples/neuron_compare.
  • Adds design notes for the network implementation and refreshes TODO/changelog entries.
  • Updates converter and validation utilities used by the example/model comparison workflows.

How Has This Been Tested

Tested locally with targeted and module-level regression runs.

Targeted regression for the recent network delay and implicit solver fixes:

python3 -m unittest \
  braincell.network.runtime_test.NetworkRuntimeTest.test_per_edge_heterogeneous_delays_arrive_at_different_steps \
  braincell.quad._implicit_test.ImplicitEulerLinearTest.test_one_step_lies_in_cn_bracket

Network runtime and implicit solver module tests:

/home/swl/anaconda3/envs/braincell/bin/python -m pytest \
  braincell/network/runtime_test.py \
  braincell/quad/_implicit_test.py \
  -q

Latest local result for the module-level regression run:

45 passed

Additional coverage in this branch includes tests for:

- multi-compartment runtime state buffers and scheduling
- channel and ion current ownership behavior
- cell construction and runtime initialization
- network topology helpers
- connection lowering and delayed event delivery
- synapse/point mechanism behavior
- NEURON comparison helper workflows and fixtures

## Types of changes

- New feature (non-breaking change which adds functionality)
- Bug fix (non-breaking change which fixes an issue)
- Documentation (non-breaking change which updates documentation)
- Refactoring (no functional changes, no api changes)

## Checklist

- [x] Code follows the code style of this project.
- [x] Changes follow the CONTRIBUTING guidelines.
- [x] Update necessary documentation accordingly.
- [x] Lint and tests pass locally with the changes.
- [ ] Check issues and pull requests first. You don't want to duplicate effort.

## Other information

This is a broad integration PR. Suggested review order:

1. Review the new braincell.network API and runtime behavior first.
2. Review multi-compartment runtime changes around point mechanisms, synapse input routing, and state buffers.
3. Review cell comparison examples and NEURON paired implementations.
4. Review docs/notebooks and generated comparison artifacts last.

The highest-risk areas are:

- delayed event delivery semantics and delay quantization
- runtime state-buffer ownership across cells, synapses, channels, and ions
- compatibility of comparison notebooks and NEURON reference workflows
- backend-specific event delivery behavior when brainevent is available

Tunenip added 30 commits May 28, 2026 14:44
Add frozen Cav2p1 aliases for BC2025 and SC2021 variants and register tests for those aliases.

Align BrainCell channel defaults and numerical behavior with the cerebellum NEURON comparisons, including GoC/BC Cav1p2 and Cav1p3 conductance defaults, CaHVA continuous rate formulas, Nav1p1 BC solver defaults, and precision-aligned Kv4p3/HCN constants.

Update channel_no_conc configs to match the revised conductance defaults and add the PC Kca2p2 dep_o1 comparison config.
Remove TABLE interpolation from cerebellum channel and ion mechanisms so rates are computed from continuous formulas.

Align selected integration and initialization paths, including cnexp rate placement, derivimplicit-to-cnexp gate updates, and Markov steady-state initializers for PC and SC mechanisms.

Document TABLE conversion status, integration-method status, rate-update placement, and numeric default precision notes for Cerebellum_mod.
Add BC2025 single-cell NEURON and BrainCell debug builders, parameter definitions, debug tests, and notebooks.

Include the BC2025 notes and default morphology/mechanism wiring for the cerebellum cell comparison examples.
Add SC2021 single-cell NEURON and BrainCell debug builders, parameter definitions, debug tests, and notebooks.

Encode the SC2021 region mapping, conductance parameters, morphology defaults, and diagnostic comparison entry points.
Add PC and GoC convergence-analysis notebooks and extend the PC debug workflow with Kca2p2 coupling diagnostics.

Expose the PC BrainCell ion channel update order option for diagnostic runs and document the expanded PC, GoC, BC, and SC cell comparison entry points.
Refresh the cable, channel_no_conc, and PC top-level comparison notebooks to match the updated cerebellum channel and cell comparison workflows.
Add generated convergence-analysis plots and metrics for GoC and PC debug comparisons.

Include PC Kca2p2 coupling diagnostic JSON and CSV outputs for the analyzed channel-isolation and update-order cases.
Add population-shaped runtime state for multi-compartment cells and update point-space buffers, clamp evaluation, probes, ion geometry, and voltage state to use pop_size-prefixed shapes.

Separate independent ion/channel updates through ind_update and make staggered stepping choose family or integration ordered post-voltage updates via ion_channel_update_order.

Route placed synapses through sparse pre_spike buffers with discrete event application, add NetStim and ExpSyn/Exp2Syn support, and move multi-compartment external current injection to placed point clamps.
Add braincell.network declarations for populations, reusable edge sets, projections, lowered sparse connections, and fixed-step network execution.

Expose Network at the package root and add network design docs, demos, and comparison helpers for placed synapse delivery.
Refresh README, TODO notes, design pointers, notebooks, and comparison examples for the unified CurrentClamp constructor, point-clamp external current path, population-shaped cells, and network/synapse workflow updates.
Keep whitespace-only formatting churn separate from the runtime, network, and docs changes.
- add ASC-only and full manual-morphology GrC debug builders
- add GrC debug notebooks, parameters, summaries, probes, and tests
- model full GrC morphology with hilock, AIS, AA, and PF chains
- switch GrC Nav/NaFHF MOD initialization to steady-state solves
- align BrainCell GrC Nav/NaFHF init/reset with steady-state initialization
# Conflicts:
#	braincell/_compute/runtime.py
#	examples/neuron_compare/cell/pc_ma2024/debug/run_debug.ipynb
#	examples/neuron_compare/cell/pc_ma2024/pc_braincell.py
#	examples/neuron_compare/cell/pc_ma2024/run.ipynb
#	examples/neuron_compare/channel_no_conc/tests/_helpers.py
#	examples/neuron_compare/channel_no_conc/tests/test_workflow_api.py
#	examples/neuron_compare/channel_no_conc/workflows/workflow.ipynb

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, we are unable to review this pull request

The GitHub API does not allow us to fetch diffs exceeding 300 files, and this pull request has 407

@chaoming0625 chaoming0625 merged commit fd21366 into main Jun 14, 2026
6 checks passed
@chaoming0625 chaoming0625 deleted the integration_order branch June 14, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants