brainevent


Namebrainevent JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/chaobrain/brainevent
SummaryEvent-driven Computation in JAX for Brain Dynamics.
upload_time2025-07-31 02:19:57
maintainerNone
docs_urlNone
authorBrainEvent Developers
requires_python>=3.10
licenseApache-2.0 license
keywords computational neuroscience brain-inspired computation brain dynamics programming
VCS
bugtrack_url
requirements numpy jax jaxlib brainunit brainstate absl-py
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Enabling Event-driven Computation in Brain Dynamics

[//]: # (<p align="center">)

[//]: # (  	<img alt="Header image of brainevent." src="https://github.com/chaobrain/brainevent/blob/main/docs/_static/brainevent.png" width=50%>)

[//]: # (</p> )



<p align="center">
	<a href="https://pypi.org/project/brainevent/"><img alt="Supported Python Version" src="https://img.shields.io/pypi/pyversions/brainevent"></a>
	<a href="https://github.com/chaobrain/brainevent/blob/main/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a>
  	<a href='https://brainevent.readthedocs.io/en/latest/?badge=latest'>
        <img src='https://readthedocs.org/projects/brainevent/badge/?version=latest' alt='Documentation Status' />
    </a>
    <a href="https://badge.fury.io/py/brainevent"><img alt="PyPI version" src="https://badge.fury.io/py/brainevent.svg"></a>
    <a href="https://github.com/chaobrain/brainevent/actions/workflows/CI.yml"><img alt="Continuous Integration" src="https://github.com/chaobrain/brainevent/actions/workflows/CI.yml/badge.svg"></a>
    <a href="https://github.com/chaobrain/brainevent/actions/workflows/CI-daily.yml"><img alt="Daily CI Tests" src="https://github.com/chaobrain/brainevent/actions/workflows/CI-daily.yml/badge.svg"></a>
    <a href="https://pepy.tech/projects/brainevent"><img src="https://static.pepy.tech/badge/brainevent" alt="PyPI Downloads"></a>
    <a href="https://doi.org/10.5281/zenodo.15324450"><img src="https://zenodo.org/badge/921610544.svg" alt="DOI"></a>
</p>


Brain is characterized by the discrete spiking events, which are the fundamental units of computation in the brain.

`BrainEvent` provides a set of data structures and algorithms for such event-driven computation on
**CPUs**, **GPUs**, **TPUs**, and maybe more, which can be used to model the brain dynamics in an
efficient and biologically plausible way.

Particularly, it provides the following class to represent binary events in the brain:

- ``EventArray``: representing array with a vector/matrix of events.

Furthermore, it implements the following commonly used data structures for event-driven computation
of the above class:

- ``COO``: a sparse matrix in COO format for sparse and event-driven computation.
- ``CSR``: a sparse matrix in CSR format for sparse and event-driven computation.
- ``CSC``: a sparse matrix in CSC format for sparse and event-driven computation.
- ``JITCHomoR``: a just-in-time connectivity matrix with homogenous weight for sparse and event-driven computation.
- ``JITCNormalR``: a just-in-time connectivity matrix with normal distribution weight for sparse and event-driven
  computation.
- ``JITCUniformR``: a just-in-time connectivity matrix with uniform distribution weight for sparse and event-driven
  computation.
- ``FixedPreNumConn``: a fixed number of pre-synaptic connections for sparse and event-driven computation.
- ``FixedPostNumConn``: a fixed number of post-synaptic connections for sparse and event-driven computation.
- ...

`BrainEvent` is fully compatible with physical units and unit-aware computations provided
in [BrainUnit](https://github.com/chaobrain/brainunit).

## Usage

If you want to take advantage of event-driven computations, you must warp your data with ``brainevent.EventArray``:

```python
import brainevent

# wrap your array with EventArray
event_array = brainevent.EventArray(your_array)
```

Then, the matrix multiplication with the following data structures, $\mathrm{event\ array} @ \mathrm{data}$,
will take advantage of event-driven computations:

- Sparse data structures provided by ``brainevent``, like:
    - ``brainevent.CSR``
    - ``brainevent.JITCHomoR``
    - ``brainevent.FixedPostNumConn``
    - ...
- Dense data structures provided by JAX/NumPy, like:
    - ``jax.numpy.ndarray``
    - ``numpy.ndarray``


```python
data = jax.random.rand(...)  # normal dense array
data = brainevent.CSR(...)  # CSR structure
data = brainevent.JITCHomoR(...)  # JIT connectivity
data = brainevent.FixedPostNumConn(...)  # fixed number of post-synaptic connections

# event-driven matrix multiplication
r = event_array @ data
r = data @ event_array
```

## Installation

You can install ``brainevent`` via pip:

```bash
pip install brainevent -U
```

Alternatively, you can install `BrainX`, which bundles `brainevent` with other compatible packages for a comprehensive brain modeling ecosystem:

```bash
pip install BrainX -U
```


## Documentation

The official documentation is hosted on Read the Docs: [https://brainevent.readthedocs.io/](https://brainevent.readthedocs.io/)


## See also the brain modeling ecosystem

We are building the brain modeling ecosystem: https://brainmodeling.readthedocs.io/


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/chaobrain/brainevent",
    "name": "brainevent",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "computational neuroscience, brain-inspired computation, brain dynamics programming",
    "author": "BrainEvent Developers",
    "author_email": "BrainEvent Developers <chao.brain@qq.com>",
    "download_url": null,
    "platform": null,
    "description": "# Enabling Event-driven Computation in Brain Dynamics\r\n\r\n[//]: # (<p align=\"center\">)\r\n\r\n[//]: # (  \t<img alt=\"Header image of brainevent.\" src=\"https://github.com/chaobrain/brainevent/blob/main/docs/_static/brainevent.png\" width=50%>)\r\n\r\n[//]: # (</p> )\r\n\r\n\r\n\r\n<p align=\"center\">\r\n\t<a href=\"https://pypi.org/project/brainevent/\"><img alt=\"Supported Python Version\" src=\"https://img.shields.io/pypi/pyversions/brainevent\"></a>\r\n\t<a href=\"https://github.com/chaobrain/brainevent/blob/main/LICENSE\"><img alt=\"LICENSE\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"></a>\r\n  \t<a href='https://brainevent.readthedocs.io/en/latest/?badge=latest'>\r\n        <img src='https://readthedocs.org/projects/brainevent/badge/?version=latest' alt='Documentation Status' />\r\n    </a>\r\n    <a href=\"https://badge.fury.io/py/brainevent\"><img alt=\"PyPI version\" src=\"https://badge.fury.io/py/brainevent.svg\"></a>\r\n    <a href=\"https://github.com/chaobrain/brainevent/actions/workflows/CI.yml\"><img alt=\"Continuous Integration\" src=\"https://github.com/chaobrain/brainevent/actions/workflows/CI.yml/badge.svg\"></a>\r\n    <a href=\"https://github.com/chaobrain/brainevent/actions/workflows/CI-daily.yml\"><img alt=\"Daily CI Tests\" src=\"https://github.com/chaobrain/brainevent/actions/workflows/CI-daily.yml/badge.svg\"></a>\r\n    <a href=\"https://pepy.tech/projects/brainevent\"><img src=\"https://static.pepy.tech/badge/brainevent\" alt=\"PyPI Downloads\"></a>\r\n    <a href=\"https://doi.org/10.5281/zenodo.15324450\"><img src=\"https://zenodo.org/badge/921610544.svg\" alt=\"DOI\"></a>\r\n</p>\r\n\r\n\r\nBrain is characterized by the discrete spiking events, which are the fundamental units of computation in the brain.\r\n\r\n`BrainEvent` provides a set of data structures and algorithms for such event-driven computation on\r\n**CPUs**, **GPUs**, **TPUs**, and maybe more, which can be used to model the brain dynamics in an\r\nefficient and biologically plausible way.\r\n\r\nParticularly, it provides the following class to represent binary events in the brain:\r\n\r\n- ``EventArray``: representing array with a vector/matrix of events.\r\n\r\nFurthermore, it implements the following commonly used data structures for event-driven computation\r\nof the above class:\r\n\r\n- ``COO``: a sparse matrix in COO format for sparse and event-driven computation.\r\n- ``CSR``: a sparse matrix in CSR format for sparse and event-driven computation.\r\n- ``CSC``: a sparse matrix in CSC format for sparse and event-driven computation.\r\n- ``JITCHomoR``: a just-in-time connectivity matrix with homogenous weight for sparse and event-driven computation.\r\n- ``JITCNormalR``: a just-in-time connectivity matrix with normal distribution weight for sparse and event-driven\r\n  computation.\r\n- ``JITCUniformR``: a just-in-time connectivity matrix with uniform distribution weight for sparse and event-driven\r\n  computation.\r\n- ``FixedPreNumConn``: a fixed number of pre-synaptic connections for sparse and event-driven computation.\r\n- ``FixedPostNumConn``: a fixed number of post-synaptic connections for sparse and event-driven computation.\r\n- ...\r\n\r\n`BrainEvent` is fully compatible with physical units and unit-aware computations provided\r\nin [BrainUnit](https://github.com/chaobrain/brainunit).\r\n\r\n## Usage\r\n\r\nIf you want to take advantage of event-driven computations, you must warp your data with ``brainevent.EventArray``:\r\n\r\n```python\r\nimport brainevent\r\n\r\n# wrap your array with EventArray\r\nevent_array = brainevent.EventArray(your_array)\r\n```\r\n\r\nThen, the matrix multiplication with the following data structures, $\\mathrm{event\\ array} @ \\mathrm{data}$,\r\nwill take advantage of event-driven computations:\r\n\r\n- Sparse data structures provided by ``brainevent``, like:\r\n    - ``brainevent.CSR``\r\n    - ``brainevent.JITCHomoR``\r\n    - ``brainevent.FixedPostNumConn``\r\n    - ...\r\n- Dense data structures provided by JAX/NumPy, like:\r\n    - ``jax.numpy.ndarray``\r\n    - ``numpy.ndarray``\r\n\r\n\r\n```python\r\ndata = jax.random.rand(...)  # normal dense array\r\ndata = brainevent.CSR(...)  # CSR structure\r\ndata = brainevent.JITCHomoR(...)  # JIT connectivity\r\ndata = brainevent.FixedPostNumConn(...)  # fixed number of post-synaptic connections\r\n\r\n# event-driven matrix multiplication\r\nr = event_array @ data\r\nr = data @ event_array\r\n```\r\n\r\n## Installation\r\n\r\nYou can install ``brainevent`` via pip:\r\n\r\n```bash\r\npip install brainevent -U\r\n```\r\n\r\nAlternatively, you can install `BrainX`, which bundles `brainevent` with other compatible packages for a comprehensive brain modeling ecosystem:\r\n\r\n```bash\r\npip install BrainX -U\r\n```\r\n\r\n\r\n## Documentation\r\n\r\nThe official documentation is hosted on Read the Docs: [https://brainevent.readthedocs.io/](https://brainevent.readthedocs.io/)\r\n\r\n\r\n## See also the brain modeling ecosystem\r\n\r\nWe are building the brain modeling ecosystem: https://brainmodeling.readthedocs.io/\r\n\r\n",
    "bugtrack_url": null,
    "license": "Apache-2.0 license",
    "summary": "Event-driven Computation in JAX for Brain Dynamics.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/chaobrain/brainevent",
        "homepage": "http://github.com/chaobrain/brainevent",
        "repository": "http://github.com/chaobrain/brainevent"
    },
    "split_keywords": [
        "computational neuroscience",
        " brain-inspired computation",
        " brain dynamics programming"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc89ac3509fdc2ed71ac7b8724480f31211508b852c3ce8c1e09aefbc91cddd2",
                "md5": "e35c6a2fae61ada5932e56735af8c242",
                "sha256": "b42533c55197697604ba4c9b86f49545af1126f0717cb5a54c759b9225c168a5"
            },
            "downloads": -1,
            "filename": "brainevent-0.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e35c6a2fae61ada5932e56735af8c242",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.10",
            "size": 289490,
            "upload_time": "2025-07-31T02:19:57",
            "upload_time_iso_8601": "2025-07-31T02:19:57.198465Z",
            "url": "https://files.pythonhosted.org/packages/fc/89/ac3509fdc2ed71ac7b8724480f31211508b852c3ce8c1e09aefbc91cddd2/brainevent-0.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-31 02:19:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chaobrain",
    "github_project": "brainevent",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "jax",
            "specs": []
        },
        {
            "name": "jaxlib",
            "specs": []
        },
        {
            "name": "brainunit",
            "specs": [
                [
                    ">=",
                    "0.0.4"
                ]
            ]
        },
        {
            "name": "brainstate",
            "specs": []
        },
        {
            "name": "absl-py",
            "specs": []
        }
    ],
    "lcname": "brainevent"
}
        
Elapsed time: 1.31547s