There’s some discussion going on about specifying systems using LightGraphs here.
Hi,
I’ve done this before as a coding exercise. You could use DiffEqFlux to get gradients of the model wrt some loss function. Or, more simply, any of the techniques here.
DiffEqParamEstim.jl is also a nice package for this.
One tip: don’t use an L2 loss on your data. A slight phase lag in a spike results in a huge L2 difference vs the nominal spike. So the loss function is badly conditioned, and optimisers converge more slowly.
A well conditioned loss for spiking models is: calculate the current you would have to inject at any point in time to make \dot{V}(t) of the parameterised model the same as that of the nominal model. IE
I_{inj}(t) = \dot{V}(t) - \dot{V}^*(t)
Then take the l2 integral of this current:
Cost = \int^T_0 I_{inj}(t)^2 \ dt
IE how hard would I have to push charge in/out of the membrane to make the model dynamics match the nominal dynamics.
Scientifically speaking, it might be useful to make your model behave like the data. However I don’t think there is any point in trying to infer biophysical parameters (e.g. conductances) by model fitting. It’s a hugely ill-coniditioned problem on these conductance based models. You give me a model and a set of parameters that fit the data. I will give you a completely (orders of magnitude) different set of parameters that also fit the data. Hence, the parameter values themselves are meaningless (although the capability of the model to fit the data may be meaningful). (This might be a bit of a generalisation)
Good luck!
PS another nice feature of the I_{inj} loss I described:
If the only parameters you are interested in are maximal conductances (or more generally, parameters that enter the equation for \dot{V} but not the time-derivatives of the ion channel states)…
Then you don’t even need to solve the differential equation more than once to calculate the loss at different parameter values! Since if you injected the I_{inj}(t) current, voltage (and hence ion channel) dynamics would be the same as for the nominal model.
So you can
- Solve the ion channel dynamics corresponding to your observed voltage trace (i.e. solve a differential equation).
- Trapezoidally integrate I_{inj}(t)^2 over time, using
I_{inj}(t) = \dot{V}^*(t) - \dot{V}(parameters, t)
and the fact that \dot{V}(parameters,t) + I_{inj}(t) follows the (solved) dynamics of V^*(t) over time.
Of course, this needs accurate knowledge of \dot{V}^*(t)…
We recently released a SNN sim package as well, WaspNet.jl. Although it doesn’t integrate with DifferentialEquations currently
We can get that fixed . Are you on the Julia slack? Join the #diffeq or #sciml channels and let’s throw a solution down someday soon!
I wanted to build a model of the famous lobster stomatogastric ganglion circuit from e.g. here.
I ended up building a mini package for iteratively making small circuit models from a library of ion channels and synapses:
https://github.com/Dhruva2/NeuronBuilder
I haven’t actually found the right synaptic conductance parameters that give the triphasic bursting behaviour from the paper. (I wasn’t careful with units, and I have to figure out what the published units correspond to in my code). And it was a ‘long weekend’ project, which I might not be able to get back to for a few weeks, so don’t expect an update soon.
Nevertheless, the code works, modulo finding the right synaptic conductance parameter values. Might be a useful template for people wanting to build similar circuits? You define the dynamics of each ion channel and synapse you want to add, and modeling toolkit magic turns it into a system of connected neurons.
More generally, with the recent Modeling Toolkit improvements. I think the Julia community could make something much faster and more flexible than current packages such as the NEURON simulator, with much less effort. That would be nice to see and I’d be happy to contribute