Getting the 'xtra' mechanism to work without 'extracellular'
Posted: Wed Apr 26, 2017 10:11 pm
I am trying to get a minimal model working in which I record the LFP of one cell using 'xtra', without the 'extracellular' mechanism, as described here viewtopic.php?f=2&t=3389&p=14342&hilit= ... lel#p14342. I have made the modifications to xtra.mod described in the post, and I also have beforestep_py.mod working, which I implement at the beginning of my minimal model:
And here is calcrxc_a.hoc (modified version of Ted's calcrxc.hoc, stripping out all the GUI-related stuff):
My problem is that attempting to run this simulation gives the error:
NEURON: division by zero, near line 1, setelec(50,0,0)
I checked whether the electrode was placed directly on top of one of the segment centers, and that is not the problem. I am actually able to get the program to run and give a coherent result if I insert the 'extracellular' mechanism into both sections, and also use Ted's setpointers() function (rather than using my own Python-based approach for setting pointers). But I really want to be able to get this to work without using 'extracellular', both for the performance speedup and so that I feel like I actually know what is going on. Thanks for the help!
Code: Select all
from neuron import h, gui
# set up recording of LFP at every time step, in conjunction with Hines's beforestep_py.mod
s = h.Section()
bscallback = h.beforestep_callback(s(.5))
lfp_rec=[]
def callback():
vx = 0
for sec in h.allsec():
for seg in sec:
vx = vx + seg.er_xtra
#end both for loops
lfp_rec.append(vx)
print h.t, vx
bscallback.set_callback(callback)
h('cvode.use_fast_imem(1)') #see use_fast_imem() at https://www.neuron.yale.edu/neuron/static/new_doc/simctrl/cvode.html
soma=h.Section(name='soma')
Bdend=h.Section(name='Bdend')
soma.diam = soma.L = 20 #microns
soma.insert('hh')
Bdend.diam = 2 #microns
Bdend.L=200 #microns
Bdend.insert('pas')
Bdend.connect(soma,0,0)
for sec in h.allsec():
sec.insert('xtra')
h.define_shape() #this assigns default position of cell, with soma at origin
#call grindaway() in order to calculate centers of all segements, and--most importantly--copy these values to the xtra mechanism of each cell, so they can be used to calculate the LFP
h('xopen("interpxyz.hoc")') #from Ted's extracellular_stim_and_rec code; see https://www.neuron.yale.edu/phpBB/viewtopic.php?f=8&t=3649
h('grindaway()')
#set pointers
for sec in h.allsec():
for seg in sec:
h.setpointer(seg._ref_i_membrane_, 'im', seg.xtra)
#compute transfer resistances between electrode and all segements
h('xopen("calcrxc_a.hoc")') #this is a slightly altered version from Ted's original calcrxc.hoc
h('setelec(50,0,0)') #this is what actually sets electrode location and computes transfer resistances'''
#record soma voltage and time
t_vec = h.Vector()
v_vec_soma = h.Vector()
v_vec_dend = h.Vector()
v_vec_soma.record(soma(0.5)._ref_v)
v_vec_dend.record(Bdend(0.5)._ref_v)
t_vec.record(h._ref_t)
#run simulation
h.tstop = 200 #ms
h.run()
Code: Select all
rho = 351
XE = -50 // um
YE = 0
ZE = 0
proc setrx() { // now expects xyc coords as arguments
forall {
if (ismembrane("xtra")) {
for (x,0) {
r = sqrt((x_xtra(x) - $1)^2 + (y_xtra(x) - $2)^2 + (z_xtra(x) - $3)^2)
rx_xtra(x) = (rho / 4 / PI)*(1/r)*0.01
}
}
}
}
proc setelec() {
xe = $1
ye = $2
ze = $3
setrx(xe, ye, ze)
}
NEURON: division by zero, near line 1, setelec(50,0,0)
I checked whether the electrode was placed directly on top of one of the segment centers, and that is not the problem. I am actually able to get the program to run and give a coherent result if I insert the 'extracellular' mechanism into both sections, and also use Ted's setpointers() function (rather than using my own Python-based approach for setting pointers). But I really want to be able to get this to work without using 'extracellular', both for the performance speedup and so that I feel like I actually know what is going on. Thanks for the help!