The authors model extracellular field as a summation of two point sources injecting current at certain frequencies (2000 Hz and 2005 Hz).
About the implementation they say that:
the potential field for a monopole current source I0 located at (xs, ys, zs)in the anisotropic volume as:

and then
To calculate the overall potential field under quasistatic conditions, we summed the individual potential fields generated by each electrode pair:

As I see they reuse spatial field from Formula1 in Formula2, which I read as "in known homogenous medium each current source generates independent and predictably oscillating voltage potential".
Now I try to look at their code (I only watched few tutorials on NEURON yet) and understand how is this done.
Their full model code is on the bottom of this post, but here is how they compute Formula1 voltages and assign them to each section of the cell:
Code: Select all
VS1=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],-5e-3,+5e-3,+0e-3,+I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS2=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],+5e-3,+5e-3,+0e-3,-I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS3=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],-5e-3,-5e-3,+0e-3,+I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS4=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],+5e-3,-5e-3,+0e-3,-I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
V1 = VS1+VS2 # voltage of first pair
V2 = VS3+VS4 # voltage of second pair
recordingDict = dict()
location = 0.5
variable = {'v'}
iSec=0
# MyPoints = list()
for Sec in MyCell.get_secs():
Sec.rx1_xtra=V1[iSec]
Sec.rx2_xtra=V2[iSec]
iSec=iSec+1
if ("node" in Sec.name()):
for vars in variable:
rec_dict(recordingDict, Sec, location, vars)
Code: Select all
h.load_file("stdrun.hoc")
h.init()
h.finitialize(h.v_init)
h.fcurrent()
h.tstop = Duration
Times=np.arange(0,h.tstop+h.dt,h.dt)
Sim1=Amps*np.sin(2*np.pi*Freq/1000.0*Times)
Sim2=Amps*np.sin(2*np.pi*(Freq+DFreq)/1000.0*Times)
t = h.Vector(Times)
Stim1=h.Vector(Sim1*1e-3)
Stim2=h.Vector(Sim2*1e-3)
Stim1.play(h._ref_is1_xtra, t, 0)
Stim2.play(h._ref_is2_xtra, t, 0)
Can someone please explain
- How these two simple formulas are implemented in given model.
- Why can't the total voltage be assigned as in
Code: Select all
for Sec in MyCell.get_secs(): Sec.rx1_xtra=V1[iSec] Sec.rx2_xtra=V2[iSec] iSec=iSec+1
- What exactly is achieved by
Code: Select all
h.tstop = Duration Times=np.arange(0,h.tstop+h.dt,h.dt) Sim1=Amps*np.sin(2*np.pi*Freq/1000.0*Times) Sim2=Amps*np.sin(2*np.pi*(Freq+DFreq)/1000.0*Times) t = h.Vector(Times) Stim1=h.Vector(Sim1*1e-3) Stim2=h.Vector(Sim2*1e-3) Stim1.play(h._ref_is1_xtra, t, 0) Stim2.play(h._ref_is2_xtra, t, 0)
Sorry for pretty beginners questions, I was just trying to get fast-tracked to NEURON via reverse-engineering a well explained source-code, but I guess I just need to spend more time reading this forum, the documentation and watching youtube hands-on sessions.
Full model code:
Code: Select all
def model(Duration,Freq,DFreq,Amps,YY):
fs = 1000*50*4 # Hz, sampling rate
h.cvode_active(0) # turn off variable time step
h.steps_per_ms = fs*1e-3 # steps per ms for NEURON simulation
h.dt = 1/(fs*1e-3) # ms, sample spacing
h.celsius = h.celsius # temperature at which to run simulation
h.v_init = -80. # mV, initial voltage to begin simulations
ZZ=0
MyTraj = np.array([[-50e-3,YY,ZZ], [+51e-3,YY,ZZ]])
MyPath = os.getcwd() + '/'
CELL_DIR = MyPath+'cells/'
CELL_FILE_NAME = 'NewMRGaxon_for_Python.hoc'
MyD = 8.7
MyCell = MRG(axon_trajectory=MyTraj, fiberD=MyD,
CELL_FILE_NAME=CELL_FILE_NAME, CELL_DIR=CELL_DIR)
I = 1. # current source amplitude in A
# find xyz coordinates of center of each axon compartment
nrn_xyz = list()
for sec in MyCell.get_secs():
nrn_xyz.append(MyCell.center_3Dcoords(sec))
nrn_xyz = np.array(nrn_xyz)*1e-6 # m, convert from um to m
sigmaXX=0.6
sigmaYY=0.083
sigmaZZ=0.083
VS1=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],-5e-3,+5e-3,+0e-3,+I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS2=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],+5e-3,+5e-3,+0e-3,-I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS3=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],-5e-3,-5e-3,+0e-3,+I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
VS4=Voltages(nrn_xyz[:,0],nrn_xyz[:,1],nrn_xyz[:,2],+5e-3,-5e-3,+0e-3,-I,sigmaXX,sigmaYY,sigmaZZ,'V')['V']
V1 = VS1+VS2 # voltage of first pair
V2 = VS3+VS4 # voltage of second pair
recordingDict = dict()
location = 0.5
variable = {'v'}
iSec=0
# MyPoints = list()
for Sec in MyCell.get_secs():
Sec.rx1_xtra=V1[iSec]
Sec.rx2_xtra=V2[iSec]
iSec=iSec+1
if ("node" in Sec.name()):
for vars in variable:
rec_dict(recordingDict, Sec, location, vars)
MyCell.record(recordingDict)
h.load_file("stdrun.hoc")
h.init()
h.finitialize(h.v_init)
h.fcurrent()
h.tstop = Duration
Times=np.arange(0,h.tstop+h.dt,h.dt)
Sim1=Amps*np.sin(2*np.pi*Freq/1000.0*Times)
Sim2=Amps*np.sin(2*np.pi*(Freq+DFreq)/1000.0*Times)
t = h.Vector(Times)
Stim1=h.Vector(Sim1*1e-3)
Stim2=h.Vector(Sim2*1e-3)
Stim1.play(h._ref_is1_xtra, t, 0)
Stim2.play(h._ref_is2_xtra, t, 0)
h.run()
return MyCell