braincell


Namebraincell JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/chaobrain/braincell
SummaryBiologically Detailed Brain Cell Modeling in JAX
upload_time2025-07-13 06:03:44
maintainerNone
docs_urlNone
authorBrainCell Developers
requires_python>=3.10
licenseApache-2.0 license
keywords dendritic computation dendritic modeling brain modeling neuron simulation
VCS
bugtrack_url
requirements numpy scipy jax brainunit brainstate brainevent
Travis-CI No Travis.
coveralls test coverage No coveralls.
            

# Biologically Detailed Brain Cell Modeling in JAX

<p align="center">
  	<img alt="Header image of BrainCell." src="https://raw.githubusercontent.com/chaobrain/braincell/main/docs/_static/braincell.png" width=50%>
</p> 



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



[braincell](https://github.com/chaobrain/braincell) provides a unified interface for modeling single-compartment and multi-compartment Hodgkin-Huxley-styled neuron models. 
It is built on top of [JAX](https://github.com/jax-ml/jax) and [brainstate](https://github.com/chaobrain/brainstate), offering a highly parallelized and efficient simulation 
of biophysically detailed brain cell models.






## Quick start


Here is an example to model the **single-compartment** thalamus neuron model by using the interface of `braincell.SingleCompartment`:

```python
import braincell
import brainstate
import brainunit as u

class HTC(braincell.SingleCompartment):
    def __init__(self, size, solver: str = 'ind_exp_euler'):
        super().__init__(size, V_initializer=brainstate.init.Constant(-65. * u.mV), V_th=20. * u.mV, solver=solver)

        self.na = braincell.ion.SodiumFixed(size, E=50. * u.mV)
        self.na.add(INa=braincell.channel.INa_Ba2002(size, V_sh=-30 * u.mV))

        self.k = braincell.ion.PotassiumFixed(size, E=-90. * u.mV)
        self.k.add(IKL=braincell.channel.IK_Leak(size, g_max=0.01 * (u.mS / u.cm ** 2)))
        self.k.add(IDR=braincell.channel.IKDR_Ba2002(size, V_sh=-30. * u.mV, phi=0.25))

        self.ca = braincell.ion.CalciumDetailed(size, C_rest=5e-5 * u.mM, tau=10. * u.ms, d=0.5 * u.um)
        self.ca.add(ICaL=braincell.channel.ICaL_IS2008(size, g_max=0.5 * (u.mS / u.cm ** 2)))
        self.ca.add(ICaN=braincell.channel.ICaN_IS2008(size, g_max=0.5 * (u.mS / u.cm ** 2)))
        self.ca.add(ICaT=braincell.channel.ICaT_HM1992(size, g_max=2.1 * (u.mS / u.cm ** 2)))
        self.ca.add(ICaHT=braincell.channel.ICaHT_HM1992(size, g_max=3.0 * (u.mS / u.cm ** 2)))

        self.kca = braincell.MixIons(self.k, self.ca)
        self.kca.add(IAHP=braincell.channel.IAHP_De1994(size, g_max=0.3 * (u.mS / u.cm ** 2)))

        self.Ih = braincell.channel.Ih_HM1992(size, g_max=0.01 * (u.mS / u.cm ** 2), E=-43 * u.mV)
        self.IL = braincell.channel.IL(size, g_max=0.0075 * (u.mS / u.cm ** 2), E=-70 * u.mV)

```


Here is an example to model the **multi-compartment** neuron model by using the interface of `braincell.MultiCompartment`:


```python
import braincell
import brainstate
import brainunit as u


class HTC(braincell.MultiCompartment):
    def __init__(self, size, solver: str = 'staggered'):
        morphology = braincell.Morphology.from_swc(...)
        super().__init__(size, 
                         morphology=morphology,   # the only difference from SingleCompartment
                         V_initializer=brainstate.init.Constant(-65. * u.mV), 
                         V_th=20. * u.mV, 
                         solver=solver)
        
        self.na = braincell.ion.SodiumFixed(size, E=50. * u.mV)
        self.na.add(INa=braincell.channel.INa_Ba2002(size, V_sh=-30 * u.mV))

        self.k = braincell.ion.PotassiumFixed(size, E=-90. * u.mV)
        self.k.add(IDR=braincell.channel.IKDR_Ba2002(size, V_sh=-30. * u.mV, phi=0.25))

```



## Installation

You can install ``braincell`` via pip:

```bash
pip install braincell --upgrade
```


Alternatively, you can install `BrainX`, which bundles `braincell` 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://braincell.readthedocs.io](https://braincell.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/braincell",
    "name": "braincell",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "dendritic computation, dendritic modeling, brain modeling, neuron simulation",
    "author": "BrainCell Developers",
    "author_email": "braincell Developers <chao.brain@qq.com>",
    "download_url": null,
    "platform": null,
    "description": "\r\n\r\n# Biologically Detailed Brain Cell Modeling in JAX\r\n\r\n<p align=\"center\">\r\n  \t<img alt=\"Header image of BrainCell.\" src=\"https://raw.githubusercontent.com/chaobrain/braincell/main/docs/_static/braincell.png\" width=50%>\r\n</p> \r\n\r\n\r\n\r\n<p align=\"center\">\r\n\t<a href=\"https://pypi.org/project/braincell/\"><img alt=\"Supported Python Version\" src=\"https://img.shields.io/pypi/pyversions/braincell\"></a>\r\n\t<a href=\"https://github.com/chaobrain/braincell/blob/main/LICENSE\"><img alt=\"LICENSE\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"></a>\r\n    <a href='https://braincell.readthedocs.io/en/latest/?badge=latest'>\r\n        <img src='https://readthedocs.org/projects/braincell/badge/?version=latest' alt='Documentation Status' />\r\n    </a>  \t\r\n    <a href=\"https://badge.fury.io/py/braincell\"><img alt=\"PyPI version\" src=\"https://badge.fury.io/py/braincell.svg\"></a>\r\n    <a href=\"https://github.com/chaobrain/braincell/actions/workflows/CI.yml\"><img alt=\"Continuous Integration\" src=\"https://github.com/chaobrain/braincell/actions/workflows/CI.yml/badge.svg\"></a>\r\n    <a href=\"https://doi.org/10.5281/zenodo.14969987\"><img src=\"https://zenodo.org/badge/825447742.svg\" alt=\"DOI\"></a>\r\n</p>\r\n\r\n\r\n\r\n[braincell](https://github.com/chaobrain/braincell) provides a unified interface for modeling single-compartment and multi-compartment Hodgkin-Huxley-styled neuron models. \r\nIt is built on top of [JAX](https://github.com/jax-ml/jax) and [brainstate](https://github.com/chaobrain/brainstate), offering a highly parallelized and efficient simulation \r\nof biophysically detailed brain cell models.\r\n\r\n\r\n\r\n\r\n\r\n\r\n## Quick start\r\n\r\n\r\nHere is an example to model the **single-compartment** thalamus neuron model by using the interface of `braincell.SingleCompartment`:\r\n\r\n```python\r\nimport braincell\r\nimport brainstate\r\nimport brainunit as u\r\n\r\nclass HTC(braincell.SingleCompartment):\r\n    def __init__(self, size, solver: str = 'ind_exp_euler'):\r\n        super().__init__(size, V_initializer=brainstate.init.Constant(-65. * u.mV), V_th=20. * u.mV, solver=solver)\r\n\r\n        self.na = braincell.ion.SodiumFixed(size, E=50. * u.mV)\r\n        self.na.add(INa=braincell.channel.INa_Ba2002(size, V_sh=-30 * u.mV))\r\n\r\n        self.k = braincell.ion.PotassiumFixed(size, E=-90. * u.mV)\r\n        self.k.add(IKL=braincell.channel.IK_Leak(size, g_max=0.01 * (u.mS / u.cm ** 2)))\r\n        self.k.add(IDR=braincell.channel.IKDR_Ba2002(size, V_sh=-30. * u.mV, phi=0.25))\r\n\r\n        self.ca = braincell.ion.CalciumDetailed(size, C_rest=5e-5 * u.mM, tau=10. * u.ms, d=0.5 * u.um)\r\n        self.ca.add(ICaL=braincell.channel.ICaL_IS2008(size, g_max=0.5 * (u.mS / u.cm ** 2)))\r\n        self.ca.add(ICaN=braincell.channel.ICaN_IS2008(size, g_max=0.5 * (u.mS / u.cm ** 2)))\r\n        self.ca.add(ICaT=braincell.channel.ICaT_HM1992(size, g_max=2.1 * (u.mS / u.cm ** 2)))\r\n        self.ca.add(ICaHT=braincell.channel.ICaHT_HM1992(size, g_max=3.0 * (u.mS / u.cm ** 2)))\r\n\r\n        self.kca = braincell.MixIons(self.k, self.ca)\r\n        self.kca.add(IAHP=braincell.channel.IAHP_De1994(size, g_max=0.3 * (u.mS / u.cm ** 2)))\r\n\r\n        self.Ih = braincell.channel.Ih_HM1992(size, g_max=0.01 * (u.mS / u.cm ** 2), E=-43 * u.mV)\r\n        self.IL = braincell.channel.IL(size, g_max=0.0075 * (u.mS / u.cm ** 2), E=-70 * u.mV)\r\n\r\n```\r\n\r\n\r\nHere is an example to model the **multi-compartment** neuron model by using the interface of `braincell.MultiCompartment`:\r\n\r\n\r\n```python\r\nimport braincell\r\nimport brainstate\r\nimport brainunit as u\r\n\r\n\r\nclass HTC(braincell.MultiCompartment):\r\n    def __init__(self, size, solver: str = 'staggered'):\r\n        morphology = braincell.Morphology.from_swc(...)\r\n        super().__init__(size, \r\n                         morphology=morphology,   # the only difference from SingleCompartment\r\n                         V_initializer=brainstate.init.Constant(-65. * u.mV), \r\n                         V_th=20. * u.mV, \r\n                         solver=solver)\r\n        \r\n        self.na = braincell.ion.SodiumFixed(size, E=50. * u.mV)\r\n        self.na.add(INa=braincell.channel.INa_Ba2002(size, V_sh=-30 * u.mV))\r\n\r\n        self.k = braincell.ion.PotassiumFixed(size, E=-90. * u.mV)\r\n        self.k.add(IDR=braincell.channel.IKDR_Ba2002(size, V_sh=-30. * u.mV, phi=0.25))\r\n\r\n```\r\n\r\n\r\n\r\n## Installation\r\n\r\nYou can install ``braincell`` via pip:\r\n\r\n```bash\r\npip install braincell --upgrade\r\n```\r\n\r\n\r\nAlternatively, you can install `BrainX`, which bundles `braincell` 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://braincell.readthedocs.io](https://braincell.readthedocs.io)\r\n\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": "Biologically Detailed Brain Cell Modeling in JAX",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/chaobrain/braincell",
        "homepage": "http://github.com/chaobrain/braincell",
        "repository": "http://github.com/chaobrain/braincell"
    },
    "split_keywords": [
        "dendritic computation",
        " dendritic modeling",
        " brain modeling",
        " neuron simulation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1df0e899ee5dfddc552588b440629fa3a2641afb00d970f3bd4f0a1c72da2baa",
                "md5": "0950892f55d780c6a53fd7b0a20bfba7",
                "sha256": "30e22436bc4362117e63688ebbf8eab5d67081dfb55e8ba49f62ab3613939945"
            },
            "downloads": -1,
            "filename": "braincell-0.0.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0950892f55d780c6a53fd7b0a20bfba7",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.10",
            "size": 464977,
            "upload_time": "2025-07-13T06:03:44",
            "upload_time_iso_8601": "2025-07-13T06:03:44.112272Z",
            "url": "https://files.pythonhosted.org/packages/1d/f0/e899ee5dfddc552588b440629fa3a2641afb00d970f3bd4f0a1c72da2baa/braincell-0.0.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-13 06:03:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chaobrain",
    "github_project": "braincell",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": []
        },
        {
            "name": "scipy",
            "specs": []
        },
        {
            "name": "jax",
            "specs": []
        },
        {
            "name": "brainunit",
            "specs": [
                [
                    ">=",
                    "0.0.2.post20240903"
                ]
            ]
        },
        {
            "name": "brainstate",
            "specs": [
                [
                    ">=",
                    "0.0.2"
                ]
            ]
        },
        {
            "name": "brainevent",
            "specs": [
                [
                    ">=",
                    "0.0.2"
                ]
            ]
        }
    ],
    "lcname": "braincell"
}
        
Elapsed time: 2.75759s