## computing impedances...

Anything that doesn't fit elsewhere.
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### computing impedances...

Dear All,

I have a very simple one-compartment model cell. My interest is to see whether in this simple approach it is possible to check resonant properties.

For that, the cell contains K+, Na+, leak and h-channels. The point is that by applying a zap current (negative in order to hyperpolarize and get strong ih activation), I expected to be able to check the nice frequency response curve (Z vs f)
reported in many papers. but it was not the case.

Here f is the instantaneous frequency of the iZAP current and Z the impedance of the membrane. However I am stroggling in understanding the results. I assumed Z=abs(V_m/I_zap) with V_m the membrane potential an I_zap the injected current. After having described my assumptions I observed the next:

1. By using the interval f=(20-0.01Hz) or (0.01-20Hz) for the ZAP, there is a nice peak in the voltage about 5.7Hz (though not extremely high compared to that for lower freqs) .

2. The Z vs F plot produced a kind of periodic curve not related at all with the expected shape (check for example http://ma-yue.net/study/bib/neuron/hutcheon_tn_2000.pdf)
Then I defined Z=abs(V_m-V_rest)/abs(I_zap-I_zap_0) where V-rest is clear an I_zap_0 is the offset of the zap assuming I_Zap=I_ZAP_0+ZAP_amplitude*sin(2PI*ft). However it didn't work either.

Question: Is this assumption of variables right? if not could anyone please tell me what is the right way to compute Z and the firing response curve?
or is there any other manner to check resonance in the model?

Thanks a lot
OJAG
ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

Hi, Oscar. Hutcheon & Yarom (TINS 2000) is a nice paper.

It is possible to study resonance in a model by current clamping with a zap function. There are some caveats, however.

First, it is important to use the correct function to produce the swept sinusoid. Cali et al. did it properly--they understood that frequency is merely angular velocity, so that if you want frequency to increase linearly with time, you want angular velocity to increase linearly with time
w = w0 + (w1 - w0)*t/dur
where
w is angular velocity at time t
w0 is initial angular velocity
w1 is final angular velocity
dur is the time it takes to sweep from w0 to w1
t is the time that has elapsed from the start of the frequency ramp

By integration, angular displacement is
theta = 2*PI*t*(f0 + (f1-f0)*t/(2*dur))
where
f0 is the initial frequency ( = w0/2/PI )
f1 is the final frequency ( = w1/2/PI )
dur is the time it takes to sweep from f0 to f1
t is the time that has elapsed from the start of the frequency ramp

And the swept sinusoid is just sin(theta).

For your convenience, and that of anyone else who wants to use a zap function, I created izap.mod, which specifies the properties of the Izap class--a current clamp that delivers an oscillating current that starts at time del and sweeps a sinusoid from f0 to f1 in the course of dur ms. Source code and a demonstration program are available here
http://www.neuron.yale.edu/ftp/ted/neuron/izap.zip

Second, it is important to realize that signal amplitude should be kept small, to avoid membrane nonlinearities that would interfere with interpretation of results.

Third, the injected current is going to make membrane potential fluctuate around an operating point. Membrane rectification (mostly caused by the slower potassium currents) will make the operating point different from the resting potential before the onset of the injected current. The magnitude of this effect can be reduced by decreasing the amplitude of the injected current.

A more convenient way to check the frequency selectivity of a model is to use NEURON's GUI impedance tools, being sure to click on the "include dstate/dt contribution" box.
NEURON Main Menu / Tools / Impedance / Frequency
will let you very quickly evaluate the input at any point in a model, or the transfer impedance between any two points in a model. If you're not familiar with this tool, see the "Electrotonic Analysis" exercise from a recent NEURON summer course--
http://www.neuron.yale.edu/neuron/stati ... zclass.htm
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### Re: computing impedances...

Hi Ted,

Thanks a lot for the really nice feedback!! I followed your suggestion and checked with the impedance tool my simple cell. As a result of this the cell exhibited resonance in the region I previously saw in the voltage plot.
However by running the simulation, while keeping open the impedance tool, I observed that the variable part of the Z vs log_10(freq) plot ( i.e. for low frequencies) was moving up when the sinusoid Zap amplitude was moving up and down in the opposite case. Is this an effect of the h-channels opening and closing dynamics? If so, can I conclude that it is then transparent to K+, Na+ changes, because of the stationary shape with I_zap fluctuations; since the time scales of their activation and deactivation variables are faster?

In my former procedure I indeed used your ZAP implementation with a subtle variation, namely
i = amp_0+amp * sin( 2*PI * (t-del) * (f0 + (f1 - f0)*(t-del)/(2*dur)) * (0.001) ) in order to create an offset in the current, so that by computing Z=V/i no unexpected x/0 values could occur.
nevertheless I am wondering why it didn't work. So my last question concerning the impedance definition is

Was it wrong to define Z=abs(V_m-V_rest)/abs(I_zap-I_zap_0) ? , how can I measure it if my output vectors are time_ ,Freq_zap, I_zap, and Voltage_ ?
How is implemented the impedance definition in the impedance tool? where can I find it out?

Thanks again Ted.

Cheers,

OJAG
ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

OJAG wrote:Is this an effect of the h-channels opening and closing dynamics?
Try changing the dynamics of the h current and see what happens.
In my former procedure I indeed used your ZAP implementation with a subtle variation, namely
i = amp_0+amp * sin( 2*PI * (t-del) * (f0 + (f1 - f0)*(t-del)/(2*dur)) * (0.001) ) in order to create an offset in the current, so that by computing Z=V/i no unexpected x/0 values could occur.
Adding a constant current merely introduces a perturbation of membrane potential that causes a dynamic shift of the operating point of the cell during the sinusoid. Not a useful thing to do.

Do you mean to say you're calculating Z by calculating (v-vrest)/i continuously during the application of the sinusoid? You really need to calculate the ratio of the waveform envelopes, i.e.
Z = v_peak-to-peak/i_peak-to-peak

i_peak-to-peak ("peak to peak amplitude of the injected current") is easy--that's a constant specified by a parameter of the Izap mechanism.

v_peak-to-peak changes continuously throughout the simulation, because the envelope of the voltage response varies continuously throughout the simulation. The envelope has two "limbs"--a positive limb and a negative limb. Imagine a pair of smooth curves, one that is tangent to the voltage waveform "from above" (this is the positive limb), and another that is tangent to the voltage waveform from below (this is the negative limb). If the injected current is a sinusoid with constant frequency, in the steady state the positive and negative limbs would be horizontal lines that are tangent to the positive and negative extrema of the voltage response. If the injected current is a sinusoid with variable frequency, the maximum depolarizations of the voltage response are approximate samples of the positive limb at times tp0, tp1 . . .. Approximate, because if impedance is increasing with frequency, the positive limb will actually be tangent to the sinusoid on the rising phase of the sinusoid, i.e. shortly before the time of maximum depolarization. Likewise, if impedance is decreasing with frequency, the positive limb will be tangent to the sinusoid on the falling phase of the sinusoid, which means slightly after the time of maximum depolarization. But the error will be small if frequency is increasing slowly enough, so that the regions where impedance increases or decreases are sampled by many oscillations of the injected current.

And of course the maximum hyperpolarizations of the voltage response are approximate samples of the negative limb of the voltage envelope at times tn0, tn1 . . ..

So if there are N cycles, you have N pairs of times and voltages that approximate a sampling of the positive limb of the voltage envelope, and N pairs of times and values that approximate a sampling of the negative limb. And this means you can define a piecewise linear function that approximates the positive and negative limbs of the voltage envelope, and from these two limbs you can compute the peak-to-peak amplitude of the voltage response. It will never be zero, so as I said before, there is no need to add a nonzero current to the injected sinusoid.
How is implemented the impedance definition in the impedance tool?
The impedance tools calculate input and transfer impedance in the frequency domain. This is much faster than running a simulation in the time domain, and it computes values throughout the entire cell at the same time. Requires just a single solution to a matrix equation. The coordinates of the matrix are filled in with values that come from the parameters of the model, and (if "include dstate/dt contribution" has been activated) augmented by values discovered by numerical differentiation of the system equations (a couple of evaluations of the system equations at two voltages separated by 0.001 mV).
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### Re: computing impedances...

Hi Ted,

It is clear to me now.

Thanks a lot,

Oscar Javier
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### Re: computing impedances...

Hi Ted,

Though this post might be a bit late, I was checking through literature and I did not manage to figure out why the measure I should take in order to compute the impedance is the peak to peak of the voltage signal and current respectively i?

My second point concerns about the computation of the impedance performed by the impedance-tool:

If I undrestand There is a linear rpresentation of the cable equation such that
dx/dt+ax=f(t) in this case the voltage plays re role of x and f(t) is actually in terms of the current i (please correct me if the reasoning is wrong).

My questions are:

-How dit you arrive to the expression: [(jwc - di/dv)v = i0 ] * exp(jwt), i.e. "the linearized impedance matrix" (where can I find the deduction)?

-Does the impedance matrix play the role of transfer function? between V and I?

-Why in the full linearized method is it possible to include di/ds, ds'/dv and ds'/ds?

-Is s' a different variable or is s'=ds/dt?

and finally, once you compute the matrix components, What represents the dataset plotted by the impedance tool in relation to that matrix?

Hope you can help me with the answer to (some of ) these new questions
Best,

OJAG
ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

OJAG wrote:why the measure I should take in order to compute the impedance is the peak to peak of the voltage signal and current respectively i?
This is just small signal analysis. The input signal is a sinusoidal current with mean 0. The output will be a fluctuation of potential around a DC level ("operating point"). The DC level is present even in the absence of input signal; small signal analysis ignores it.
-How dit you arrive to the expression: [(jwc - di/dv)v = i0 ] * exp(jwt)
Fourier transform of the cable equation.
-Does the impedance matrix play the role of transfer function? between V and I?
Yes.
-Why in the full linearized method is it possible to include di/ds, ds'/dv and ds'/ds?
It isn't "possible" to include these derivatives--it is necessary to include them. The necessity comes from the chain rule. If v fluctuates, then so must voltage-gated states. Fluctuations in states other than v induce changes in other variables, and must be included in the complete expression for the linearized impedance matrix.
-Is s' a different variable or is s'=ds/dt?
"s are all the other states of the membrane mechanisms" [i.e. the states other than v]
What represents the dataset plotted by the impedance tool in relation to that matrix?
Depends on which of the Impedance Toolkit's tools you are using, and what you select with its "Plot" button (if it has a Plot button). The first three tools in the menu show a label on the graph that tells the meaning of its y coordinates. The x axis of the first two tools (Impedance / Frequency and Impedance / Path) is log10(frequency); the x axis of the third tool (Impedance / log(A) vs. x) is anatomical (path) distance from a reference point. The fourth tool (Impedance / Shape) redraws the branched pattern of the cell but with branch lengths that are proportional to log(voltage attenuation).
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### Re: computing impedances...

Hi Ted,

After our last communication I peformed the analytical calculation of the Fourier tranform of the cable equation and I did not manage to arrive to this expression
[(jwc - di/dv)v = i0 ] * exp(jwt) (1)

furthermore, I did not fully understand what the meaning is of
d2v/dx2 compartmental terms are in i....
Could you please let me know whether there exist any reference concerning the calculation of (1)? otherwise could you tell me what are the intermediate assumptions necessary to rewrite the Fourier transform of the cable equation as (1)?

Thanks a lot

OJAG
ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

The cable equation in its simplest form is
c*dv/dt = membrane ionic currents + axial currents + injected current
The "axial currents" term is porportional to the second spatial derivative of v, which can be written (crudely--superscripts would be nice but I'm not sure the Forum allows that kind of formatting, or how to do it) as d2v/dx2.

Since we are interested in small fluctuations of v around an "operating point," this equation can be rewritten as
c*dv/dt = v*di/dv + axial currents + injected current
where v means the "AC compoment" of membrane potential (the fluctuations minus the average membrane potential) and di/dv is the membrane slope conductance. Move the v*di/dv term to the left hand side and apply the Fourier transform in time and the result is
jwcv - v di/dv = i0
where i0 is the result of applying the transform to the sum of the two current terms.

For a slightly different approach, you might want to look at chapter 3 "Linear cable theory" in the book "Electric current flow in excitable cells" by Jack, Noble, and Tsien. They use Laplace transforms, but a Fourier transform is basically just a Laplace transform with jw substituted for s.
btorb
Posts: 30
Joined: Fri Oct 21, 2005 8:14 am

### Re: computing impedances...

Hi Ted, so, in short the answer is that we have to use the Impedance tool included and toggle the "full" computation of the impedance

Code: Select all

``compute(loc,1)``
?

If I understand the explanation in the programmers manual correctly the toggle has to be used when the membrane contains voltage-gated conductances? (in passive membranes there is no difference, correct?)
ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

btorb wrote:in short the answer is that we have to use the Impedance tool included
I'm not sure what you're asking here. You can always call the underlying methods of the Impedance class directly, as documented in the Programmer's Reference
http://www.neuron.yale.edu/neuron/stati ... edanc.html
and toggle the "full" computation of the impedance

Code: Select all

``compute(loc,1)``
?
There isn't a
compute(loc,1)
as such. The compute method accepts one or two arguments (frequency, or frequency and a second argument which, if set to 1, ensures that the gating states are also taken into account.
If I understand the explanation in the programmers manual correctly the toggle has to be used when the membrane contains voltage-gated conductances? (in passive membranes there is no difference, correct?
You can always call compute() with a single argument if, as an experiment, you want to ignore the effect of the dynamics of the gating states. The results will be identical if the model is passive.
OJAG
Posts: 34
Joined: Wed Nov 14, 2007 4:46 am
Location: Bogota

### Re: computing impedances...

Hi Ted!

A couple of years ago I started this posting, and right now I have to repeat some of my simulations, The question now is: Since my model is a single compartment with just a soma, and given that the transfer impedance is a function of the relative position between the application and measurement point. What is neuron computing by using the impedance tool (plot -> transfer impedance) since there is no second compartment?
2.) I still don't understand why the transfer impedance tool runs even before running the simulation and depends on the instantaneous voltage of the membrane?

ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

OJAG wrote:What is neuron computing by using the impedance tool (plot -> transfer impedance) since there is no second compartment?
If you inject current I_A at point A and measure voltage V_B at point B, the transfer impedance is V_B/I_A. If A and B happen to be at the same location, the ratio V_B/I_A is the input impedance at that location.
I still don't understand why the transfer impedance tool runs even before running the simulation
Good question. Executing model setup code causes the creation of a "system matrix" that describes the relationship between the dependent and independent variables in a model. That matrix, which exists even before a simulation has been run, can be used by the Impedance class without you having to run a simulation.
and depends on the instantaneous voltage of the membrane?
Another good question. In the course of a simulation, voltage- and ligand-gated channels will open and close. This affects the elements in the system matrix, and causes impedance to change during a run.

Finally, I should mention that a model with voltage- or ligand-gated channels, or time-varying ionic conductances, should always be initialized _before_ impedance is calculated.
asb
Posts: 20
Joined: Mon Apr 25, 2016 5:25 am

### Re: computing impedances...

Hi Ted,

I have a question about measuring impedance that relates somewhat to this thread.

I have previously used a zap current to measure impedance but prefer the convenience of neuron's built in tool. However, I am interested in looking at impedance at both 'near' and sub-threshold potentials (ie, using a fixed holding current, followed by a sinusoidal input in addition). This may be a silly question, but is it possible to change the initial conditions at which the impedance tools performs its measurement? Eg initialise at a given voltage and then calculate? I have played around with both the GUI and on python but could not find an obvious solution.

ted
Posts: 5885
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: computing impedances...

is it possible to change the initial conditions at which the impedance tools performs its measurement? Eg initialise at a given voltage and then calculate?
Absolutely. First I should point out that any model should always be properly initialized before the Impedance tools (or the Impedance class's methods) are used. NEURON's default initialization is equivalent to steady-state initialization of all compartments to the potential specified by v_init. You can do this with the RunControl panel by entering the desired value for v_init into the numeric field next to the Init button, then clicking on Init. Alternatively, you can execute the commands
v_init = your_particular_value
stdinit()
(Python equivalent would be
h.v_init = your_particular_value
h.stdinit()
)
or even more simply
finitialize(your_particular_value)
(Python equivalent
h.finitialize(your_particular_value)
).

Of course, there are many situations for which this is not the initialization that you want, e.g. models that
--have nonuniform resting potential for any reason (such as nonuniform distribution of channels or pumps)
--are used to study how a real cell might respond to current injected at a particular location
--have spontaneous fluctuations of membrane potential (oscillations)
For such cases, you may prefer to use a custom initialization that allows the cell to reach the desired state--or simply launch a simulation and let the cell reach that state on its own. Once it reaches that state, just use the Impedance tools (or the Impedance class's methods) to study the cell.