Metadata-Version: 2.4
Name: braincell
Version: 0.0.6
Summary: Biologically Detailed Brain Cell Modeling in JAX
Author-email: BrainCell Developers <chao.brain@qq.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/chaobrain/braincell
Project-URL: Documentation, https://braincell.readthedocs.io/
Project-URL: Bug Tracker, https://github.com/chaobrain/braincell/issues
Project-URL: Source Code, https://github.com/chaobrain/braincell
Keywords: dendritic computation,dendritic modeling,brain modeling,neuron simulation
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
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: Intended Audience :: Science/Research
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: brainunit>=0.0.8
Requires-Dist: brainstate>=0.2.0
Requires-Dist: brainevent>=0.0.2
Requires-Dist: scipy
Requires-Dist: brainpy>=2.7.0
Requires-Dist: braintools>=0.1.0
Provides-Extra: cpu
Requires-Dist: jax[cpu]; extra == "cpu"
Requires-Dist: brainstate; extra == "cpu"
Requires-Dist: brainunit; extra == "cpu"
Requires-Dist: brainevent; extra == "cpu"
Requires-Dist: brainpy; extra == "cpu"
Requires-Dist: braintools; extra == "cpu"
Provides-Extra: cuda12
Requires-Dist: jax[cuda12]; extra == "cuda12"
Requires-Dist: brainstate; extra == "cuda12"
Requires-Dist: brainunit; extra == "cuda12"
Requires-Dist: brainevent; extra == "cuda12"
Requires-Dist: brainpy; extra == "cuda12"
Requires-Dist: braintools; extra == "cuda12"
Provides-Extra: cuda13
Requires-Dist: jax[cuda13]; extra == "cuda13"
Requires-Dist: brainstate; extra == "cuda13"
Requires-Dist: brainunit; extra == "cuda13"
Requires-Dist: brainevent; extra == "cuda13"
Requires-Dist: brainpy; extra == "cuda13"
Requires-Dist: braintools; extra == "cuda13"
Provides-Extra: tpu
Requires-Dist: jax[tpu]; extra == "tpu"
Requires-Dist: brainstate; extra == "tpu"
Requires-Dist: brainunit; extra == "tpu"
Requires-Dist: brainevent; extra == "tpu"
Requires-Dist: brainpy; extra == "tpu"
Requires-Dist: braintools; extra == "tpu"
Provides-Extra: testing
Requires-Dist: pytest; extra == "testing"
Requires-Dist: jax; extra == "testing"
Requires-Dist: brainstate; extra == "testing"
Requires-Dist: brainunit; extra == "testing"
Requires-Dist: brainevent; extra == "testing"
Requires-Dist: brainpy; extra == "testing"
Requires-Dist: braintools; extra == "testing"
Dynamic: license-file



# 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/?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 braintools
import brainunit as u

class HTC(braincell.SingleCompartment):
    def __init__(self, size, solver: str = 'ind_exp_euler'):
        super().__init__(size, V_initializer=braintools.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/

