NMODL files conflict

NMODL and the Channel Builder.
Post Reply
dperakis

NMODL files conflict

Post by dperakis »

Cood evening to everybody!!!
I have written a .mod file which simulates a POINT_PROCESS that accomplish all the activity of a single neuron.
For me to start, I try to connect two of these neurons and I do it using the NetCon. I apply a stimulative current in the first neuron and observe the consequenses on the second one.
The strange is that when I use the same .mod file for the two neurons, the results are different (and for sure wrong as the neuron has a sort of anodal break excitation mechanism) than when I copy the .mod file to another wordpad (exactly the same), save it with a new name and let the second neuron use the "new" .mod file.
It seems as if there is a form of conflict when using the same .mod file.
I present the hoc files:

Code: Select all

load_file("nrngui.hoc")
//-----------------------------------------------------
// setup the cell
create cell_1, cell_2
access cell_1
objref neuron_1, neuron_2, nc1, fresh1
cell_1 neuron_1 = new MECH(0.5)
cell_2 neuron_2 = new MECH(0.5)
//-----------------------------------------------------
// I setup the stimulative current to neuron_1 with -500nA untill 400msec
// and then 0nA till the end of the simulation
fresh1 = new FInitializeHandler("IsendFirst()")

proc IsendFirst(){
	Isend1 (0,-500)
	Isend1 (400, 0)
}
proc Isend1 () {
	sprint(tstr,"neuron_1.I=%g cvode.re_init()",$2)
	cvode.event($1,tstr)
}
//-----------------------------------------------------
// connection() connects the two neurons with neuron_1
// being the source and neuron_2 the target
proc connection () {
  nc1 = new NetCon(neuron_1,neuron_2)
  nc1.delay = 0
  nc1.weight = 0.8
}
//-----------------------------------------------------

connection()

xopen("test2.ses")
The only difference in the second "working" hoc is:

Code: Select all

objref neuron_1, neuron_2, nc1, fresh1, fresh2
cell_1 neuron_1 = new MECH(0.5)
cell_2 neuron_2 = new MECH_NEW(0.5)
Linking the neuron_2 with the new .mod file (which is exactly the same)

The results I take from the two simulations are (jpeg images):
The right one when using the two .mod files
http://www.nikaia-church.gr/neolaia/Perakis/Normal.JPG

and the wrong one when using the single .mod file
http://www.nikaia-church.gr/neolaia/Per ... normal.JPG

Many Thanks in Advance
Last edited by dperakis on Tue Oct 16, 2007 6:33 am, edited 2 times in total.
ted
Site Admin
Posts: 6398
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

Without seeing the mod file's source code there is no way to tell what the problem is, but
here is a guess: does the NMODL code have one or more GLOBAL variables?

The code that you do present raises a couple of issues regarding point processes and
artificial spiking cells. These issues almost certainly have nothing to do with the symptoms
you report, but just in case anyone else ever reads this thread closely:

Artificial spiking cells that have a NET_RECEIVE block, do not need a BREAKPOINT block,
and do not refer to v or any ions or have a POINTER, can use the ARTIFICIAL_CELL
keyword in the NEURON block, instead of the POINT_PROCESS keyword. This tells the
NMODL compiler that the model cell is not to be associated with a section location or
numerical integrator. Since ARTIFICIAL_CELLs do not need to be attached to a section, a
model that consists entirely of such cells can be simulated more efficiently.

Even if your model cells do not satisfy the requirements for use of the ARTIFICIAL_CELL
keyword, if they have their own internal variables and do not affect membrane potential
or ionic currents or concentrations, there is no reason why they could not be attached
to a single section.
dperakis

Post by dperakis »

The .mod file is this:
(Sorry for being too extensive)

Code: Select all

NEURON {
  POINT_PROCESS MECH
  RANGE C,Vr,Vt,k,a_pos,a_neg,b_pos,b_neg,d_pos,Vpeak,ydir,I,spikes,gsyn,erev,tau
}

INITIAL {
  spikes = 0
  vv = -65
  u = 0
  gsyn = 0
  net_send(0,1)
  to = t
}

PARAMETER {
  C  = 70
  Vr = -65
  Vt = -55
  k  = 1
  a
  a_pos = 0.008
  b
  b_pos = 0
  d_pos = 10
  a_neg = 0.0005
  b_neg = 70
  d_neg
  Vpeak = 35
  ydir = 30
  I = 0  
  erev = 0
  spikes
  tau = 30 (ms) : Is the synapse time constant
}

ASSIGNED { 
  gsyn
  to (ms)
}

STATE { u vv } : use vv for voltage so don't interfere with built-in v of cell

BREAKPOINT {
: ---------------------------------------------
: Different response of the model in excitatory
: and inhibitory input
: ---------------------------------------------
  if (vv>=-65) {
	if (u>0) {
		b = b_pos
		a = a_pos
	} else {
		b = b_pos
		a = a_neg
	}
  } else {
	if (u>0) {
		b = b_neg
		a = a_pos
	} else {
		b = b_neg
		a = a_neg
	}
  }
: -----------------------------------------------
  SOLVE states METHOD derivimplicit
: -----------------------------------------------
}
 
DERIVATIVE states {
  vv' = (1/C)* ( k*(vv-Vr)*(vv-Vt) + ydir - u + I - gsyn*(vv-erev))
  u' = a* ( b*(vv-Vr) - u)
}

FUNCTION M() {
  M = gsyn * exp(-(t - to)/tau)  : in order to graph the evolution of gsyn
}

NET_RECEIVE (w) { 
: The contents of the NET_RECEIVE block specify what happens when
: an event is delivered to a point process or artificial spiking neuron. 
  if (flag == 1) {
      WATCH (vv>Vpeak) 2  : Checks for threshold crossing turning flag to 2
  } else if (flag == 2) {
      net_event(t,0)
  : -----------------------------------------------
  : Some terminating conditions and variable update
  : -----------------------------------------------
	if (u>=0) {
		vv = -65 + 0.05*u
		u = u + d_pos
	} else {
		if (u<-60) {
			d_neg = 5
		} else {
			d_neg = 0.75*u + 50
		}
		u = u + d_neg
		vv = -58 + 0.05*u
	}
	spikes = spikes + 1
  } else {						 : synaptic activation
    gsyn = gsyn * exp(-(t-to)/tau)
    gsyn = gsyn + w
    to = t
  }
}
Thanks...
ted
Site Admin
Posts: 6398
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

The strange is that when I use the same .mod file for the two neurons, the results are different (and for sure wrong as the neuron has a sort of anodal break excitation mechanism) than when I copy the .mod file to another wordpad (exactly the same), save it with a new name and let the second neuron use the "new" .mod file.
It seems as if there is a form of conflict when using the same .mod file.
The mod file contains a single syntax error--net_event() takes only one argument.
Also, if C were in pF, the ODE for vv would need a scale factor to reconcile units
inconsistencies.

But after fixing the net_event syntax error, I get identical results regardless of whether the
two point processes are on the same section or on different sections. And there's no "sag"
of the first 400 ms in the presynaptic cell--vv just settles quickly to ~ -82 and stays there
until the end of the "hyperpolarizing current pulse".
dperakis

Post by dperakis »

Finally I found the problem with the code.
First of all I have included in the PARAMETER block some variables that are changing (varied) during the simulation run, succh as II, a, b, d_neg, spikes. So moving them to the ASSIGNED block fixed the first problem.
The second problem was with the gsyn parameter which was not reset to zero after a spiking input. Thus we changed the gsyn in the first differential equation with the function M().
With these two modifications the problems are really fixed.
Ted thanks for your time,
Dimitris
ted
Site Admin
Posts: 6398
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

dperakis wrote:First of all I have included in the PARAMETER block some variables that are changing (varied) during the simulation run, succh as II, a, b, d_neg, spikes. So moving them to the ASSIGNED block fixed the first problem.
I do prefer to declare "assigned variables" in an ASSIGNED block, and true parameters in a
PARAMETER block, but for the most part these declarations are merely hints to the GUI (e.g.
they control whether a variable appears in a parameter panel). For this particular model and
the a, b, d_neg, and spikes variables, it doesn't make any difference whether they are
declared to be ASSIGNED or PARAMETERS--they are all given appropriate values before
they are used. To verify this, I just tried the changes you suggest (except for "ll", which
doesn't exist), and got the same results as I did before I made them. I'll send you a zip file
that contains my slight modification of the mod file (mostly units-related changes) and a
couple of hoc files that demonstrate that it doesn't matter whether both point processes
are attached to one section or to different sections.
The second problem was with the gsyn parameter which was not reset to zero after a spiking input. Thus we changed the gsyn in the first differential equation with the function M().
Reset gsyn to 0 after a spike? Doesn't happen in real cells, but a model cell isn't real, is it?
In any case, the model cell seems to work OK without that change.
dperakis

Post by dperakis »

Sorry for some mis-comprehension due to my bad english.
First of all I never said that the problem was due to different "host sections".
Second the results that you send me are not the "perfect" and i post in here the "real" one:
http://www.nikaia-church.gr/neolaia/Per ... Result.JPG
I think the real problem is the parameter of the current, which previously i posted as "II" which is actually "I". In the new mech, i included the "I" (input current) in the ASSIGNED block and i initialized it in the INITIAL block.
With this modification, the results are the one depicted in the above url.
PS: These results are taken from the .hoc you send me with commeding the "Load file" command and including the new MECH.
Thanks for your precious time,
Dimitris
ted
Site Admin
Posts: 6398
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Post by ted »

dperakis wrote:Sorry for some mis-comprehension due to my bad english.
Your english is more than good enough. The error was mine--I read this
when I use the same .mod file for the two neurons, the results are different (and for sure wrong . . .
but saw this

Code: Select all

create cell_1, cell_2
access cell_1
objref neuron_1, neuron_2, nc1, fresh1
cell_1 neuron_1 = new MECH(0.5)
cell_2 neuron_2 = new MECH(0.5)
and then simply became fixated on the notion of "one host section vs. two host sections."
I think the real problem is the parameter of the current, which previously i posted as "II" which is actually "I". In the new mech, i included the "I" (input current) in the ASSIGNED block and i initialized it in the INITIAL block.
Really? Making "I" ASSIGNED and initializing it to 0 doesn't affect the results I get.
dperakis

Post by dperakis »

Try with fixed time step.
In the .hoc you send to me I saw that you make use of variable time step which for some reason (I think because of the nature of the two differential equations) breaks down the whole simulation (I mean gives unexpected results).
So avoid variable time step and it will work.
PS: I have e-mailed you the code

Really many thanks
Post Reply