Add option to save total synaptic current into each section
On the suggestion of @ccluri and @hglabska, an option should be added to nC to save not just the individual currents through each of the synapses on a cell, but to save the total synaptic current into each section (e.g. for post processing and generating local field potential/current source density plots).
This has been started in the main branch and a test project which will be used to develop/test the feature has been added here: https://github.com/NeuralEnsemble/neuroConstruct/tree/master/testProjects/TestSynCurrents
It would be good to get input on what the best algorithm for this might be before fully implementing it...
- create vectors (indexed by synapse id) to record the instantaneous currents through each synapse using record() on Vector class
- when simulation finishes, loop through each section, create a vector with the same size as number of timesteps; loop through each synapse vector, determine whether this synapse is on this section; add the value for current at each timestep from this syn to the corresponding timestep val in the section totals file
- write each section totals vector to file (text or hdf5)
If there are other options you know of for saving/collating this data more efficiently (i.e. without having to store all individual syn currents until the end) I'd be grateful to know.
One possible change to the above: did you want the total transmembrane current, i.e. currents through ion channels also? Also, do you want this at each numerical integration point, i.e. 3 separate files when nseg = 3?
We are interested in the trans-membrane currents (synaptic+ionic+passive+capacitive) at every time step - variable or otherwise. We think it would be easier to look from the segment point of view rather than the synapses.
NEURON specific suggestions
- Compute the trans-membrane currents based on the difference between axial current entering and leaving each segment. This i_tm is what is of interest to us.
OR
- Ability to track every current on the segment [ a great feature to have! ] - This is similar to your suggestion, however, breaking into chunks might be a better idea. For example: i_ion = ina + ik + ica + icl + ... (?) i_syn = i_nmda + i_gabaa + i_gabab + i_ampa + ... (?) TC model specific : i_ar, i_cat, i_cat_a [generally in the format i__] and then, i_tm = (i_ion + icap + ipas )_area_seg + i_syn
The way to go about this without have to store all individual currents is to use "new MechanismType(1)" of NEURON. This way only one Vector per segment is needed.
mylib.hoc code by @hglabska https://gist.github.com/ccluri/5934704 See proc take_currents and func source_i
On behalf of @hglabska and @ccluri