# Neuroscientists using DifferentialEquations.jl ecosystem?

**URL:** <https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871>\
**Category:** Modelling & Simulations\
**Created:** [December 4, 2019, 8:30pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871 "2019-12-04T20:30:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsphillips](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsphillips/32/6777_2.png) [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Post date:** [December 4, 2019, 8:30pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/1 "2019-12-04T20:30:53Z")

</div>

I am curious who might be working with the DiffEq packages to do single neuron cell modeling up to small network simulations using Hodgkin Huxley or similar models, either single or multi-compartment, etc.

If you’re out there or know someone heavy into Julia + comp neuroscience, I am very curious whether anyone has played with neural differential equations (i.e. DiffEqFlux.jl) and directly fitting their models to real electrophysiological whole cell recordings of neurons, using it to infer coefficients like conductance/current density, etc

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [December 5, 2019, 12:02am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/2 "2019-12-05T00:02:42Z")

</div>

Most of those cellular level electrophysiological equations are pretty straightforward IIRC. Is there a pacjage that implements standard cellular modeling equations? That would be a good place to add these.

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [December 5, 2019, 1:37am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/3 "2019-12-05T01:37:37Z")

</div>

I’ve been contributing to [SpikingNeuralNetworks.jl](https://github.com/AStupidBear/SpikingNeuralNetworks.jl), which has a few different spiking neuron types available.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [December 5, 2019, 1:57am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/4 "2019-12-05T01:57:48Z")

</div>

That’s really impressive! A lot of these formulas are just outside the reach of macro scale analysis with EEG (which is more along the lines of what I do). However, it would be interesting to see how well certain frequency domains could be characterized be these. Thoeretically some of these domains are suppose to represent specific cell types.

---

<div class="post-metadata">

**Author:** ![grero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grero/32/109_2.png) [@grero](https://discourse.julialang.org/u/grero)\
**Post date:** [December 5, 2019, 7:05am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/5 "2019-12-05T07:05:17Z")

</div>

That looks really solid! I hope I find an excuse to play with it : )

---

<div class="post-metadata">

**Author:** ![wsphillips](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsphillips/32/6777_2.png) [@wsphillips](https://discourse.julialang.org/u/wsphillips)\
**Post date:** [December 5, 2019, 10:30am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/6 "2019-12-05T10:30:49Z")

</div>

Indeed the implementation of the equations isn’t such a big deal (although, it can get more elaborate when you start adding cell geometry, and networks).

I’m curious whether anyone has attempted using Hodgkin-Huxley or related models as an input layer to DiffEqFlux, and subsequently training on _real data_ to learn the coefficients. If someone has tried it or has some experience, it would be great to hear how it went for them. If not, I may just give it a go by my lonesome 🤓

Also, thanks for the link @jpsamaroo interesting indeed!

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [April 3, 2020, 5:08pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/7 "2020-04-03T17:08:52Z")

</div>

Anything new on this front? I am interested in a Julia alternative to the Brian simulator.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [April 3, 2020, 7:13pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/8 "2020-04-03T19:13:44Z")

</div>

Nothing that I am aware of and I am from this field. It should not be too difficult to write a Julia replacement though. Same for Neuron. I know a couple people who wrote a grant about writing a Julia analog of Neuron, not sure they got funded.

What is it that makes you turn away from Brian?

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [April 3, 2020, 8:39pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/9 "2020-04-03T20:39:26Z")

</div>

I love Brian actually. However, we are modling an compartmentalized system with astrocytes with a numerical technique that makes it difficult to work within the Synapse/NeuronGroup framework provided. I had to create an artificial Synaptic group and control the order of execution just so I could implement the numerical approach. This was unnatural to say the least, and non-maintanable. So I keep searching. Also, I fell in love with Julia lately. 🙂

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [April 4, 2020, 12:11pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/10 "2020-04-04T12:11:57Z")

</div>

SpikingNeuralNetworks is a really good start on this. The thing I found missing when I briefly played with it was easily composing networks. I have a heap of code that binds LightGraphs to a metadata structure that is more suitable for this sort of thing. It’s littered with notes and untested right now though. I was hoping to have something out weeks ago (nothing official but just to get some conversation going) but some events New York state have disrupted … everything.

Edit: by “more suitable for this sort of thing” I just mean composing networks not the actual neuron attributes that SpikingNeuralNetowrks does.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [April 4, 2020, 12:39pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/11 "2020-04-04T12:39:58Z")

</div>

The thing I am worried about SpikingNeuralNetworks, and it should be a fairly simple addition, is that the time stepper is not that great. It should perhaps give the choice of using OrdinaryDiffEq.jl. For example, the iz neuron blows up in finite time…

Hence the precision of the time spikes is not great.

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [April 4, 2020, 3:07pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/12 "2020-04-04T15:07:35Z")

</div>

Agreed, I think it’d be ideal to convert SNN (SpikingNeuralNetworks.jl) to use OrdinaryDiffEq as the integrator, especially since that would potebtially net us great GPU support. I have somewhat limited time right now, but if someone feels like putting together a PR to convert some or all of the models to use OrdinaryDiffEq, I’d be happy to review and merge.

---

<div class="post-metadata">

**Author:** ![Modatu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Modatu](https://discourse.julialang.org/u/Modatu)\
**Post date:** [April 4, 2020, 5:19pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/13 "2020-04-04T17:19:33Z")

</div>

Would you rate this as a “beginner” friendly task?

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [April 5, 2020, 11:54am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/14 "2020-04-05T11:54:52Z")

</div>

I think that it’s a pretty simple task from my standpoint, since the current API for each neuron model’s `integrate!` call looks reasonably similar to a DiffEq `solve` call. I can help you debug any issues you run into while doing this, of course.

---

<div class="post-metadata">

**Author:** ![Modatu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@Modatu](https://discourse.julialang.org/u/Modatu)\
**Post date:** [April 5, 2020, 4:28pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/15 "2020-04-05T16:28:06Z")

</div>

I am going to give it a try!  
Hopefully, I can start to work on it tomorrow.

---

<div class="post-metadata">

**Author:** ![Rainbow-Anthony\_Lili](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainbow-anthony_lili/32/13299_2.png) [@Rainbow-Anthony\_Lili](https://discourse.julialang.org/u/Rainbow-Anthony_Lili)\
**Post date:** [April 22, 2020, 6:48pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/16 "2020-04-22T18:48:09Z")

</div>

I’m doing exactly this for my final year uni project! It’s largely motivated by a different design principle from Brian. Brian wants the user to express their neuron through a series of differential equations as strings, which makes sense for a mathematician but feels very wrong to a programmer, and somewhat loses the representation of the biology behind a neuron. My goal is to build some package(?) in which the user creates an H-H style neuron as a struct, adding channels and gating variables with the necessary parameters, and then the resulting function is built from the structure and parameters, and then passed to an ODEProblem call. In this way the biological meaning is there, and from a programming perspective having the differential equation as a function built from the structure makes a lot more sense.  
I had hoped to integrate it with Unitly.jl in order to have the same unit-checking behaviour as Brian, and include some other model types. However progress has been significantly hampered by the whole global pandemic thing, so that may be an overly optimistic. I certainly intend to continue work on it after I had in whatever mess I manage to create in time for the end of the academic year though.  
If I manage to not totally fail my degree I might have something worth showing in a couple of months here.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 22, 2020, 7:43pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/17 "2020-04-22T19:43:58Z")

</div>

ModelingToolkit might be the thing to target now, since it has fancy component support and unit checking stuff. It’s not complete yet, but it’ll keep growing. I think @asinghvi17 has been doing some things along those lines.

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [April 23, 2020, 11:58am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/18 "2020-04-23T11:58:29Z")

</div>

I was using ModelingToolkit, and had a system set up, but for some reason, even in a simple example, the results from the hand-spun system and the MTK one were pretty different, and the solving was also pretty slow (understandably, since the constraints caused the final equation to be a DAE rather than an ODE).

After my exams end, my plan is to look into constructing the system on an expression level, by appending coupling terms to the equations. Since the metadata of the system (jacobian, Wfact, etc) seem not to be constructed, I think it should be possible to construct the ODE systems, and then append to them.

I’m using the FitzHugh-Nagumo model, by the way, which is simpler than most of the more commonly used ones but still reasonably accurate.

---

<div class="post-metadata">

**Author:** ![Zach\_Christensen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zach_christensen/32/7220_2.png) [@Zach\_Christensen](https://discourse.julialang.org/u/Zach_Christensen)\
**Post date:** [April 23, 2020, 1:15pm UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/19 "2020-04-23T13:15:45Z")

</div>

> [@ChrisRackauckas](#):
>
> It’s not complete yet

Are you referring to unit support with comment or just that it’s generally not ready for prime time use.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 24, 2020, 4:55am UTC](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871/20 "2020-04-24T04:55:38Z")

</div>

> [@Zach\_Christensen](#):
>
> Are you referring to unit support with comment or just that it’s generally not ready for prime time use.

Not complete yet and not ready for prime time use are quite different. It’s ready for people to use, and a lot of infrastructure is using it (ParameterizedFunctions.jl is one use, and Pumas is a commercial software that utilizes it under the hood).That said, there’s still a lot of things to add, like automating the algebraic simplifications, automatic GPU support, etc. so where we are vs where I want it to be is still quite a gap. That said, the current interface is stable, and there are ways to do things like unit support, it’s just not the easiest to tell MTK what your units are (exposing type definitions at the higher level is one thing we plan to add fairly soon).

[Next page](https://discourse.julialang.org/t/neuroscientists-using-differentialequations-jl-ecosystem/31871.md?page=2)
