Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,4 @@ cython_debug/
/examples/MC13_golgi_model/x86_64/
/.claude/
/dev/replace_init.py
/dev/replace_all.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ The official documentation is hosted on Read the Docs: [https://braincell.readth



## See also the brain modeling ecosystem
## See also the ecosystem

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

34 changes: 10 additions & 24 deletions braincell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,14 @@
# ==============================================================================


__version__ = "0.0.6"
__version_info__ = (0, 0, 6)
__version__ = "0.0.7"
__version_info__ = tuple(map(int, __version__.split(".")))

from . import channel
from . import ion
from . import morph
from . import neuron
from . import quad
from ._base import (
HHTypedNeuron,
IonChannel,
Expand All @@ -29,27 +31,10 @@
mix_ions,
IonInfo,
)
from ._integrator import *
from ._integrator_protocol import (
DiffEqState,
DiffEqModule,
IndependentIntegration,
)
from ._morphology import (
Segment,
Section,
CylinderSection,
PointSection,
Morphology,
)
from ._morphology_from_asc import from_asc
from ._morphology_from_swc import from_swc
from ._multi_compartment import (
MultiCompartment,
)
from ._single_compartment import (
SingleCompartment,
)
from ._multi_compartment import MultiCompartment
from ._single_compartment import SingleCompartment
from .morph import *
from .quad import *

_deprecations = {
'SingleCompartment': (
Expand All @@ -65,5 +50,6 @@
}

from braincell._misc import deprecation_getattr

neuron.__getattr__ = deprecation_getattr(__name__, _deprecations)
del deprecation_getattr
4 changes: 2 additions & 2 deletions braincell/_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,7 +88,7 @@
import numpy as np
from brainstate.mixin import _JointGenericAlias

from ._integrator_protocol import DiffEqModule, IndependentIntegration
from .quad import DiffEqModule, IndependentIntegration
from ._misc import set_module_as, Container, TreeNode

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/_base_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion braincell/_misc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
7 changes: 3 additions & 4 deletions braincell/_multi_compartment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,9 +19,8 @@
import brainunit as u

from ._base import HHTypedNeuron, IonChannel
from ._integrator import get_integrator
from ._integrator_protocol import DiffEqState, IndependentIntegration
from ._morphology import Morphology
from .quad import get_integrator, DiffEqState, IndependentIntegration
from .morph import Morphology
from ._typing import Initializer

__all__ = [
Expand Down
5 changes: 2 additions & 3 deletions braincell/_single_compartment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,8 +20,7 @@
import braintools

from ._base import HHTypedNeuron, IonChannel
from ._integrator import get_integrator
from ._integrator_protocol import DiffEqState, IndependentIntegration
from .quad import get_integrator, DiffEqState, IndependentIntegration
from ._typing import Initializer

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/_typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion braincell/channel/calcium.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import brainunit as u

from braincell._base import Channel, IonInfo
from braincell._integrator_protocol import DiffEqState
from braincell.quad import DiffEqState
from braincell.ion import Calcium

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/channel/hyperpolarization_activated.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import brainunit as u

from braincell._base import Channel, HHTypedNeuron
from braincell._integrator_protocol import DiffEqState
from braincell.quad import DiffEqState

__all__ = [
'Ih_HM1992',
Expand Down
2 changes: 1 addition & 1 deletion braincell/channel/potassium.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import brainunit as u

from braincell._base import Channel, IonInfo
from braincell._integrator_protocol import DiffEqState
from braincell.quad import DiffEqState
from braincell.ion import Potassium

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/channel/potassium_calcium.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import jax

from braincell._base import IonInfo, Channel
from braincell._integrator_protocol import DiffEqState
from braincell.quad import DiffEqState
from braincell.ion import Calcium, Potassium

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/channel/sodium.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import jax.tree

from braincell._base import Channel, IonInfo
from braincell._integrator_protocol import DiffEqState, IndependentIntegration
from braincell.quad import DiffEqState, IndependentIntegration
from braincell.ion import Sodium

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion braincell/ion/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions braincell/ion/calcium.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
import brainunit as u

from braincell._base import Ion, Channel, HHTypedNeuron
from braincell._integrator_protocol import DiffEqState
from braincell.quad import DiffEqState

__all__ = [
'Calcium',
Expand Down
2 changes: 1 addition & 1 deletion braincell/ion/potassium.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion braincell/ion/sodium.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
18 changes: 18 additions & 0 deletions braincell/morph/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2026 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

from ._from_asc import from_asc
from ._from_swc import from_swc
from ._morphology import Morphology, Segment, Section, CylinderSection, PointSection
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
from scipy.interpolate import interp1d

from ._morphology import Morphology
from ._morphology_utils import get_type_name
from ._utils import get_type_name


class Token:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2025 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2025 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@
import numpy as np

from ._morphology import Morphology
from ._morphology_utils import get_type_name
from ._utils import get_type_name


class Import3dSection:
Expand Down
12 changes: 6 additions & 6 deletions braincell/_morphology.py → braincell/morph/_morphology.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -21,15 +21,15 @@
import brainunit as u
import numpy as np

from ._morphology_branch_tree import BranchingTree
from ._morphology_utils import (
from ._branch_tree import BranchingTree
from ._utils import (
calculate_total_resistance_and_area,
generate_interpolated_nodes,
compute_connection_seg,
compute_line_ratios,
init_coupling_weight_nodes,
)
from ._typing import SectionName
from braincell._typing import SectionName

__all__ = [
'Segment',
Expand Down Expand Up @@ -925,7 +925,7 @@ def from_swc(cls, filename: str | Path):
Morphology
A Morphology object created from the SWC file
"""
from ._morphology_from_swc import from_swc
from ._from_swc import from_swc
return from_swc(filename)

@classmethod
Expand All @@ -943,7 +943,7 @@ def from_asc(cls, filename: str | Path):
Morphology
A Morphology object created from the ASC file
"""
from ._morphology_from_asc import from_asc
from ._from_asc import from_asc
return from_asc(filename)

def visualize(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,7 @@
class TestMorphologyConstruction:
def test_single(self):
# Instantiate a Morphology object
morphology = braincell.Morphology()
morphology = braincell.morph.Morphology()
# Create individual sections using the creation methods
morphology.add_cylinder_section(
'soma', length=20 * u.um, diam=10 * u.um, nseg=1
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_single(self):

def test_multiple(self):
# Instantiate a Morphology object
morphology = braincell.Morphology()
morphology = braincell.morph.Morphology()

# Define sections using a property dictionary
section_dicts = {
Expand Down Expand Up @@ -87,16 +87,16 @@ def test_multiple(self):

def test_swc(self):
# Load morphology from SWC file
swc_file = os.path.join(os.path.dirname(__file__), "../dev/swc_file/io.swc")
morphology = braincell.Morphology.from_swc(swc_file)
swc_file = os.path.join(os.path.dirname(__file__), "../../dev/swc_file/io.swc")
morphology = braincell.morph.from_swc(swc_file)
print(morphology)
# Initialize DHS
morphology.to_branch_tree()

def test_asc(self):
# Load morphology from ASC file
asc_file = os.path.join(os.path.dirname(__file__), "../dev/asc_file/golgi.asc")
morphology = braincell.Morphology.from_asc(asc_file)
asc_file = os.path.join(os.path.dirname(__file__), "../../dev/asc_file/golgi.asc")
morphology = braincell.morph.from_asc(asc_file)
print(morphology)
# Initialize DHS
morphology.to_branch_tree()
3 changes: 2 additions & 1 deletion braincell/_morphology_utils.py → braincell/morph/_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
import brainunit as u
import numpy as np


def calculate_total_resistance_and_area(
points: brainstate.typing.Array,
resistivity: u.Quantity = 100.0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,7 @@
import numpy as np
import pytest

from braincell._morphology_utils import (
from braincell.morph._utils import (
compute_line_ratios,
calculate_total_resistance_and_area,
find_ratio_interval,
Expand Down
2 changes: 1 addition & 1 deletion braincell/neuron/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 BDP Ecosystem Limited. All Rights Reserved.
# Copyright 2024 BrainX Ecosystem Limited. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Loading