Axons with compartmental models in Neuronify
One of the features I have been wanting to implementing in Neuronify for a long time is compartmental models. These are used to simulate features such as action potentials running down an axon:
The big blue dot represents the soma of a neuron, which is driven by a current source - the yellow dot. The blue lines represent the axon, which is built up of individual compartments, represented as small blue dots.
Even though we had a few implementations of compartmental models in the making for Neuronify 1.0, we never got around to releasing them. The biggest challenge was to find a good way to combine the compartments with neurons, which are modelled as points and based on the integrate-and-fire model.
In the integrate-and-fire model, the connections between the neurons is modeled as a simple time delay between when a neuron fires and when the current is injected into the receiving neuron. In the simulation below, the yellow dot is a current source, while the blue dots are excitatory neurons. The red dots are inhibitory.
The small white dots flowing across the lines represents a signal going down the axon. The signal will always take the exact same time to reach its target, as it is modelled only as a time delay:
Combining the integrate-and-fire model with a compartmental model raises a number of choices that must be made. Should some neurons be modelled only as compartments? How should compartments be connected together by the user? How do we keep two neurons from suddenly fusing if any compartment can be connected to any other compartment?
Another challenge with the compartmental model is that its calculations are way slower than the integrate-and-fire model. Multiple time steps are needed for an action potential to propagate from one compartment to the next. While in the integrate-and-fire model, the time delay is trivial and fast to implement.
After playing around with Neuronify 2.0 for a while, I think I have found a fairly simple solution to combine the two paradigms.
By leaving the soma as a point, but allowing the axons to be modelled as compartments, we can get the best of both worlds. This allows for some interesting dynamics to be explored, while still keeping the simulation performant and easy to understand. And fully compartmental models can still be included in the future.
To solve the challenge regarding compartment connection, I decided to make it possible only to make new connections from existing compartments, but not to existing compartments. I also decided to make the positions of the axons dynamic. Even though you get to draw them yourself, I added a bit of repulsion between the compartments, which I think helps make them organize themselves more pleasingly.
This means that two axons that are drawn crossing each other do not get fused into a single axon. Instead, they stay independent and allow the signals in one axon to seamlessly flow past the other axon. The repulsion also organizes the two such that it looks like one is atop the other, as you can see in the simulation above.