I'm relatively new to neuron and attempting to inject a current into a custom cell and record the transfer impedance along the axon as one would with the ImpedanceRatio tool in the Neuron GUI but in python. Attached is my python code, I built the same cell in the neuron GUI and recorded the transfer impedance and the outputs do not match. I am using this as a sanity check my next step is to Import an array from a file, convert it to a vector and play that vector on the Iclamp for the next step. Any help on this would be greatly appreciated.
Code: Select all
import neuron as ne
import nrn as n
import numpy as np
class cell:
def __init__(self):
self.ne = ne
self.n = n
def make_cell(self):
soma = self.soma = self.n.Section()
axon = self.axon = self.n.Section()
dend = self.dend = self.n.Section()
soma.L = 100
soma.diam = 50
soma.nseg = 5
soma.Ra = 100
soma.cm = 1
axon.L = 1500
axon.diam = 10
axon.nseg = 50
axon.Ra = 100
axon.cm = 1
dend.L = 3400
dend.diam = 50
dend.nseg =70
dend.Ra = 100
dend.cm = 1
axon.connect(soma,1)
dend.connect(soma,0)
soma.insert('hh')
axon.insert('hh')
dend.insert('hh')
self.vect = ne.h.Vector()
soma.push()
self.vect.record(self.ne.h.ref(soma(0.5).v))
self.ne.h.pop_section()
def run(self,tstop,v_init=-65):
print ("Before sim " + str(self.soma(0.5).v))
self.ne.h.finitialize(v_init)
self.ne.h.fcurrent()
self.ne.h.dt = 1
z_transfer = []
#load file
in_wav = np.loadtxt('ModulatedWave.txt')
#IClamp
stim = self.ne.h.IClamp(self.soma(0.5))
stim.delay = 0
stim.dur = 1000
#stim.dur = 1e9 #for vector input
stim.amp = 0.5
#read transfer impedance
imp = self.ne.h.Impedance()
imp.loc(0.5, sec=self.soma) #location of input electrode
#input current
#i_vect = ne.h.Vector(np.array(in_wav))
t_list = list(range(0,1000))
while self.ne.h.t < tstop:
#ne.h.VecStim.play(stim._ref_amp, i_vect , 1)
imp.compute(int(self.ne.h.t), 1)
z_transfer.append(imp.transfer(0.41, self.axon))
self.ne.h.fadvance()
print ("After sim " + str(self.soma(0.5).v))
z_transfer = np.array(z_transfer)
output_f = open('channel_result.txt', 'w')
np.savetxt(output_f, z_transfer)
output_f.close()
c = cell()
c.make_cell()
c.run(1000)