Skip to main content

Biologically Detailed Brain Cell Modeling in JAX

Project description

Biologically Detailed Brain Cell Modeling in JAX

Header image of BrainCell.

Supported Python Version LICENSE Documentation Status PyPI version Continuous Integration DOI

braincell provides a unified interface for modeling single-compartment and multi-compartment Hodgkin-Huxley-styled neuron models. It is built on top of JAX and 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:

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:

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:

pip install braincell --upgrade

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

pip install BrainX -U

Documentation

The official documentation is hosted on Read the Docs: https://braincell.readthedocs.io

See also the ecosystem

BrainCell is one part of our brain modeling ecosystem: https://brainmodeling.readthedocs.io/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

braincell-0.0.7.tar.gz (5.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

braincell-0.0.7-py3-none-any.whl (155.8 kB view details)

Uploaded Python 3

File details

Details for the file braincell-0.0.7.tar.gz.

File metadata

  • Download URL: braincell-0.0.7.tar.gz
  • Upload date:
  • Size: 5.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for braincell-0.0.7.tar.gz
Algorithm Hash digest
SHA256 bbe9a7804cca99ec7092ae6d5f46571577ca11ead3d7dc3b6e8a678ed734da76
MD5 d4640e8bbfc3955a15060c61ce84ddc6
BLAKE2b-256 48bc3ddb5ef1ace5f714136d722c77d88fcabd07da6c657755907d5e1231a6d1

See more details on using hashes here.

File details

Details for the file braincell-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: braincell-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 155.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for braincell-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 741041e12ba473c9203e2f7eab2377a1cb58890467d920caec7c175de67751fb
MD5 8239d0cc6994f11f6e44a4ac6a9dc7b9
BLAKE2b-256 845752d4446e77b1b1f227790e846f4c90d6c597342bca7668574bca6203dd72

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page