As mentioned in a previous post, you can compile frequently used functions to save time when running your NEURON code. For my code, this made a huge difference when it came to connecting the model cells. The process used to be coded in hoc, and it took hours. Now it takes about a minute in NMODL for my largest model size.
For my code, the longest part of the connectivity process was not making the connections, but deciding which connections should be made. The full size model makes just over one billion synapses. For each connection, it chooses which cells to connect randomly, while taking into account the proximity of the cells to be connected. Therefore, I put the decision making process into NMODL, and that alone was sufficient to reduce the time requirement over an order of magnitude.
I took advantage of compiled NMODL code by using a custom vector method (technique from Bill Lytton) in the following way:
To understand how to do this, first take a look at my general example for using a custom vector method.
Once that makes sense, look at my specific example for using a custom vector method to determine the model connectivity. It shows:
- how to use a random number generator in NMODL in a reproducible manner without accidentally reusing any of the same numbers during a parallel simulation.
- how to make the connectivity depend on all of the following:
- the axonal extent of the presynaptic cell type
- the bouton distribution of the presynaptic cell type
- the distance between the presynaptic and postsynaptic cells.
- How to specify the positions of the cells using a generic algorithm that distributes them in a prism
Note that this is just one way of using NMODL to speed up NEURON code. Ted Carnevale also has a nice example of how to put pretty much anything written in C into NMODL, very easily. So there is a lot of potential with NMODL, and much of it would be even simpler to implement than what I’ve done here with the connectivity algorithm.
Do you have specific feedback or questions about my connectivity code? Comment here! Or join the discussion generally at the NEURON forum.