VClamp and IClamp in the same .hoc file

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

VClamp and IClamp in the same .hoc file

Post by porio »

Hi,

I have a model neuron with several conductances, and I want to test its behavior with both v-clamp and i-clamp experiments (not at the same time, of course).
My .hoc file defines the procedures 'dovc' and 'doic', which perform several pulses of either voltage or current clamp and plot the results in a graph.
However, I became aware that I can not have both clamps 'turned on' at the same time, so I wonder if there is a way to 'turn off' a stimulus object that has already been declared.
Otherwise, I guess I will have to write separate hoc files, one for v-clamping and the other for i-clamping.

Just in case, here is the code I'm writing:

Code: Select all

load_file("nrngui.hoc")

create soma

access soma

insert trpm8
insert hcn_po

dt = 0.5
tstop = 500

objectvar vstim,grph,istim
objectvar vec[2],ivec

vstim = new VClamp(0.5)
vstim.dur(0) = 50
vstim.dur(1) = 300
vstim.dur(2) = 150
vstim.amp(0)= -60
vstim.amp(2)= 40
istim = new IClamp(0.5)
istim.del = 50
istim.dur = 300

numpulses = 4

for i=0,1 vec[i] = new Vector()
ivec = new Vector()
vec[0].record(&soma.i_hcn_po(0.5),1)
vec[1].record(&soma.i_trpm8(0.5),1)
ivec.record(&soma.v(0.5),1)

grph = new Graph()

proc dovc() {
grph.erase()
grph.size(0, 500, -0.05, 0.1)
for i=0,numpulses-1 {
	vstim.amp(1)= -100 + i*20
	run()
	for j=0,1 vec[j].line(grph,j+1,1)	
}
}

proc doic() {
grph.size(0, 500, -150, 100)
for i=0,numpulses-1 {
	istim.amp= -120 + i*20
	run()
	ivec.line(grph,3,1)	
}
}
Regards.
ted
Site Admin
Posts: 6299
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: VClamp and IClamp in the same .hoc file

Post by ted »

I have a model neuron with several conductances, and I want to test its behavior with both v-clamp and i-clamp experiments (not at the same time, of course).
My .hoc file defines the procedures 'dovc' and 'doic', which perform several pulses of either voltage or current clamp and plot the results in a graph.
However, I became aware that I can not have both clamps 'turned on' at the same time, so I wonder if there is a way to 'turn off' a stimulus object that has already been declared.
Otherwise, I guess I will have to write separate hoc files, one for v-clamping and the other for i-clamping.
Nice clean code.

First, a question: why use VClamp instead of SEClamp? If your interest is in the cell,
and not instrumentation artefact caused by limited bandwidth of a two electrode voltage
clamp circuit, SEClamp is the better tool to use. Go to NEURON's FAQ list
http://www.neuron.yale.edu/neuron/faq/general-questions
and read
What is the difference between SEClamp and VClamp, and which should I use?

Next the answer to your question:
No need to "disable" anything.
To defer the IClamp's output to "never," simply assign
istim.del = 1e9
(effectively infinitely far in the future).
To eliminate the effect of an SEClamp, stop for a moment and think: what is a perfect
voltage clamp? Just a battery with zero series resistance. So how does one render
a voltage clamp completely ineffective? Make its series resistance effectively infinite,
i.e. 1e9. Trivial with SEClamp, which is nothing more than a perfect voltage source in
series with a resistor.

BTW, SEClamp's default series resistance is 1 megohm. When dealing with a cell
that has a low input resistance, it may be necessary to make this smaller in order to
improve control of membrane potential.

Finally a suggestion:
Record time to a vector. Then you can use the Vector class's plot() method
to see your variables plotted vs. t.
porio

Post by porio »

Thank you!!
I didn't know about SEClamp (i have quite a lot to learn yet)

But know I have this problem: I want to plot the total cell current evoked by the voltage pulse, instead (or in addition to) the currents of individual conductances.
I have tried to record it into a vector with something like
vec[2].record(&SEClamp[0].i,1)
(SEClamp[0].i is the name it has when I add it 'manually' to a graph in the GUI)

or
vec[2].record(&vstim.i,1)

and all I get is a 'record : object prefix is NULL' error message.

How should I do it?

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

diagnosing "object prefix is NULL"

Post by ted »

all I get is a 'record : object prefix is NULL' error message
Is vec[2] already a Vector before you assert .record()? To find out, insert
print vec[2]
before the
vec[2].record(&vstim.i,1)
statement

An aside to help you avoid future pain:
I have tried to record it into a vector with something like
vec[2].record(&SEClamp[0].i,1)
It is not a good practice to invoke the actual name of an object,
because the "index" part of the name is not under your direct
control--it is assigned automatically by NEURON, and depends on
how many other objects of the same type have already been created,
which in turn depends on what hoc code you have executed or GUI
tools you have used in a given session. Always use the name of the
objref, over which you have complete control.
porio

Post by porio »

Ooops... you were right. vec[2] wasn't declared yet as a Vector. I didn't realize that because I thought that the 'object prefix is NULL' message was referring to t he &vstim object.
Thanks!!
I have another problem, though. I will start another topic for the sake of order.
Post Reply