Page 1 of 1

### Stimulate multiple axons with IClamp

Posted: Thu Feb 25, 2016 2:30 pm
Hello!

I need to stimulate n axons with IClamp. Unfortunately only the first axon I instantiate gets stimulated no matter what axon I choose in IClamp( <position>, <section>). In the following minimal working example, I create two axons. I connect IClamp to the second one but the first one gets stimulated only. What could be the problem?

While trying to solve the issue myself I noticed the segments of the two axons have the same memory locations. Why is that?

Thank you very much!

Code: Select all

``````import neuron
from neuron import h
import neuron.gui
import numpy as np
from matplotlib import pyplot

h.celsius = 33  # set temperature in celsius
h.tstop = 3e1  # set simulation duration (ms)
h.dt = 0.0025  # 0.0005 # set time step (ms)
h.finitialize(-65)  # initialize voltage state

# create first axon and set properties
h('create axon0')
axon0 = h.axon0
axon0.nseg = 20
axon0.L = 1000
axon0.diam = 1
axon0.insert('hh')

# create second axon and set properties
h('create axon1')
axon1 = h.axon1
axon1.nseg = 20
axon1.L = 1000
axon1.diam = 1
axon1.insert('hh')

# create current clamp and connect to SECOND axon
stim1 = h.IClamp(0, axon1)
stim1.delay = 0
stim1.dur = 1
stim1.amp = 1

# why are all segments at the same locations in memory?
print list(axon0.allseg())
print list(axon1.allseg())

# set voltage recorder for first axon
vAxonVec0 = h.Vector()
vAxonVec0.record(axon0(0)._ref_v)

# set voltage recorder for second axon
vAxonVec1 = h.Vector()
vAxonVec1.record(axon1(0)._ref_v)

# record time, too
timeVector = h.Vector()
timeVector.record(h._ref_t)

# run simulation
h.run()

# convert recorded data to np.array for plotting
timeArray = np.array(timeVector)
vAxon0 = np.array(vAxonVec0)
vAxon1 = np.array(vAxonVec1)

# plot all signals
pyplot.plot(timeVector, vAxon0, label='First axon')
pyplot.plot(timeVector, vAxon1, label='Second axon')
pyplot.xlabel('time [ms]')
pyplot.ylabel('voltage [mV]')
pyplot.legend()
pyplot.show()
``````

### Re: Stimulate multiple axons with IClamp

Posted: Fri Feb 26, 2016 11:11 am
An IClamp is like any other point process: it can be attached to an individual segment (compartment) of an individual section, and if it is a point process that can deliver current, it can only deliver current to that segment of that section. If you want to stimulate both axons, each one will need its own IClamp.

It might be a good idea to read chapters 5 and 6 of The NEURON Book, or at least
Hines, M.L. and Carnevale, N.T.
The NEURON simulation environment.
Neural Computation 9:1179-1209, 1997
which is available from a link at http://www.neuron.yale.edu/neuron/nrnpubs

### Re: Stimulate multiple axons with IClamp

Posted: Fri Feb 26, 2016 2:33 pm
Thanks for the reply, maybe I was not clear enough. When I do any of the following

- connect IClamp to first axon
- connect IClamp to second axon
- connect IClamp to both axons

I always get the same result: Only the first axon I instantiate is stimulated. Meaning adding the following code changes nothing in the final outcome, the plot looks excactly the same.

Code: Select all

``````# create current clamp and connect to FIRST axon
stim1 = h.IClamp(0, axon0)
stim1.delay = 0
stim1.dur = 1
stim1.amp = 1
``````

### Re: Stimulate multiple axons with IClamp

Posted: Mon Feb 29, 2016 11:35 pm
calu wrote:When I do any of the following

- connect IClamp to first axon
- connect IClamp to second axon
- connect IClamp to both axons

I always get the same result: Only the first axon I instantiate is stimulated.
Because you really are stimulating only the first axon that was created. It's good that you tested. Here's an example extract that works:

Code: Select all

``````stim0 = h.IClamp(0, sec=axon0)
stim0.delay = 0.1
stim0.dur = 0.1
stim0.amp = 1

stim1 = h.IClamp(0, sec=axon1)
stim1.delay = 1.1
stim1.dur = 0.1
stim1.amp = 1``````
BTW, clarity will be served if you adopt a consistent notation, as in the above example (if the first axon is axon0, call its stimulus stim0, etc.).

Next, for debugging and development, it's a good idea to use short run times and reasonable integration step size (NEURON's default 5 ms run time and 0.025 ms dt will suffice for this toy model).

Finally, please note that it is generally best to use odd values for nseg, and that the d_lambda rule generally does an excellent job of choosing nseg values that produce results that have good spatial accuracy--see
Why should I use an odd value for nseg?
What's a good strategy for specifying nseg?

in the FAQ list (see link on the documentation page http://www.neuron.yale.edu/neuron/docs).

### Re: Stimulate multiple axons with IClamp

Posted: Tue Mar 01, 2016 8:07 am
Aaaah, thanks Ted! I missed the sec= in the call of h.IClamp(0, sec=<axonname>). So sec is an optional parameter for the IClamp constructor? How is h.IClamp(0, <axonname>) without sec= interpreted by NEURON?

Where can I get an overview of the functions in the neuron.h model and their input parameters? Whenever I am searching online I arrive at the HOC documentary

### Re: Stimulate multiple axons with IClamp

Posted: Tue Mar 01, 2016 11:54 am
The problem you encountered has to do with the issue of "currently accessed section." When inserting a density mechanism or point process into a section, it is necessary to specify which section is to be the target of that action. Dot notation, as in axon.insert('hh'), makes the intended target for a density mechanism quite explicit, but it works only for density mechanisms, which become attributes of the affected section. Point processes are managed as object instances, so a different syntax is required--
pythonobject = h.ClassName(range, sec=pythonsectionname)
or the more compact
pythonobject = h.ClassName(pythonsectionname(range))

By the way it can be very useful to emply hoc to create sections in the way you did--that is
h('create axon')
axon = h.axon
This ensures that each section's hoc name is the same as its Python name, which makes it very easy to use NEURON's native InterViews GUI tools to explore section attributes, especially the Graph class (for shape plots and space plots) and the ModelView tool.

The Programmer's Reference is slowly being revised to include more Python-specific information. In the meantime, you might find these items particularly helpful--look on NEURON's Documenatation page http://www.neuron.yale.edu/neuron/docs for the following:
Scripting NEURON with Python contains a lot of useful hints and examples.
So does Examples of using the Python interpreter to work with hoc/nrniv objects
Reaction-diffusion tutorials is useful if that particular topic is of interest to you.

### Re: Stimulate multiple axons with IClamp

Posted: Tue Mar 01, 2016 12:21 pm
Ok, I will look into these examples, they seem pretty informative and indeed I did not find them over a general google enquiry. An extensive documentation for Python would be extermely useful to many NEURON users, I guess.

So thank you again very much for the detailed explanation and the hints!