Giter VIP home page Giter VIP logo

poirazi-lab / dendrify Goto Github PK

View Code? Open in Web Editor NEW
28.0 4.0 4.0 10.5 MB

Introducing dendrites to spiking neural networks. Designed for the Brian 2 simulator.

Home Page: https://dendrify.readthedocs.io/en/latest/

License: GNU General Public License v3.0

Python 6.23% Makefile 0.03% Batchfile 0.03% Jupyter Notebook 93.71%
dendrites snns brian2 spiking-neural-networks dendritic-mechanisms reduced-neuron-models

dendrify's Introduction

Dendrify

Introducing dendrites to spiking neural networks

image

Documentation Status

Contributor Covenant

Although neuronal dendrites play a crucial role in shaping how individual neurons process synaptic information, their contribution to network-level functions has remained largely unexplored. Current spiking neural networks (SNNs) often oversimplify dendritic properties or overlook their essential functions. On the other hand, circuit models with morphologically detailed neuron representations are computationally intensive, making them impractical for simulating large networks.

In an effort to bridge this gap, we present Dendrify—a freely available, open-source Python package that seamlessly integrates with the Brian 2 simulator. Dendrify, through simple commands, automatically generates reduced compartmental neuron models with simplified yet biologically relevant dendritic and synaptic integrative properties. These models offer a well-rounded compromise between flexibility, performance, and biological accuracy, enabling us to investigate the impact of dendrites on network-level functions.

image

If you use Dendrify for your published research, we kindly ask you to cite our article:

Pagkalos, M., Chavlis, S., & Poirazi, P. (2023). Introducing the Dendrify framework for incorporating dendrites to spiking neural networks. Nature Communications, 14(1), 131. https://doi.org/10.1038/s41467-022-35747-8

Documentation for Dendrify can be found at https://dendrify.readthedocs.io/en/latest/

The project presentation for the INCF/OCNS Software Working Group is available on google drive.

dendrify's People

Contributors

ckarageorgkaneen avatar mpgl avatar poirazilab avatar spiroschv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dendrify's Issues

Encapsulate brian objects

Encapsulate brian objects in the same way brian, pytorch, etc. encapsulate other libraries (e.g. numpy, matplotlib)
e.g.

import brian2 as b
from brian2.units import (ms, um, pA, nS, uS, ohm, cm, mV, uF, mvolt)
from dendrify import Soma, Dendrite, NeuronModel

b.prefs.codegen.target = 'numpy'
b.start_scope()    # allows running separate simulations in the same notebook

should be:

import dendrify as d
from dendrify.units import (ms, um, pA, nS, uS, ohm, cm, mV, uF, mvolt)
d.prefs.codegen.target = 'numpy'
d.start_scope()

This makes development and usage easier, cleaner and less ambiguous.

Implement tests

  1. Write unit tests
  2. Write functional tests
  3. Implement a workflow that runs the tests on every push or PR to assure that further changes to the project don't break anything

Replace sys.exit() with specific error

sys.exit() raises SystemError. However, dendrify errors vary and are not system-related. So, always calling sys.exit() is misleading.

Suggestion: Replace sys.exit() calls with raising specific exceptions.

E.g. instead of this:

if self.name == other.name:
    print(("ERROR: Cannot connect to compartments with the same name.\n"
           "Program exited"))
    sys.exit()

do this:

if self.name == other.name:
    raise ValueError('Cannot connect to compartments with the same name')

See:

Error on import

pip install dendrify && python -c 'import dendrify'

yields

Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "/home/csk/miniconda3/envs/dendrify/lib/python3.10/site-packages/dendrify/__init__.py", line 1, in <module>
      from .compartment import Compartment, Dendrite, Soma
   File "/home/csk/miniconda3/envs/dendrify/lib/python3.10/site-packages/dendrify/compartment.py", line 13, in <module>
      import numpy as np                                                                                                            
ModuleNotFoundError: No module named 'numpy'

This is obviously fixed by installing the required brian2 dependency. However, any required dependencies should be automatically installed when installing the package.

Replace linking scheme

Having to create a NeuronModel and a NeuronGroup and then having to link them is unnecessarily complex for the user.
Linking should at the very least be hidden and not have to be done by the user.

I suggest the following. Just define your own dendrify NeuronGroup that inherits Brian's NeuronGroup and extends it with all the cool functionality of your current NeuronModel class. After this, dendrify will only have one neuron-related class, and no linking.

That would simplify snippets such as the following:

edges = [(soma, apical, 10*nS), (soma, basal, 10*nS)]
pyr_model = NeuronModel(edges, cm=1*uF/(cm**2), gl=50*uS/(cm**2),
                          v_rest=-70*mV, r_axial=150*ohm*cm,
                          scale_factor=3, spine_factor=1.5)

# create a Brian NeuronGroup and link it to the neuron model
pyr_group = b.NeuronGroup(3, model=pyr_model.equations, method='euler',
                          threshold='V_soma > -40*mV', reset='V_soma = -50*mV',
                          refractory=3*ms, namespace=pyr_model.parameters)
pyr_model.link(pyr_group)

into something like this:

edges = [(soma, apical, 10*nS), (soma, basal, 10*nS)]
pyr_group = d.NeuronGroup(3, edges, ...)

So that everything you want to happen, happens inside your NeuronGroup.

Nice and simple.

Replace exec statements

Putting assignment statements in strings and using exec() (e.g. this) leads to having to do weird things, beforehand. Like, parsing the guts of the main module just to get a hold of a neuron group object. All this is unnecessarily complex.

There are two better ways of doing such things:

  1. One alternative is just having the dendrify NeuronModel hold a reference of the brian NeuronGroup. Therefore, to set the rest potential, for example, you can do something like this:
for cpt in self._compartments:
    setattr(self.linked_ng, f'V_{cpt.name}', self.linked_ng.namespace[f'EL_{cpt.name}'])
  1. Another simple way would be to implement the suggestion: #13 (comment), by merging your NeuronModel with the brian NeuronGroup. Then, you could just be able to do this:
for cpt in self._compartments:
    setattr(self, f'V_{cpt.name}', self.namespace[f'EL_{cpt.name}'])

since self would itself be just an instance of a brian NeuronGroup subclass.

Missing paper_figures notebooks requirements

In order to successfully run the paper_figures/ notebooks , I had to manually install the following requirements:

git-lfs
networkx
seaborn
scipy
statsmodels

These should either be installed at the top of the notebook (e.g. !pip install seaborn --quiet), or at least be inside a paper_figures/requirements.txt file, so a user can easily install them all at once.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.