Membrane mechanisms xtra, extracellular collide with VecStim

Moderator: wwlytton

Post Reply
calu
Posts: 19
Joined: Fri Feb 19, 2016 10:07 am

Membrane mechanisms xtra, extracellular collide with VecStim

Post by calu » Fri Feb 19, 2016 5:50 pm

Hello,

I am trying to use VecStim to input a spike train into an axon. I also need to record the membrane currents (via extracellular) and want to additionally stimulate the axon externally (via xtra). When inserting nothing but Hodgkin-Huxley (hh) channels into the membrane, everything is fine. BUT:

- extracellular causes the axon to only receive the first spike of the inserted series and
- xtra gives error 139.

Is there a way to get around this? Thank you very much for any help. Here the code:

Code: Select all

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

# set neuron simulation parameters
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


# define axon
axonTest = h.Section(name='unmyelinated_axon')
axonTest.nseg = 20
axonTest.L = 1000
axonTest.diam = 1


# insert channels. Hodgkin-Huxley needed
axonTest.insert('hh')

# !!! ATTENTION
# here the problems arise, comment out for testing.
axonTest.insert('extracellular')
axonTest.insert('xtra')


# configure ExpSyn synapse
stim = h.ExpSyn(0, axonTest)
stim.e = 10
stim.i = 0.2
stim.tau = 3

# configure input to synapse
vecStim = h.VecStim()
vec = h.Vector([5, 25])#[1, 2])
vecStim.play(vec)

# connect synapse and VecStim input
netCon = h.NetCon(vecStim, stim)
netCon.weight[0] = 1

#observe synapse current
iSynVec = h.Vector()
iSynVec.record(stim._ref_i)

# and observe axon potentials
vAxonVec0 = h.Vector()
vAxonVec0.record(axonTest(0)._ref_v)
vAxonVec1 = h.Vector()
vAxonVec1.record(axonTest(1)._ref_v)

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

# run simulation
h.run()

# convert recorded signals to numpy arrays
timeArray = np.array(timeVector)
iSynArr = np.array(iSynVec)
vAxonArr0 = np.array(vAxonVec0)
vAxonArr1 = np.array(vAxonVec1)

# plot synapse currents and axon potentials
pyplot.plot(timeVector,vAxonArr0, label='Axon potential at start-position')
pyplot.plot(timeVector,vAxonArr1, label='Axon potential at end-position')
pyplot.plot(timeVector,iSynArr, label='Synapse current')
pyplot.legend()
pyplot.show()


Oh, and hello all! Great community, learned a lot by just reading. I could not find any thread addressing my issue though and hope this hasn't already been answered somewhere else.

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

Re: Membrane mechanisms xtra, extracellular collide with Vec

Post by ted » Sun Feb 21, 2016 11:54 pm

calu wrote:- extracellular causes the axon to only receive the first spike of the inserted series
Well, the axon doesn't receive anything--it's the synaptic mechanism ExpSyn that receives events. It would be quite surprising if inserting extracellular into the axon had any adverse effect on ExpSyn's response to events, or the axon's response to ExpSyn's response. Have you tried including just extracellular?

With regard to xtra, is the code in your msg your entire program, or did you leave out the bit that links xtra's POINTER variables im and ex to the appropriate variables? If that seems obscure, maybe the example in this post will help:
viewtopic.php?f=2&t=1685&p=14088#p14075
POINTERs have to be linked to variables or a run time error will happen. xtra has two POINTERs called ex and im that must be linked to the extracelluar mechanism's range variables e_extracellular and i_membrane. This must be done in every segment of every section that has xtra. If you got xtra.mod from https://www.neuron.yale.edu/ftp/ted/neu ... nd_rec.zip you would also have picked up other files and notes that discuss these variables.

calu
Posts: 19
Joined: Fri Feb 19, 2016 10:07 am

Re: Membrane mechanisms xtra, extracellular collide with Vec

Post by calu » Mon Feb 22, 2016 5:59 am

Thank you very much, Ted. I did not know enough about the properties of xtra. If I set the pointers like in the link you send, xtra does not produce an error anymore. Does not stimulate either, but that's something I'll look into later.

The strange effect of extracellular remains. With and without this mechanism, the following code produces the following plots.

Code: Select all

import neuron
from neuron import h
import neuron.gui
import numpy as np
from matplotlib import pyplot
#h.load_file('noload.hoc')

# set neuron simulation parameters
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(-100) #65 # initialize voltage state


# define axon
axonTest = h.Section(name='unmyelinated_axon')
axonTest.nseg = 20
axonTest.L = 1000
axonTest.diam = 1


# insert channels. Hodgkin-Huxley needed
axonTest.insert('hh')

# here the problems arise

# extracellular
# axonTest.insert('extracellular')

# # extracellular stimulation
# axonTest.insert('xtra')
# tsvec = h.Vector(6)
# isvec = h.Vector(6)
# tsvec.x[0] = 0.0
# tsvec.x[1] = 1.0
# tsvec.x[2] = 1.0
# tsvec.x[3] = 2.0
# tsvec.x[4] = 2.0
# tsvec.x[5] = 3.0
# isvec.x[0] = 0.0
# isvec.x[1] = 0.0
# isvec.x[2] = 1.0
# isvec.x[3] = 1.0
# isvec.x[4] = 0.0
# isvec.x[5] = 0.0
#
# # xtra's ex must be coupled to e_extracellular in the same segment
# # and its im must be coupled to i_membrane in the same segment
# for seg in axonTest:
#   # couple ex_xtra to e_extracellular
#   # hoc syntax:  setpointer ex_xtra(x), e_extracellular(x)
#   h.setpointer(axonTest(seg.x)._ref_e_extracellular, 'ex', axonTest(seg.x).xtra)
#   # couple im_xtra to i_membrane
#   # hoc syntax:  setpointer im_xtra(x), i_membrane(x)
#   h.setpointer(axonTest(seg.x)._ref_i_membrane, 'im', axonTest(seg.x).xtra)

# configure ExpSyn synapse
stim = h.ExpSyn(0, axonTest)
stim.e = 10
stim.i = 0.2
stim.tau = 3

# configure input to synapse
vecStim = h.VecStim()
vec = h.Vector([5, 25])#[1, 2])
vecStim.play(vec)

# connect synapse and VecStim input
netCon = h.NetCon(vecStim, stim)
netCon.weight[0] = 1

#observe synapse current
iSynVec = h.Vector()
iSynVec.record(stim._ref_i)

# and observe axon potentials
vAxonVec0 = h.Vector()
vAxonVec0.record(axonTest(0)._ref_v)
vAxonVec1 = h.Vector()
vAxonVec1.record(axonTest(1)._ref_v)

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

# run simulation
h.finitialize() #65 # initialize voltage state
h.run()

# convert recorded signals to numpy arrays
timeArray = np.array(timeVector)
iSynArr = np.array(iSynVec)
vAxonArr0 = np.array(vAxonVec0)
vAxonArr1 = np.array(vAxonVec1)

# plot synapse currents and axon potentials
pyplot.plot(timeVector,vAxonArr0, label='Axon potential at start-position')
pyplot.plot(timeVector,vAxonArr1, label='Axon potential at end-position')
pyplot.plot(timeVector,iSynArr, label='Synapse current')
pyplot.legend()
pyplot.show()
Image
Image

So there is only the first current peak and the curves are extremely steep. I understand extracellular adds an outer layer around the section, maybe the ExpSyn does not connect correctly to the axon anymore? It is probably something I did not understand, thanks for helping.

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

Re: Membrane mechanisms xtra, extracellular collide with Vec

Post by ted » Mon Feb 22, 2016 1:19 pm

I see the problem. A point process attached to the 0 or 1 end of a section will deliver no current if extracellular has been inserted into the section. A workaround is to attach the point process to the first (or last) internal node of the section. Example hoc and Python statements using ExpSyn are
axon syn = new ExpSyn(1e-3) // or ExpSyn(1 - 1e-3) if nseg is >= 1000
and
syn = h.ExpSyn(1e-3, axon) ## or ExpSyn(1 - 1e-3) if nseg is >= 1000
assuming that the section name is axon.

calu
Posts: 19
Joined: Fri Feb 19, 2016 10:07 am

Re: Membrane mechanisms xtra, extracellular collide with Vec

Post by calu » Mon Feb 22, 2016 2:34 pm

:-) Thank you so much! It works now.

Post Reply