Metadata-Version: 2.2
Name: brainmodeling
Version: 2025.5.4
Summary: Brain Modeling Ecosystem.
Home-page: https://github.com/chaobrain/brainmodeling
Author: BrainEvent Developers
Author-email: Brain Modeling Ecosystem Developers <chao.brain@qq.com>
License: Apache-2.0 license
Project-URL: homepage, http://github.com/chaobrain/brainmodeling
Project-URL: repository, http://github.com/chaobrain/brainmodeling
Keywords: computational neuroscience,brain-inspired computation,brain dynamics programming
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.15
Requires-Dist: jax>=0.4.35
Requires-Dist: brainunit>=0.0.10
Requires-Dist: brainevent>=0.0.1.post20250502
Requires-Dist: brainstate>=0.1.0.post20250501
Requires-Dist: braincell>=0.0.1.post20250216
Requires-Dist: braintools>=0.0.4.post20250423
Provides-Extra: testing
Requires-Dist: pytest; extra == "testing"
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# Brain Modeling Ecosystem

[![PyPI version](https://img.shields.io/pypi/v/brainmodeling)](https://pypi.org/project/brainmodeling/)
![Read the Docs](https://img.shields.io/readthedocs/brainmodeling)


<p align="center">
  	<img alt="Header image of Brain Modeling Ecosystem." src="https://raw.githubusercontent.com/chaobrain/brainmodeling/main/docs/_static/bdp-ecosystem.png" width=50%>
</p> 


## Overview

Brain Modeling Ecosystem is a comprehensive framework for computational neuroscience and brain simulation. 
It provides tools and libraries for researchers to model, simulate, train, and analyze neural systems at different scales.

For complete documentation, please see [Brain Modeling Ecosystem](https://brainmodeling.readthedocs.io).

**Core components** in this ecosystem includes:

- [BrainUnit](https://github.com/chaobrain/brainunit): Comprehensive physical units and unit-aware mathematical system for brain dynamics.

- [BrainCell](https://github.com/chaobrain/braincell): Intuitive, parallel, and efficient simulation for biologically detailed brain cell modeling. 

- [BrainState](https://github.com/chaobrain/brainstate): State-based IR compilation for efficient simulation of brain models on CPUs, GPUs, and TPUs.

- [BrainTaichi](https://github.com/chaobrain/braintaichi): The first-generation framework for customizing event-driven operators based on Taichi Lang syntax.

- [BrainEvent](https://github.com/chaobrain/brainevent): Enabling event-driven computations in brain dynamics. 

- [BrainScale](https://github.com/chaobrain/brainscale): Enabling scalable online learning for brain dynamics: $O(N)$ complexity for SNNs, and $O(N^2)$ for RNN computations.

- [BrainTools](https://github.com/chaobrain/braintools): Commonly used tools for brain dynamics programming, for example checkpointing. 


## Installation

The ecosystem can be installed with the following command:

```bash
pip install brainmodeling
```

This pins particular versions of component projects which are known to work correctly together via the integration tests in this repository. 




## Quick Start

```python
import braintools
import brainstate
import brainunit as u


class EINet(brainstate.nn.Module):
    def __init__(self):
        super().__init__()
        self.n_exc = 3200
        self.n_inh = 800
        self.num = self.n_exc + self.n_inh
        self.N = brainstate.nn.LIFRef(
            self.num, V_rest=-60. * u.mV, V_th=-50. * u.mV, V_reset=-60. * u.mV,
            tau=20. * u.ms, tau_ref=5. * u.ms,
            V_initializer=brainstate.init.Normal(-55., 2., unit=u.mV)
        )
        self.E = brainstate.nn.AlignPostProj(
            comm=brainstate.nn.EventFixedProb(self.n_exc, self.num, 0.02, 0.6 * u.mS),
            syn=brainstate.nn.Expon.desc(self.num, tau=5. * u.ms),
            out=brainstate.nn.COBA.desc(E=0. * u.mV),
            post=self.N
        )
        self.I = brainstate.nn.AlignPostProj(
            comm=brainstate.nn.EventFixedProb(self.n_inh, self.num, 0.02, 6.7 * u.mS),
            syn=brainstate.nn.Expon.desc(self.num, tau=10. * u.ms),
            out=brainstate.nn.COBA.desc(E=-80. * u.mV),
            post=self.N
        )

    def update(self, t, inp):
        with brainstate.environ.context(t=t):
            spk = self.N.get_spike() != 0.
            self.E(spk[:self.n_exc])
            self.I(spk[self.n_exc:])
            self.N(inp)
            return self.N.get_spike()
    
    def save_checkpoint(self):
        braintools.file.msgpack_save('states.msgpack', self.states())

```

## Documentation

For detailed documentation, tutorials, and examples, visit our [Documentation Portal](https://brainmodeling.readthedocs.io).


## Contributing

We welcome contributions from the community! Please see our [Contributing Guidelines](CONTRIBUTING.md) for more information on how to get involved.


## License

This project is licensed under the [Apache License v2.0](LICENSE).

## Citation

If you use the Brain Modeling Ecosystem in your research, please use the following link: https://brainmodeling.readthedocs.io/citation.html


## Support

For questions and support, please [open an issue](https://github.com/chaobrain/brainmodeling/issues) or email to us: chao.brain@qq.com



