Page 1 of 1

Implementing Superposition to "custom" waveforms in NMODL

Posted: Fri Oct 30, 2020 10:08 pm
by duytanph
Hello,

I am wondering if there is a way to implement superposition for waveforms that are "saved" in the form of a constant, predetermined array.

For example, the basic exp2syn.mod mechanism defines conductance waveforms that are governed by a double exponential function with respective DERIVATIVE state blocks. In an example situation where two NET_RECEIVE events occur somewhat close in time (let's say at t1 and t2), the output of the exp2syn conductance is presumably the sum/superposition of two waveforms. The key feature that I am trying to capture from this example is that the effects of the first waveform can be "felt" on the overall output even after t2. I am unsure exactly how NEURON maintains this superposition of waveforms. I assume it is something that happens "behind the scenes" and is hidden from the NMODL level. I am also wondering if this superposition feature is exclusive to variables defined as state variables/have a differential equation associated with them.

What I am ideally trying to achieve is this. Assume I have an array in my NMODL mechanism that stores a prerecorded, finite, and decaying waveform (where each index of the array represents subsequent timesteps--which admittedly will only work for fixed timestep NEURON simulations). I can already successfully output this saved waveform by incrementing some indexing variable at each timestep and outputting the contents of the array. I would like my NMODL mechanism to, just like exp2syn, be able to output superpositions of this saved waveform in the event of NET_RECEIVE inputs which result in overlapping waveforms. Again, the crucial feature that I am trying to achieve is the effects of waveform1 continuing AFTER t2 (after waveform 2 occurs). Since these waveforms are fixed and finite, I wasn't sure if this is achievable since there is no differential equation governing the waveforms.

I appreciate any help on this issue! Thanks :)

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Mon Nov 02, 2020 9:12 am
by ted
I am unsure exactly how NEURON maintains this superposition of waveforms. I assume it is something that happens "behind the scenes" and is hidden from the NMODL level.
There is no hidden magic. It arises naturally from the numerical integration of the differential equation(s) that govern the time course of conductance in synaptic mechanisms like Exp2Syn.
I can already successfully output this saved waveform by incrementing some indexing variable at each timestep and outputting the contents of the array.
Presumably you are doing that with Vector play().
The key feature that I am trying to capture from this example is that the effects of the first waveform can be "felt" on the overall output even after t2.
This happens automatically if your "waveform" is being used as a forcing function to a differential equation. Example: if you use Vector play() to drive an IClamp's amp parameter, the ODE that governs v in the affected segment is

C v' + {sum of segment's ionic currents} = {sum of axial currents entering the segment from adjacent segments}+ IClamp.i
where the amplitude of IClamp.i follows the variation of IClamp.amp

In this example, the persistent effect of IClamp.i is mediated by the charge that the IClamp deposits on local membrane capacitance C. Do you need to drive some other variable, such as a channel conductance?

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Mon Nov 02, 2020 5:56 pm
by duytanph
Thanks for the reply!
ted wrote: Mon Nov 02, 2020 9:12 am Presumably you are doing that with Vector play().
I am actually using pointer manipulation such that an NMODL mechanism is able to access the contents of a numpy array (see viewtopic.php?t=4167). The aim is to have the NMODL mechanism "play" some scaled version of the array every time there is a NET_RECEIVE event (in my case, this represents presynaptic release of NT). I believe the Vector.play() method is exclusive to the Python level of the simulation and is geared more towards answering "how will my mechanism react to this custom stimulation?" (Please correct me if I am wrong). I am, instead, seeking to get my mechanism to output a "known" waveform (at the NMODL level) in response to any presynaptic input pattern, while also obeying superposition. The use of the array to represent the waveform is purely to reduce computational load.
ted wrote: Mon Nov 02, 2020 9:12 am In this example, the persistent effect of IClamp.i is mediated by the charge that the IClamp deposits on local membrane capacitance C. Do you need to drive some other variable, such as a channel conductance?
Ideally, I would like to drive any variable while maintaining superposition. In this specific case, though, the variable represents open-state probability, which eventually leads me to conductance and then EPSC.
ted wrote: Mon Nov 02, 2020 9:12 am This happens automatically if your "waveform" is being used as a forcing function to a differential equation.
This is perhaps what I am after. Is there a way for me to accomplish this within the NMODL mechanism, instead of at the python level?

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Mon Nov 02, 2020 10:27 pm
by ted
For this particular problem, what do you want your array of precalculated values to drive? Probability of transmitter release as a function of time? Transmitter concentration in the synaptic cleft? The detailed time course of synaptic conductance? If none of these, then what?
The use of the array to represent the waveform is purely to reduce computational load.
At some point, programmer's effort becomes more important than computational load. What equations define the waveform?

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Wed Nov 04, 2020 4:01 pm
by duytanph
ted wrote: Mon Nov 02, 2020 10:27 pm For this particular problem, what do you want your array of precalculated values to drive? Probability of transmitter release as a function of time? Transmitter concentration in the synaptic cleft? The detailed time course of synaptic conductance? If none of these, then what?
I am trying to get the array to drive the time course of open-state probability of an NMDA receptor in response to presynaptic inputs provided by NET_RECEIVE.
ted wrote: Mon Nov 02, 2020 10:27 pm At some point, programmer's effort becomes more important than computational load. What equations define the waveform?
The equations are given by a 15-state kinetic model of NMDA receptors, which when simulated at large-scales (millions of synapses), take up large runtimes. The goal is to circumvent the heavy computational load by saving the "waveform" and playing it. I've been able to reduce runtimes by replacing this kinetic model (~200 minutes runtime) with using a saved basis waveform (on the order of 2-3 minutes). So I think the gain in speed is definitely worth it.

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Wed Nov 04, 2020 5:18 pm
by ted
Sounds like you have take on a challenging task. I'm fresh out of ideas for how to accomplish it.

Re: Implementing Superposition to "custom" waveforms in NMODL

Posted: Wed Nov 04, 2020 5:40 pm
by duytanph
No worries! Thank you for the help! I will update if I find a way to accomplish this.