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
import matplotlib.pyplot as plt from functions.Voltages import Voltages from classes.Cell_rdg import MRG MyTraj = np.array([[-50e-3, 0, 0], [51e-3, 0, 0]]) 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) MyPoints = list() for sec in MyCell.get_secs(): if ("node" in sec.name()): MyPoints.append(MyCell.center_3Dcoords(sec)) MyPoints = np.array(MyPoints) * 1e-6 NumNodes = len(MyPoints[:, 0]) AllAPT = [] AllAPL = [] APTs = np.empty(0) APLs = np.empty(0) Ns = 10 for F in range(1, 51, 1): for f2 in [1000, 2000, 4000]: