Utilizing extracellular in a for loop
Posted: Wed Dec 12, 2007 2:27 am
First off, here's what I'm trying to do. I'm trying to model an extracellular monopolar current stimulus and apply it to an axon with n nodes/segments (currently set at 21 for simplicity). I have MATLAB code which models the extracellular monopolar current source and calculates corresponding voltages at the membrane for each of the 21 nodes. That code has been vetted and creates a file with column one being time, and columns 2 through n+1 being nodal voltages at each time step.
The NEURON code reads in that file (as a matrix), and then is supposed to use a for loop to strip out each column 2 through n+1 in sequence as a vector and then play it via the extracellular mechanism. However, when the code is run, it only applies the extracellular voltage stimulus at the most distal node (i.e. at axon position 1.0). I (and the person I'm working with) haven't been able to figure out the problem but think it may have something to do with handling of pointers within the loop. I've been able to play vectors fine outside of the loop and the loop itself is iterating as it should.
Any thoughts on what we're missing?
Thanks very much for the help.
*****
load_file("nrngui.hoc")
create axon
access axon
// Global simulation constants
num_nodes = 21 // compartments
Dt = 0.1 // msec
tstop = 500 // msec
// Constants for active axon with HH channels
axon nseg = 100
axon diam = 1
axon L = 28000
axon Ra = 100
axon insert hh
axon insert pas
g_pas = 1/20000
e_pas = -60
// Insert extracellular mechanism. Changed nrn/src/nrnoc/options.h line #define EXTRACELLULAR 1
// Syntax:
// insert extracellular
// vext[2] -- mV
// i_membrane -- mA/cm2
// xraxial[2] -- MOhms/cm
// xg[2] -- mho/cm2
// xc[2] -- uF/cm2
// e_extracellular -- mV
axon insert extracellular
// Apply extracellular stim from MATLAB file
objref f1, v1, t1, m1
f1=new File()
num_rows = tstop/Dt+1
num_cols = num_nodes+1
m1 = new Matrix(num_rows,num_cols)
v1=new Vector(num_rows)
t1=new Vector(num_rows)
for i=1,num_nodes{
print "\nLoad compartment ", i
f1.ropen("HFAC_extra_21node_10Hz.dat")
m1.scanf(f1,num_rows,num_cols)
v1=m1.getcol(i)
// Only strip out the time vector once
if (i==1) {
t1=m1.getcol(i-1)
}
norm_step = (i-1)/(num_nodes-1)
print "Axon fraction: ", norm_step
v1.play(&e_extracellular(norm_step), t1)
}
// Current injection at proximal end of cable (to produce APs)
objectvar stim
axon stim = new IClamp(0)
stim.del = 10
stim.dur = 100
stim.amp = 1
*****
Too bad phBB won't preserve tab indents...
The NEURON code reads in that file (as a matrix), and then is supposed to use a for loop to strip out each column 2 through n+1 in sequence as a vector and then play it via the extracellular mechanism. However, when the code is run, it only applies the extracellular voltage stimulus at the most distal node (i.e. at axon position 1.0). I (and the person I'm working with) haven't been able to figure out the problem but think it may have something to do with handling of pointers within the loop. I've been able to play vectors fine outside of the loop and the loop itself is iterating as it should.
Any thoughts on what we're missing?
Thanks very much for the help.
*****
load_file("nrngui.hoc")
create axon
access axon
// Global simulation constants
num_nodes = 21 // compartments
Dt = 0.1 // msec
tstop = 500 // msec
// Constants for active axon with HH channels
axon nseg = 100
axon diam = 1
axon L = 28000
axon Ra = 100
axon insert hh
axon insert pas
g_pas = 1/20000
e_pas = -60
// Insert extracellular mechanism. Changed nrn/src/nrnoc/options.h line #define EXTRACELLULAR 1
// Syntax:
// insert extracellular
// vext[2] -- mV
// i_membrane -- mA/cm2
// xraxial[2] -- MOhms/cm
// xg[2] -- mho/cm2
// xc[2] -- uF/cm2
// e_extracellular -- mV
axon insert extracellular
// Apply extracellular stim from MATLAB file
objref f1, v1, t1, m1
f1=new File()
num_rows = tstop/Dt+1
num_cols = num_nodes+1
m1 = new Matrix(num_rows,num_cols)
v1=new Vector(num_rows)
t1=new Vector(num_rows)
for i=1,num_nodes{
print "\nLoad compartment ", i
f1.ropen("HFAC_extra_21node_10Hz.dat")
m1.scanf(f1,num_rows,num_cols)
v1=m1.getcol(i)
// Only strip out the time vector once
if (i==1) {
t1=m1.getcol(i-1)
}
norm_step = (i-1)/(num_nodes-1)
print "Axon fraction: ", norm_step
v1.play(&e_extracellular(norm_step), t1)
}
// Current injection at proximal end of cable (to produce APs)
objectvar stim
axon stim = new IClamp(0)
stim.del = 10
stim.dur = 100
stim.amp = 1
*****
Too bad phBB won't preserve tab indents...