intracellular K depletion and extracellular K accumulation

NMODL and the Channel Builder.
Post Reply
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

intracellular K depletion and extracellular K accumulation

Post by auatai »

Hi ,

I am trying to create a mechanism that reads the potassium current ik and computes the values of ki and ko. What i also require is that ik should also be dependent on the newly modified values of ik and ko. The model that I have in mind is a single compartment soma(with a certain initial potassium concentration ki_initial) enveloped by a fixed volume of extracellular space (again with a certain initial potassium concentration ko_initial).

I looked at the potassium accumulation mechanism kext described in Example 6. I have two queries

First, would I be right in updating the values of ko and ki by using the same code as example 6, with the following changes:-

(a) I change the USEION statement so that it reads ik and writes ki,ko. I also add ki in the state block.
(b) I select the thickness of fh space so that I get the extracellular space volume that i desire (which is approx 20% of the volume of the soma in my case).
(c) I disregard the kbath by removing the second term from the following equation in the derivative block
ko' = (1e8)*ik/(fhspace*FARADAY) + (kbath - ko)/txfer
(c) I add another equation for intracellular K depletion as follows
ki' = (1e8)*(-ik)/(fhspace*FARADAY)

Second, how do i ensure that ik itself depends on the changed concentrations of ki and ko ?

thanks in advance
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: intracellular K depletion and extracellular K accumulation

Post by ted »

auatai wrote:(a) I change the USEION statement so that it reads ik and writes ki,ko. I also add ki in the state block.
(b) I select the thickness of fh space so that I get the extracellular space volume that i desire (which is approx 20% of the volume of the soma in my case).
(c) I disregard the kbath by removing the second term from the following equation in the derivative block
ko' = (1e8)*ik/(fhspace*FARADAY) + (kbath - ko)/txfer
(c) I add another equation for intracellular K depletion as follows
ki' = (1e8)*(-ik)/(fhspace*FARADAY)
You're on the right track.

The USEION statement should be changed as you noted.

But ki would not be declared a STATE. Your k accumulation mechanism is a closed system in which ko and ki are not independent variables. If one is governed by an ODE, the other is dictated by a simple algebraic equation. So if you preserve the ODE for ko (omitting, as you remarked, exchange between "bath" and extracellular space), then ki becomes an ASSIGNED, not a STATE.

If I were you, I'd declare two new PARAMETERs ki0 and ko0 that specify initial ki and ko, and a third PARAMETER rho that specifies the ratio (vol that contains extracellular k)/(intracellular vol).

Then total k is
ki*section_volume + ko*rho*section_volume = ki0*section_volume + ko0*rho*section_volume
With rearrangement this gives
ki = (ki0 + ko0*rho) - ko*rho
which suggests declaring an ASSIGNED kx and adding an INTIAL block that contains this statement
kx = ki0 + ko0*rho

The contents of the BREAKPOINT block then become
SOLVE state METHOD cnexp
ki = kx - ko*rho
how do i ensure that ik itself depends on the changed concentrations of ki and ko ?
Happens automatically. In a section that has an ion accumulation mechanism (a mechanism that contains a USEION statement that WRITEs an intra- and/or extracellular concentration), NEURON by default will use the Nernst equation to calculate a new equilibrium potential for that ion at each time step. Every mechanism that WRITEs a current that depends on that equilibrium potential will be affected by this. And every mechanism that WRITEs a current that depends on the GHK relationship for that ion will also be affected, as will every transport mechanism (pump or exchange, whether electroneutral or not) that generates a flux that depends on the concentration of that ion.
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Thank you sir. I really appreciate the promptness and detail, of the reply
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: intracellular K depletion and extracellular K accumulation

Post by ted »

In my haste, I omitted the following:
declare two new PARAMETERs ki0 and ko0 that specify initial ki and ko
so the INITIAL block would also contain the statements
ki = ki0
ko = ko0

As always, test with modlunit and fix any syntax errors or units inconsistencies that are found, and also test the operation of the mechanism to make sure that it works properly.
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Dear Sir,

1. I made the necessary amendments in the kext.mod file as you had suggested. Here is the kext.mod code

Code: Select all

: Extracellular potassium ion accumulation

NEURON {
	SUFFIX kext
	USEION k READ ik WRITE ko,ki
	RANGE fhspace
}

UNITS {
	(mV) = (millivolt)
	(mA) = (milliamp)
	FARADAY = (faraday) (coulombs)
	(molar) = (1/liter)
	(mM) = (millimolar)
}

PARAMETER {
	fhspace = 300 (angstrom) : effective thickness of F-H space
	ki0	= 54.4  (mM)		:	Initial K Conc within the section
	ko0	= 3	  (mM)		:	Initial K conc in Extracellular space
	rho	= 0.2   (1)			: 	Ratio of ECS volume to section volume
	kx	(mM)
}

ASSIGNED { 
	ik (mA/cm2)
	ki (mM) 
	}

INITIAL {
	ki = ki0
	ko = ko0
	kx = ki0 + ko0*rho
}
STATE { ko (mM) }

BREAKPOINT { 
	SOLVE state METHOD cnexp 
	ki = kx - ko*rho
}

DERIVATIVE state {
	ko' = (1e8)*ik/(fhspace*FARADAY) 
}
However, on compiling the mechanism I get the following error

Code: Select all

Translating kext.mod into kext.c
ki is WRITE but is not a STATE and has no assignment statement at line 44 in file kext.mod
^
make: *** [kext.o] Error 1
Where have I gone wrong? Isn't the statement ki = kx - ko*rho
in the breakpoint block an assignment statement?

Thanking you in advance.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: intracellular K depletion and extracellular K accumulation

Post by ted »

Well, as far as I can tell, you were just doing what I suggested. Here's how I proceeded to diagnose and fix the problems.

1. Checked the code with modlunit (was OK), then tried compiling it and got the same error message you did.
2. Changed the SUFFIX to kacc because it does both intra- and extracellular k accumulation, which makes it not quite the FH mechanism any more. Also eliminated the fhspace parameter, which is no longer pertinent, but made the rho parameter a RANGE variable. Moved the declaration of kx from the PARAMETER block to the ASSIGNED block, because it isn't really a parameter set by the user--it's an "intermediate variable" with a value that is calculated at initialization. Changed the value of ko0 to 2.5 because I would be testing this with the HH mechanism, for which extracellular k is 2.5 mM.
3. Changed the ODE for ko in the DERIVATIVE block to be appropriate for this new k accumulation mechanism.
Ignoring scale factors for the moment,
ko' = ik * membrane area / (extracellular volume * FARADAY)
membrane area = PI*diam*L, extracellular volume = PI*diam^2*L/4, so the ODE should be
ko' = 4 * ik / (rho * diam * FARADAY)
This necessitated declaring diam in the ASSIGNED block (NMODL allows mechanisms to discover the diameter of the segment in which they exist--and the diameter variable is called diam, but it must be declared as an ASSIGNED in order to be used).
4. Checked units with modlunit and found that the ODE needed a scale factor of (1e4)*(). Made that change.
ko' = (1e4) * 4 * ik / (rho * diam * FARADAY)
5. Ran nrnivmodl and got the error msg
ki is WRITE but is not a STATE and has no assignment statement at line 54 in file kacc.mod
even though the BREAKPOINT block contained the assignment statement
ki = kx - ko*rho
Stared at that for a while, then decided to try moving the assignment statement to the DERIVATIVE block--that is,

Code: Select all

BREAKPOINT { 
	SOLVE state METHOD cnexp 
}
DERIVATIVE state {
	ko' = (1e4)*4*ik/(rho*diam*FARADAY)
	ki = kx - ko*rho
}
6. Ran modlunit again--OK again. Ran nrnivmodl and it compiled without problem.
7. Used the GUI to make a single compartment model that contained both hh and kacc, attached an IClamp, created a couple of graphs (v, ki, ko), set the IClamp to trigger 1 spike, and ran a simulation.
Result: ki goes from 54.4 to 54.34, ko goes up from 2.5 to 2.80. Ratio of concentration changes is 0.3/0.06 = 5, which is exactly what should happen when rho is 0.2. I'll email you the mod and ses files so you can try it for yourself.

So my initial suggestions for how to revise the code weren't entirely correct, but at least pointed in the general direction of a correct solution. And now you see another example of how to get code working. Here's the mod file for anyone else who may be interested in the final result:

Code: Select all

COMMENT
k moves between intra- and extracellular volumes.
Extracellular volume is a specified fraction rho of intracellular volume.

Strategy A.  ko state, ki assigned in the BREAKPOINT block.
nrnivmodl exits with error msg:
ki is WRITE but is not a STATE and has no assignment statement at line 54 in file kacc.mod
?? But the BREAKPOINT block contains the assignment statement
ki = kx - ko*rho

Strategy B.  ko state, ki assigned in the DERIVATIVE block.
This works.
ENDCOMMENT

NEURON {
	SUFFIX kacc
	USEION k READ ik WRITE ko,ki
	RANGE rho
}

UNITS {
	(mV) = (millivolt)
	(mA) = (milliamp)
	FARADAY = (faraday) (coulombs)
	(molar) = (1/liter)
	(mM) = (millimolar)
}

PARAMETER {
	ki0	= 54.4  (mM)		:	Initial K Conc within the section
	ko0	= 2.5	  (mM)		:	Initial K conc in Extracellular space
	rho	= 0.2   (1)		: 	Ratio of ECS volume to section volume
}

ASSIGNED { 
	ik (mA/cm2)
  diam (micron)
  kx	(mM)
  ki (mM)
}

INITIAL {
	ki = ki0
	ko = ko0
	kx = ki + ko*rho
}

STATE {
  ko (mM)
}

BREAKPOINT { 
	SOLVE state METHOD cnexp 
}

DERIVATIVE state {
	ko' = (1e4)*4*ik/(rho*diam*FARADAY)
	ki = kx - ko*rho
}
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Dear Sir,

Thank you once again. I have started understanding NMODL a little better now, all because of you.
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Dear Sir,

The Potassium accumulation mechanism is working as desired. Many thanks for the same.

Now, moving ahead, my next step is to implement a sink which is attached to the extracellular space(ECS) and sucks out the accumulated K+ from the ECS. However the efficiency of sucking out is to be inversely proportional to the amount of K+ that has already been sucked out. So, initially when the simulation starts, I assume that the K+ conc in the sink (lets say ks) is zero and the sink draws out K+ at a fast rate, however as time passes, and ks rises, the efficiency of extrusion reduces(As an afterthought , if I set ks initially to zero it would draw out the existing k+ in the ECS, so maybe i'll need to set ks initially to ko). And all the while, I would like to monitor the values of ki, ko and ks

To achieve this, I again used the kacc mechanism as a base and followed the reasoning that you had used. (At this point I want to confess that I am not very good at differential equations so maybe I have gone totally wrong)

1. For sake of simplicity, I assumed that the vol of the sink was again a multiple of the section volume (lets say rhosnk) and declared rhosnk as a PARAMETER.

2. I also declared ki0,ko0 and ks0 as PARAMETERs and initialized them in the INITIAL block.

3. Then, for maintaing total k constant in the system i used the relation
ki*section_volume + ko*rho*section_volume + ks*rhosnk*section_volume = ki0*section_volume + ko0*rho*section_volume + ks0*rhosnk*section_volume
which yields
ki = (ki0 + ko0*rho + ks0*rhosnk) - ko*rho - ks*rhosnk
and
ks=[(ki0 + ko0*rho + ks0*rhosnk) - ko*rho - ki] / rhosnk

4. Next step was to declare an ASSIGNED kx and adding into the INITIAL block the statement
kx = ki0 + ko0*rho + ks0*rhosnk

5. Now, to set up the flow of k from ECS to sink, I declared a new current iks (mA/cm2) in the ASSIGNED block. Since iks exists between the ECS and sink, i assumed its effect on ko would be dictated by
ko' = (-) iks * surface area of ECS shell / (sink volume * FARADAY) {ignoring scale factors)
surface area of ECS shell = PI*diam*L*sqrt(1+rho) {since diameter of ECS shell is sqrt(1+rho) times diam of section}
sink volume = PI*diam^2*L*rhosnk/4
which yields,
ko' = (-) iks * 4 * sqrt(1+rho) / (rhosnk * diam * FARADAY)
Adding the scale factor of (1e4) i get
ko' = (-) (1e4)*iks * 4 * sqrt(1+rho) / (rhosnk * diam * FARADAY)

6. Next, I amended the DERIVATIVE block to include

ko' = (1e4)*4*ik/(rho*diam*FARADAY) - (1e4)*iks*4*sqrt(1+rho)/(rhosnk*diam*FARADAY)
ki = kx - ko*rho - ks*rhosnk
ks= (kx - ko*rho - ki)/rhosnk

so my mod file is as below

Code: Select all

    

NEURON {
  SUFFIX kacc
  USEION k READ ik WRITE ko,ki
  RANGE rho,rhosnk,ks
}

UNITS {
  (mV) = (millivolt)
  (mA) = (milliamp)
  FARADAY = (faraday) (coulombs)
  (molar) = (1/liter)
  (mM) = (millimolar)
}

PARAMETER {
  ki0   = 54.4  (mM)     :   Initial K Conc within the section
  ko0   = 2.5   (mM)     :   Initial K conc in Extracellular space
  ks0   = 0   (mM)      :   Initial K conc in Sink
  rho   = 0.2   (1)      :    Ratio of ECS volume to section volume
  rhosnk = 2   (1)      :   Ratio of Sink Volume to section volume
}

ASSIGNED {
  ik (mA/cm2)
  iks (mA/cm2)
  diam (micron)
  kx   (mM)
  ki (mM)
  ks (mM)
}

INITIAL {
  ki = ki0
  ko = ko0
  ks = ks0
  kx = ki + ko*rho + ks*rhosnk
}

STATE {
  ko (mM)
}

BREAKPOINT {
   SOLVE state METHOD cnexp
}

DERIVATIVE state {
  ko'=(1e4)*4*ik/(rho*diam*FARADAY)-(1e4)*iks*4*sqrt(1+rho)/(rhosnk*diam*FARADAY)
  ki=kx-ko*rho-ks*rhosnk
  ks=(kx-ko*rho-ki)/rhosnk
}

Now the queries,
1. The mod file did compile correctly but the change in ki and ko was exactly as before. It seems that iks had no effect at all. I did suspect this to happen because at no place have i defined iks. So how do I do this ? Can I do it within the same mod file or will i have to use another mechanism

2. Secondly, I would like to define iks in such a way that it should reduce as ks increases, so how can I incorporate this behaviour into the definition of iks.

3. Am i correct in trying to model the behaviour of an attached sink by using a current iks, because it also occurred to me that I could consider the sink as a bath(as in example 6) with initial k conc as zero, so that k would diffuse from ECS to bath. But then how would i be able to control the rate of diffusion from the ECS to the sink.

I am sorry if I am bothering you with trivial questions but would greatly appreciate any help or some guidelines if possible.

best regards
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: intracellular K depletion and extracellular K accumulation

Post by ted »

Sorry I haven't had the opportunity to get back to your latest question until now.

Your development is sound through "4. Next step was to declare an ASSIGNED kx . . . "

Where it starts to go wrong is in "5. Now, to set up the flow of k from ECS to sink, I declared a new current iks . . . " Instead, keep everything in terms of concentration.

So introduce a new DE for ks into the DERIVATIVE block
ks' = (ko - ks)/taus
where the PARAMETER taus (in milliseconds) is the time constant for equilibration between the sink and the space immediately adjacent to the membrane.
And change the DE for ko to
ko' = (1e4)*4*ik/(rho*diam*FARADAY) + (ks-ko)/taus

. . . assuming, of course, that I haven't made another mistake
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Thank you sir,

Actually, even I by myself had employed similar suggestions as given by you but was not sure whether I was doing it right. Your post has reassured me that I was on the right track. However the behavior is still not as I desired, so I am trying to work out another way of doing it. In case I get stuck I shall post my doubts again.

thanks once again
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: intracellular K depletion and extracellular K accumulation

Post by ted »

And if you don't get stuck, please be sure to tell me how you solved the problem.
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Dear Sir,
as always, I am STUCK again.Let me tell you what i did to test the model

First I implemented Accumulation in ECS, depletion in ICS and diffusion to a constant volume sink using the relations given below
ko'=(1e4)*4*ik/(rho*diam*FARADAY)+(ks-ko)/taus
ks'=(ko-ks)/taus
ki=kx-ko*rho-ks*rhosnk
where,
kx = ki + ko*rho + ks*rhosnk

Next, I created a simple cell with just a single compartment of diam=18.8 and L=18.8 and inserted the mechanism into the soma and ran a simulation for 10s

I found that even without adding a current clamp there was a spike initially itself and an almost constant ik started flowing.About 1.2seconds later, automatic regular spiking of gradually decreasing magnitude started appearing which died down within about a second. Meanwhile , when I plotted ki and ko, i saw that ki decreased very gradually initially from the initial level of 54.4 mM and then when the automatic spiking started it reduced rapidly and continued to reduce even when the automatic spiking had stopped. Similarly the opposite happened in case of ko and finally after some time both of them became almost equal.

What i actually wanted from my model was:
1. Whenever there is an action potential, K should flow from within the section to ECS which would cause ko to increase.
2. This increase of ko would gradually reduce due to diffusion into a sink.
3. K should not flow across the membrane when no action potential is applied.

But the present model causes K from within the section to flow out even in the absence of spikes. How can i correct this?

I tried doing it by defining ki as a state variable which is only dependent on ik by using the relation ki' = -(1e4)*4*ik/(diam*FARADAY) but even then the result was similar. Would greatly appreciate if you can tell me where have i gone wrong.
Here is the mod file

Code: Select all

    NEURON {
      SUFFIX kdiff
      USEION k READ ik WRITE ko,ki
      RANGE rho,rhosnk,ks,taus
    }

    UNITS {
      (mV) = (millivolt)
      (mA) = (milliamp)
      FARADAY = (faraday) (coulombs)
      (molar) = (1/liter)
      (mM) = (millimolar)
    }

    PARAMETER {
      ki0   = 54.4  (mM)     :   Initial K Conc within the section
      ko0   = 3   (mM)     :   Initial K conc in Extracellular space
      ks0   = 3   (mM)      :   Initial K conc in Sink
      rho   = 0.2   (1)      :    Ratio of ECS volume to section volume
      rhosnk = 1   (1)      :   Ratio of Sink Volume to section volume
	  taus	= 50 (ms)		: Time constant for diffusion from ECS to sink
    }

    ASSIGNED {
      ik (mA/cm2)
      diam (micron)
      kx   (mM)
      ki (mM)
	  :ks
    }

    INITIAL {
      ki = ki0
      ko = ko0
      ks = ks0
      kx = ki + ko*rho + ks*rhosnk
    }

    STATE {
      ko (mM)
	  ks (mM)
	  :ki (mM)
    }

    BREAKPOINT {
       SOLVE state METHOD cnexp
    }

    DERIVATIVE state {
      ko'=(1e4)*4*ik/(rho*diam*FARADAY)+(ks-ko)/taus
      ki=kx-ko*rho-ks*rhosnk
	  :ki' = -(1e4)*4*ik/(diam*FARADAY)
      ks'=(ko-ks)/taus
	  :ks=(kx-ko*rho-ki)/rhosnk
    }

Here is the hoc code that i used

Code: Select all

load_file("nrngui.hoc") 

create soma
soma {
 nseg = 1
 diam = 18.8
 L = 18.8
 Ra = 123.0
 insert hh
 insert kdiff 
 }
ko0_k_ion = 3        //To initialize ko to 3 mM
ki0_k_ion = 65.28  // To preserve ek
finitialize(v_init)
tstop = 10000
objectvar stim,kgr,vgr,ikgr
soma stim = new IClamp(0.5)
/*
stim.del = 100
stim.dur = 300
stim.amp = 0.15
*/
// show ki,ko,ks plot
kgr=new Graph()
kgr.size(0,tstop,-0.0001,55)
kgr.xaxis() kgr.yaxis()
kgr.addvar("soma.ki(0.5)",2,0) 
kgr.addvar("soma.ko(0.5)",3,0)
kgr.addvar("soma.ks_diff(0.5)",4,0)
kgr.save_name("graphList.")
graphList.append(kgr)

// show volt spikes	
vgr=new Graph()
vgr.size(0,tstop,-90,60)
vgr.xaxis() vgr.yaxis()
vgr.addvar("soma.v(0.5)",1,0)
vgr.save_name("graphList.")
graphList.append(vgr)

// show ik plot	
ikgr=new Graph()
ikgr.size(0,tstop,-0.1,1)
ikgr.xaxis() ikgr.yaxis()
ikgr.addvar("soma.ik(0.5)",1,0)
ikgr.save_name("graphList.")
graphList.append(ikgr)
nrncontrolmenu()
run()
thanking you in advance
auatai
Posts: 29
Joined: Mon Sep 14, 2009 6:33 am

Re: intracellular K depletion and extracellular K accumulation

Post by auatai »

Dear Sir,

I was experimenting with the model for potassium accumulation which had been initially discussed in this post. The one in which accumulation is implemented in the ECS alongwith corresponding depletion in ICS. You had helped me out with the framing of the equations controlling ki and ko and had sent me the mod file along with rig.hoc to test it out.

Today, I ran the rig.hoc file keeping the amplitude of IC clamp as zero and simulated for 10s. I found that even without any action potentials being given there was automatic spiking occuring at around 1s and ki and ko kept reducing and increasing as time passed.

Isn't something wrong with the mechanism. Because I thought that there should be influx/efflux of K only when there is a spike but here it is happening by itself.

Waiting for your reply

Hi again,

Actually, I tried experimenting a little more. I declared ek as an assigned variable and in the Neuron block I put ek in the Read and Write part. I then included the statement v=ek in the Breakpoint block and this caused the automatic spiking to finish off. But all the same the values of ko and ki continued to rise and fall gradually even in the absence of any action potentials. So i plotted ik and observed that ik remained at a positive value(0.00453082) all through the simulation and I guess this is what must have been causing the steady exodus of K from within the cell.

So, after toying around with trying to set ik as zero and in the absence of any better idea, i did the following. I amended the ko' equation as
ko' = (1e4)*4*(ik-0.00453082)/(rho*diam*FARADAY)

Now, on observing the output, i saw that firstly there was no automatic spiking and also there was no gradual change in ki and ko in the absence of any inputs.

Thereafter, I applied some action potentials into the cell and thankfully ki and ko responded the way they should have and once the spiking stopped, they stabilized at the last attained values for the rest of the simulation.

I am yet to implement diffusion from ECS into the sink.Will be doing that today.

But , I would be really grateful if you could comment on the validity of the method adopted by me.

Sorry for being verbose, I know your time is valuable.

Best Regards
Post Reply