Neuron code

When Python is the interpreter, what is a good
design for the interface to the basic NEURON
concepts.

Moderator: hines

ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Neuron code

Post by ahmed.hamzah »

I am new user to NEURON ,I am writing a code to stimulate an axon in the middle. the axon has sealed end at both side. I trying to track the concentration of Na and K inside the axon during action potential.
geometry:
L=1[µm]
d=0.1[µm]
cm=1 [uF/cm2]
the initial concentration
{nai0_na_ion = 12}
{nao0_na_ion = 145}
{ki0_k_ion = 140}
{ko0_k_ion = 4}
the current
stim.dur = 0.2 // [ms] duration
stim.amp = 1e-3// [nA] amplitude
here you are my results:
Image
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

this is my code
create soma

soma {
nseg = 10000
L = 1// [µm] length
diam = 0.1 // [µm] diameter


insert hh
gnabar_hh = 0.120 // [S/cm^2]
gkbar_hh = 0.036 // [S/cm^2]
glbar_hh = 0.0 // [S/cm^2]
cm=1 // [uF/cm2]
Ra=89.9 //ohm cm
insert nadifl
insert kdifl
insert enae
insert eke
{nai0_na_ion = 12}

{nao0_na_ion = 145}
{ki0_k_ion = 140}

{ko0_k_ion = 4}
}

// stimulating current
objref stim
soma stim = new IClamp(0.5)
stim.del = 0 // [ms] delay
stim.dur = 0.2 // [ms] duration
stim.amp = 1e-3// [nA] amplitude

// simulation time course
// set initial conditions
dt = 0.05
tstop = 5
finitialize(-68)

proc integrate() {
print t, soma.v(0.5)

while (t < tstop) {
fadvance()

print t, soma.v(0.5) // show present time

}
}
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

can you please check the results for me ?
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Neuron code

Post by ramcdougal »

This is probably not doing what you meant to do, although I'm not entirely sure what your question is.

The following HOC code (did you want to use Python instead of HOC?)

Code: Select all

soma {
nseg = 10000 
L = 1// [µm] length
diam = 0.1 // [µm] diameter
creates a single section called soma with total length of just L=1 micron, divided into 10,000 pieces each 0.1 nm long. Perhaps you meant something more like L=1001 nseg=1001?

I'm guessing your mechanisms enae or eke are accumulation mechanisms for sodium and potassium that make their concentrations change in response to the currents? If so (and I realize this may be the point of your investigation), keep in mind that without a pump or other stabilization mechanism, after a sufficiently long period of time of continuous firing, the intracellular potassium concentration will increase and the sodium concentration will decrease to the point where the cell is no longer able to fire.

Instead of printing out the membrane potentials at each time step, it's probably better to use a Vector to record the state variables (potentials, concentrations, etc) that you're interested in so that you can analyze and plot them later.

A few other hints:
  • Start with simple models (e.g. can you record an action potential for a single compartment cell with Hodgkin-Huxley channels?) before proceeding to more complicated ones, especially if your just learning a tool.
  • You generally want to use an odd value for nseg because that allows you to easily refine your discretization (by increasing nseg by a factor of 3) and preserve all the previous node locations so you can check for convergence.
  • An axon with diameter 0.1 microns is possible, but smaller than most.
  • Since this is the NEURON + Python forum, I would be remiss if I didn't point out that there is a tutorial about using Python (as opposed to HOC) to do things like this at: https://neuron.yale.edu/neuron/static/d ... tick1.html
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Neuron code

Post by ted »

You generally want to use an odd value for nseg
For more about this, and how to choose an appropriate value for nseg, see Use an odd value for nseg viewtopic.php?f=28&t=3637
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

Thank you for the comments. I meant can anyone check whether the result make sense or not.
Yes, the mechanism enae and eke to calculate reversal sodium and potassium, and mechanism nadifl and kdifl to calculate sodium and potassium longitudinal diffusion ( I do not know the exactly the basic equation for the mechanism nadifl and kdifl and that is what I would like to ask about it also )
If anyone would like me to send this code for him to check I will do it, and this is the purpose of my post because I am new user for NEURON.
In regard to the dimension I need to create a huge change of concentration so I have chosen the small dimension
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Neuron code

Post by ramcdougal »

The equations for nadifl and kdifl are in the mod files that you're using; they're not part of NEURON itself. Without seeing them, they are likely to just be LONGITUDINAL_DIFFUSION based mechanisms, possibly with radial diffusion as well.

If by "small dimension" you're talking about the 0.1 microns for the diameter of a thin axon, okay. If you're talking about the 1/10000 microns = 0.1 nm length for the segments, that's way too small. You're discretizing into pieces that are thinner than a hydrogen atom.
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

Did you mean that LONGITUDINAL_DIFFUSION
del C/del t=del2 C/del2 x
so it is just Fick's second law.
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Neuron code

Post by ramcdougal »

Not having seen your nadifl.mod, it's impossible to say for certain, but if we consider this file of the same name, the interesting part is the KINETIC block:

Code: Select all

KINETIC conc {
	COMPARTMENT PI*diam*diam/4 {nai}
	LONGITUDINAL_DIFFUSION D {nai}
	~ nai << (-ina/(FARADAY)*PI*diam*(1e4))
}
The COMPARTMENT line indicates the volume per unit length (this will be needed later). The second line indicates that nai exhibits one dimensional diffusion at a rate D (in that file 0.6 um2/ms by default via Fick's law). The third line scales the current per unit area by the surface area (per unit length) and turns it into a change of mass for nai. Together with the COMPARTMENT specification of the volume per unit length, this finally turns into a change in concentration.

Note that with a total length of only 1 micron, diffusion will ensure a near-uniformity of concentration. Note also that if you have a line like the ~nai line that converts currents to changes in concentration, you cannot include another mechanism that does the same thing. NEURON by default updates reversal potentials (here, ena) for you whenever the corresponding concentrations (here, nai) are updated in a mod file.
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

thanks for explanation. that means the basic equation is Fick's second law,because I am looking for the differential equation that has been used to find the concentration in nadifl. You can find it here:
https://en.wikipedia.org/wiki/Fick%27s_ ... _diffusion
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

Anyone can help me to do Na/K restoration process, which pushes the concentrations back to equilibrium, because right now the sodium and potassium go up at a certain time and stay constant. is there mechanism to push them back to the resting value.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Neuron code

Post by ted »

that means the basic equation is Fick's second law
Actually the basic equation is conservation of mass. Rewriting in english
rate of change of total mass of solute S in compartment C = (sum of all fluxes of S into C)/(volume of C)
Diffusion is only one of many possible mechanisms that can generate a flux of S.
right now the sodium and potassium go up at a certain time and stay constant. is there mechanism to push them back to the resting value
This is a two step search process.
First step: Go to ModelDB
https://senselab.med.yale.edu/modeldb/default.cshtml
and use its search box to look for
WRITE nai
or
WRITE ki
You'll get a lot of hits, most of which aren't useful.

Which is why there's a second step.

Second step: Use your browser to search the hits for the exact string
WRITE nai
or
WRITE ki
Case is important! Avoid any hits that
WRITE Nai
or
WRITE Ki
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

Thank you Ted.
I am trying to add calcium to my code but when drew the calcium concentration with time there is no curve show up in the graph.


insert hh
gnabar_hh = 0.120 // [S/cm^2]
gkbar_hh = 0.036 // [S/cm^2]
glbar_hh = 0.0003 // [S/cm^2]
gcabar_hh = 0.32 // [S/cm^2]
cm=1 // [uF/cm2]
Ra=89.9 //ohm cm
insert nadifl
insert kdifl
insert cadifl
insert enae
insert eke
insert ecae
{nai0_na_ion = 12}

{nao0_na_ion = 145}
{ki0_k_ion = 140}

{ko0_k_ion = 4}
{cai0_ca_ion = 10}

//{cao0_ca_ion = 1e-4}
{cai0_cadifus = 1e-5}
}

// stimulating current
objref stim
soma stim = new IClamp(0.5)
stim.del = 0 // [ms] delay
stim.dur = 0.2 // [ms] duration
stim.amp = 50e-3// [nA] amplitude

// simulation time course
// set initial conditions
dt = 0.05
tstop = 5
finitialize(-68)

proc integrate() {
print t, soma.v(0.5)

while (t < tstop) {
fadvance()

print t, soma.v(0.5) // show present time

}
}

and this is my cadifl.mod
COMMENT
Longitudinal diffusion of sodium (no buffering)
(equivalent modified euler with standard method and
equivalent to diagonalized linear solver with CVODE )
ENDCOMMENT

NEURON {
SUFFIX cadifl
USEION ca READ ica WRITE cai
RANGE D
}

UNITS {
(mM) = (milli/liter)
(um) = (micron)
FARADAY = (faraday) (coulomb)
PI = (pi) (1)
}

PARAMETER {
D = .6 (um2/ms)
}

ASSIGNED {
ica (milliamp/cm2)
diam (um)
}

STATE {
cai (mM)
}

BREAKPOINT {
SOLVE conc METHOD sparse
}

KINETIC conc {
COMPARTMENT PI*diam*diam/4 {cai}
LONGITUDINAL_DIFFUSION D*PI*diam*diam/4 {cai}
~ cai << (-ica/(FARADAY)*PI*diam*(1e4))
}

and this is a ecae.mod
COMMENT
Longitudinal diffusion of sodium (no buffering)
(equivalent modified euler with standard method and
equivalent to diagonalized linear solver with CVODE )
ENDCOMMENT

NEURON {
SUFFIX ecae
USEION ca READ cai,cao WRITE eca
RANGE F1
}

UNITS {
(mM) = (milli/liter)

(mV)=(millivolt)



}

PARAMETER {

F1=25.247 (mV)

}

ASSIGNED {
cai (milli/liter)
cao (milli/liter)

}

STATE {
eca (mV)
}

BREAKPOINT {

eca=F1*log(cao/cai)

}

Can any one help me please
ramcdougal
Posts: 267
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Public Health

Re: Neuron code

Post by ramcdougal »

Note that Hodgkin and Huxley considered only the role of sodium, potassium, and leak currents. In particular, it follows that the hh mechanism does not generate a calcium current.
ahmed.hamzah
Posts: 49
Joined: Thu Jun 07, 2018 10:57 am

Re: Neuron code

Post by ahmed.hamzah »

So in this case I have to create file.mod to calculate calcium current . Is there example I can use it for this purpose ?
Post Reply