Using Impedance Class for model with Ca accumulation

Managing anatomically complex model cells with the CellBuilder. Importing morphometric data with NEURON's Import3D tool or Robert Cannon's CVAPP. Where to find detailed morphometric data.
Post Reply
Darshan
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Using Impedance Class for model with Ca accumulation

Post by Darshan »

Hi Ted,

I have a model with calcium accumulation mechanism. I wanted to measure transfer impedance at different locations of the cell using the Impedance class. While doing so I get a following error:

Code: Select all

cmplx_spFactor error: Singular
The model does not have the extracellular and LinearMechanism. According to the warning in the documentation for Impedance.compute() (https://www.neuron.yale.edu/neuron/stat ... ce.compute) :

Code: Select all

the typical way NEURON deals with ionic concentration coupling to current is not handled.
Does that mean that the Impedance class cannot be used with models having ion accumulation mechanisms and transfer impedance has to be calculated manually using current injection and recording at different x's?

I also tried with the a toy model with inserting capmp.mod (from NEURON's library) along with the code given here this post: viewtopic.php?t=3515#p14919 and got the same error.

Thanks,
Darshan
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using Impedance Class for model with Ca accumulation

Post by ted »

The error you encountered has nothing to do with the presence of an ion accumulation mechanism. Impdedance.compute can be used in models that have ion accumulation mechanisms. The point of the "Warning" is to bring a potential source of error to the reader's attention. Whether this particular error is significant or not in any particular model depends on the details of the model and is an empirical question--one that could be resolved by a computational experiment, similar to what you proposed: calculating impedance by injecting current and recording the resulting voltage. Keep in mind the fact that every model that does not include ion accumulation for each and every ionic species that crosses the cell membrane is itself full of potential sources of error. And for those few ionic species whose concentrations are state variables, in most cases it seems likely that the amplitude of ionic concentration changes is either small and characterized by a very slow time course compared to the amplitude and frequency of interesting fluctuations of ion channel conductances, or limited to a very small spatial extent and therefore negligible to everything else that may be going on in a piece of neurite that is more than a few microns long. Possible exceptions include very small structures such as spine necks and heads.
I also tried with the a toy model with inserting capmp.mod (from NEURON's library) along with the code given here this post: viewtopic.php?t=3515#p14919 and got the same error
I see the code in the Forum, but am not sure what constitutes the toy model you mention.
Darshan
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Re: Using Impedance Class for model with Ca accumulation

Post by Darshan »

Thanks Ted for the detailed explanation for the "Warning". I will look into my model for the source of that error.

Below is the code I used for the toy model:

Code: Select all

load_file("nrngui.hoc")

v_init=-65
create soma
soma{
	nseg =9

	insert hh
	insert cachan
	insert capr
}

finitialize(v_init)

objref zz
zz = new Impedance()
FREQ = 0 // Hz
WHERE = 0.5 // location in the soma that is the reference point
soma distance(0, WHERE)  // sets origin for distance calculations

proc calcZ() {
  soma zz.loc(WHERE)  // sets origin for impedance calculations
  zz.compute(FREQ, 1) // takes the impedance contributions of 
                      // gating state differential equations into account
                      // but requires mechanisms to be compatible with CVODE
  print "x distance(x) input(x) input_phase(x) transfer(x) transfer_phase(x) ratio(x)"
  forall {
    print secname()
    for (x) print x, distance(x), zz.input(x), zz.input_phase(x), zz.transfer(x), zz.transfer_phase(x), zz.ratio(x)
  }
}

calcZ()
The mechanisms capmp.mod and cachan.mod are from NEURON's library. If I comment out "insert capr", the code works properly. I get the error even if I don't have hh and cachan in the model.

The error is:

Code: Select all

C:\nrn\bin\nrniv.exe: cmplx_spFactor error: Singular
 in C:/Users/Darshan/Desktop/pumptest/toymodel.hoc near line 34
 calcZ()
        ^
        Impedance[0].compute(0, 1)
      calcZ()
 calcZ()
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using Impedance Class for model with Ca accumulation

Post by ted »

capr? Is that the mechanism specified by the code in capr.mod, which is used in
Neymotin et al. 2011 modeldb.yale.edu/139421
and Sanjay et al. 2015 modeldb.yale.edu/186768
?
If so, and if capmp.mod is the same as the file nrn/share/examples/nrniv/nmodl/capmp.mod, then you have a model in which two different mechanisms are WRITEing cai in the same section. That's guaranteed to cause trouble. For any ion x, no section should have more than one mechanism that WRITEs xi or xo. Get rid of one of them and see if that fixes your problem.
Darshan
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Re: Using Impedance Class for model with Ca accumulation

Post by Darshan »

Sorry for not being clear on the source of mod files. I obtained the cachan.mod and capmp.mod from C:\nrn\examples\nrniv\nmodl of my NEURON 7.6.2 setup. Also uploaded here: https://drive.google.com/drive/folders/ ... sp=sharing

The SUFFIX in capmp.mod is capr. I don't have capr.mod in the model. The capr.mod files in the 2 modeldb models are different from capmp.mod.

There is only one mechanism capmp.mod which WRITEs cai. I also did not get any error while compiling the mod files which would have been there if the model had 2 or more mechanisms writing the same concentration.
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using Impedance Class for model with Ca accumulation

Post by ted »

Sure enough, a
cmplx_spFactor error
message appears if the the extended impedance calculation is performed on a model that includes capr. No problem happens if the model has hh, or hh and cachan.

capr is not itself an "excitable channel" so I don't see how this could be attributed to the fact that "the extended impedance calculation may involve a singular matrix because of the negative resistance contributions of excitable channels."

A comment about the capr mechanism specified by the NMODL code in capmp.mod--
Although that mechanism WRITEs cai and ica, it does not READ ica. Consequently cai is completely unaffected by the fact that the spikes generated by your model cell's Hodgkin-Huxley mechanism produce significant ica. In fact, cai remains constant throughout the simulation (because it is initialized to the capr mechanism's steady state value).
Darshan
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Re: Using Impedance Class for model with Ca accumulation

Post by Darshan »

Ok. So, there is no change in cai in the model and it may not be the reason for the message. I will try find the source of error.

Meanwhile, I will use a workaround for calculating transfer impedance similar to as discussed in the above posts: injecting current (1 nA) and recording the resulting (peak) voltage at different segments of the model.

Thanks,
Darshan
ted
Site Admin
Posts: 6287
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Using Impedance Class for model with Ca accumulation

Post by ted »

I will use a workaround for calculating transfer impedance similar to as discussed in the above posts: injecting current (1 nA) and recording the resulting (peak) voltage at different segments of the model.
I don't think you'll have to do that. Notice that the error only occurs when FREQ == 0, i.e. DC. With FREQ = 1e-3 (or even 1e-10) the error message does not appear. So if you don't need impedance calculations at 0 Hz, don't bother with FREQ == 0. If you do need impedances at 0 Hz, just go ahead and inject a small current and measure the relevant steady state changes of membrane potential. OR you could

Code: Select all

FREQ = 1
while (FREQ>1e-6) {
  record FREQ
  calculate and record the impedances of interest at this FREQ
  FREQ/=10
}
and then plot the impedances of interest vs. the corresponding FREQs just to verify that they converge to sensible values.
Darshan
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Re: Using Impedance Class for model with Ca accumulation

Post by Darshan »

Thanks for your help, Ted!

Darshan
Post Reply