Dynamic clamp?

The basics of how to develop, test, and use models.
Post Reply
gartland

Dynamic clamp?

Post by gartland » Tue Jun 23, 2009 7:31 pm

I don't believe that I'm the first person to try to implement a dynamic clamp (or conductance clamp) in NEURON, but i can't seem to find anyone else who has done this. Can someone point me in the right direction?

What I need is sort of like a current clamp. I would be able to "play" an arbitrary stimulus into it, but unlike a normal IClamp, the stimulus vector would need to change during the simulation depending on the voltage at the position of the electrode. That way I can reduce the amount of current injected if the driving force on the simulated conductance decreases, thus clamping the conductance, not the current.

As I'm writing this I'm realizing that I could probably interrupt the the "while (t<tstop) { fadvance()}" loop and after each iteration change the vector that is being played into the IClamp based on the voltage, but I have a feeling that this will either be terribly slow and/or mess up the integration? What do you think? Any better ideas? Is there a way to use NMODL to make a conductance clamp? Would the stimulus have to be hard-coded and recompiled every time or could it be a mechanism sort of like IClamp?

Thanks for any ideas!

-Andrew

hines
Site Admin
Posts: 1528
Joined: Wed May 18, 2005 3:32 pm

Re: Dynamic clamp?

Post by hines » Thu Jun 25, 2009 5:14 pm

NEURON as a dynamic clamp is an aim of the present NEURON grant. Our proposal contained the fragment:
With a Dell Dimension 8000 (3GHz i686) we have demonstrated hard real
time performance with a 40 compartment hh model with 25us steps under
RTAI Linux and a National Intruments M series data acquisition card.
With such small steps, there can be no user input during an individual
sweep. But when long time steps are feasible (beginning at .1 to 1 ms),
a separate hard-realtime data thread coexists with an interruptable thread
so that gui, mouse, keyboard, disk/net io is handled without a problem
as long as total computation time remains less than realtime. It is
interesting to note that since interrupt latency is in the neighborhood
of 10 us with a few us jitter, with 25 us steps it is necessary during
sweep initialization to execute a false step to put the entire model
into cache so that the first step does not overrun the first realtime
interval.

Because many newer machines suffer from serious interrupt latency
problems in which a timing interrupt is not handled fast enough to
read the data input and compute the output for the next time point,
our first goal is to develop diagnostic expertise with
known latency killers such as SMI interrupts and USB. Some have been
shown to be easily overcome, eg. using PS2 keyboard and mouse and
turning off USB, whereas others may make a particular machine
unsuitable for hard real-time applications.
At present that project is in hiatus due to the difficulty of user diagnosis of latency killers. All the software involved is in the current software distribution in nrn/src/ni_pci_6229 however several important files explaining what is going on are missing. If interested, I can send them to you (they are on the above mentioned dell dimension 8000). Just send me an email at michael dot hines at yale dot edu.

gartland

Re: Dynamic clamp?

Post by gartland » Mon Jun 29, 2009 7:01 pm

Your idea to use NEURON as a dynamic clamp for a real neuron sounds very cool! However I was asking about something much simpler (I hope :) ). I would simply like to alter the IClamp point process to make it a conductance clamp point process. Current I "play" an arbitrary current waveform into a IClamp point process and the clamp.mod mechanism injects this waveform into the cell. I'd like to modify clamp.mod to inject current that is dependent on the driving force (a conductance). It would look something like this:

Code: Select all

COMMENT
This is a dynamic clamp (a.k.a conductance clamp). To use it, play a stimulus conductace vector into the g range variable. Set the reversal
potential of the conductance with the e range variable. Record the injected current with the i range variable.
ENDCOMMENT

NEURON {
	POINT_PROCESS gclamp
	RANGE g, i, e
	ELECTRODE_CURRENT i
}

UNITS {
	(mV) = (millivolt)
	(uS) = (micromho)
	(nA) = (nanoamp)
}

PARAMETER {
	g (micromho)
	e (millivolt)
	v (millivolt)
}
ASSIGNED { i (nanoamp) }

INITIAL {
	i = g*(v-e)
}

BREAKPOINT {
	i=g*(v-e)
}
Does this make sense?
I can't get this to work because I'm not sure how I can "play" a vector into a point process that has been "inserted" and when I try to insert a GClamp like I would insert an IClamp, i get a message that I am missing a template? Can you suggest a way for me to implement a conductance clamp that could take an arbitrary vector at runtime?

Here is the factory I use to create an IClamp which works well (even if its not the newest pythonic way of doing it):

Code: Select all

self.n('obfunc newiclamp() {return new IClamp($1)}')
self.n.iclamp=self.n.newiclamp(segment)

When I try to do this with a GClamp (gclamp.mod, the above code is compiled and in the right place):

Code: Select all

NEURON: GClamp is not a template
 near line 0
 obfunc newgclamp() {return new GClamp($1)}
This doesn't totally surprise me since it appears there is something special about an IClamp point process compared to other mechanisms. Can we make GClamp special too?

gartland

Re: Dynamic clamp?

Post by gartland » Mon Jun 29, 2009 7:27 pm

May have spoken too soon. Think it was just a capitalization typo with the mechanism name! (gclamp versus GClamp)

And somehow I missed this post about a conductance idiom which was helpful.
viewtopic.php?f=2&t=1345&p=4689&hilit=play+python#p4689

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

Re: Dynamic clamp?

Post by ted » Tue Jun 30, 2009 10:57 am

gartland wrote:I would simply like to alter the IClamp point process to make it a conductance clamp point process.
Use an SEClamp. Drive its rs. For any "zero conductance" values, use rs = 1e9.

cafischer
Posts: 19
Joined: Sun Nov 30, 2014 6:03 am

Re: Dynamic clamp?

Post by cafischer » Thu Nov 30, 2017 11:07 am

So if the SEClamp replaces: i = g * (v - e)
then rs is the equivalent for 1/g. But what is the equivalent for e. How can I set that in the SEClamp?

----------------------------------------------------------------------------------------------------------------------------------------------------------------
Would the code from gartland also work? (Is it equivalent to the SEClamp method?) I am unable to play a time varying g(t) into the GClamp. How could one implement that?
I am doing it like this:

Code: Select all

g_vec = h.Vector()
g_vec.from_python(g)
t_vec = h.Vector()
t_vec.from_python(np.arange(len(g)*dt))
g_vec.play(GClamp._ref_g, t_vec)

hines
Site Admin
Posts: 1528
Joined: Wed May 18, 2005 3:32 pm

Re: Dynamic clamp?

Post by hines » Thu Nov 30, 2017 4:00 pm

Set SEClamp.dur1 = 1e9 and then play a Vector into SEClamp.amp1

Without looking too closely, using your GCLamp is very similar. Please note, though the abuse of syntax used there as well as in the line above.
SECla
mp cannot be used as an instance without its instance index. eg. SEClamp[0], or via an object reference as in

Code: Select all

create a
objref sc
a { sc = new SEClamp(.5) }
sc.dur1 = 1e9

cafischer
Posts: 19
Joined: Sun Nov 30, 2014 6:03 am

Re: Dynamic clamp?

Post by cafischer » Fri Dec 01, 2017 3:28 am

I think we misunderstood. I want to use the SEClamp as a conductance clamp. So I should play my time dependent conductance g(t) into SEClamp.rs, right? But then I did not know how to set the reversal potential of the, as synapse abused, SEClamp.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Regarding the GClamp: So there is nothing I need to do in the .mod file to make a range parameter playable?

hines
Site Admin
Posts: 1528
Joined: Wed May 18, 2005 3:32 pm

Re: Dynamic clamp?

Post by hines » Fri Dec 01, 2017 6:27 am

I believe the variable name is SEClamp[0].rs if it is the first instance.

All range varialbles are playable if they are PARAMETER. It becomes ambiguous if they are ASSIGNED or STATE as those are usually changed
in the mod file and it is implementation dependent if the "play" takes place before or after they are changed.

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

Re: Dynamic clamp?

Post by ted » Fri Dec 01, 2017 11:43 am

I want to use the SEClamp as a conductance clamp. So I should play my time dependent conductance g(t) into SEClamp.rs, right? But then I did not know how to set the reversal potential of the, as synapse abused, SEClamp.
Set the SEClamp's dur1 to 1e9, and set its amp1 to the value you want for the reversal potential.
Regarding the GClamp: So there is nothing I need to do in the .mod file to make a range parameter playable?
You can drive any range variable with a Vector.

One general comment: sign convention for ELECTRODE_CURRENT is that depolarizing current is positive, unlike NONSPECIFIC_CURRENT or ionic transmembrane current. Note that synaptic mechanisms such as ExpSyn generate NONSPECIFIC_CURRENT.

Post Reply