#stim2.number = 1 #stim2.start = 5 * ms #stim2.interval = 0.5 * ms # ## stimulator 2 #stim3 = h.NetStim() #stim3.number = 1 #stim3.start = 5 * ms #stim3.interval = 0.5 * ms # SYNAPSES # set 1 # excitatory synapse on relay cell - technically part of triad but named differently for clarity rc_exc1 = h.AlphaSynapse(relaycell.soma(0.28)) rc_exc1.onset = 5 * ms rc_exc1.tau = 0.2 * ms rc_exc1.gmax = 5 rc_exc1.i = 12 syns.append(rc_exc1) # proximal excitatory axodendritic synapse on interneuron in_exc1 = h.AlphaSynapse(interneuron.dend1_p(0.1)) in_exc1.onset = 5 * ms in_exc1.tau = 0.2 * ms in_exc1.gmax = 5 in_exc1.i = 12 syns.append(in_exc1) # distal excitatory axodendritic synapse on interneuron
from neuron import h, gui from matplotlib import pyplot soma = h.Section(name='soma') h.psection() soma.insert('pas') print("type(soma) = {}".format(type(soma))) print("type(soma(0.5)) ={}".format(type(soma(0.5)))) mech = soma(0.5).pas print(dir(mech)) asyn = h.AlphaSynapse(soma(0.5)) print("asyn.e = {}".format(asyn.e)) print("asyn.gmax = {}".format(asyn.gmax)) print("asyn.onset = {}".format(asyn.onset)) print("asyn.tau = {}".format(asyn.tau)) asyn.onset = 20 asyn.gmax = 1 h.psection() v_vec = h.Vector() # Membrane potential vector t_vec = h.Vector() # Time stamp vector v_vec.record(soma(0.5)._ref_v) t_vec.record(h._ref_t) h.tstop = 40.0 h.run() #plotting pyplot.figure(figsize=(8,4)) # Default figsize is (8,6) pyplot.plot(t_vec, v_vec) pyplot.xlabel('time (ms)') pyplot.ylabel('mV') pyplot.show()
basilar.nseg = 5 basilar.diam = 2 axon.L = 1000 axon.nseg = 37 axon.diam = 1 # biophysics for sec in h.allsec(): sec.Ra = 100 sec.cm = 1 soma.insert('hh') apical.insert('pas') basilar.insert('pas') for seg in chain(apical, basilar): seg.pas.g = 0.0002 seg.pas.e = -65 axon.insert('hh') # --------------------- Instrumentation --------------------- # synaptic input syn = h.AlphaSynapse(0.5, sec=soma) syn.onset = 0.5 syn.gmax = 0.05 syn.e = 0
def insert_alphasynapse(segment, onset=200.0, gmax=1e-3, tau=0.1): asyn = h.AlphaSynapse(segment) asyn.onset = onset asyn.gmax = gmax asyn.tau = tau return asyn
def __init__(self): neuron_utils.createProject(name='Simple Cell') self.soma = h.Section(name='soma') self.dend = h.Section(name='dend') self.dend.connect(self.soma(1)) # Surface area of cylinder is 2*pi*r*h (sealed ends are implicit). # Makes a soma of 500 microns squared. self.soma.L = self.soma.diam = 12.6157 self.dend.L = 200 # microns self.dend.diam = 1 # microns for sec in h.allsec(): sec.Ra = 100 # Axial resistance in Ohm * cm sec.cm = 1 # Membrane capacitance in micro Farads / cm^2 # Insert active Hodgkin-Huxley current in the soma self.soma.insert('hh') self.soma.gnabar_hh = 0.12 # Sodium conductance in S/cm2 self.soma.gkbar_hh = 0.036 # Potassium conductance in S/cm2 self.soma.gl_hh = 0.0003 # Leak conductance in S/cm2 self.soma.el_hh = -54.3 # Reversal potential in mV # Insert passive current in the dendrite self.dend.insert('pas') self.dend.g_pas = 0.001 # Passive conductance in S/cm2 self.dend.e_pas = -65 # Leak reversal potential mV self.dend.nseg = 10 # add synapse (custom channel) self.syn = h.AlphaSynapse(self.dend(1.0)) self.syn.e = 0 # equilibrium potential in mV self.syn.onset = 20 # turn on after this time in ms self.syn.gmax = 0.05 # set conductance in uS self.syn.tau = 0.1 # set time constant # self.stim = h.IClamp(self.dend(1.0)) # self.stim.amp = 0.3 # input current in nA # self.stim.delay = 1 # turn on after this time in ms # self.stim.dur = 1 # duration of 1 ms # record soma voltage and time self.t_vec = h.Vector() self.t_vec.record(h._ref_t) neuron_utils.createStateVariable(id='time', name='time', units='ms', python_variable={ "record_variable": self.t_vec, "segment": None }) self.v_vec_soma = h.Vector() self.v_vec_soma.record(self.soma(1.0)._ref_v) # change recoding pos # TODO How do we extract the units? neuron_utils.createStateVariable(id='v_vec_soma', name='v_vec_soma', units='mV', python_variable={ "record_variable": self.v_vec_soma, "segment": self.soma(1.0) }) self.v_vec_dend = h.Vector() self.v_vec_dend.record(self.dend(1.0)._ref_v) # TODO How do we extract the units? neuron_utils.createStateVariable(id='v_vec_dend', name='v_vec_dend', units='mV', python_variable={ "record_variable": self.v_vec_dend, "segment": self.dend(1.0) }) # run simulation h.tstop = 60 # ms # h.run() neuron_geometries_utils.extractGeometries()
sim_length = float(args[7]) try: t_on = list(map(lambda x: float(x), args[8][1:len(args[8])-1].split(','))) except: t_on = [float(args[8])] save_dir = args[-1] axon.L = L axon.diam = diam axon.nseg = nseg axon.Ra = Ra axon.insert('hh') asyns = [h.AlphaSynapse(axon(0)), h.AlphaSynapse(axon(0))] for ix,t in enumerate(t_on): asyns[ix].onset = t asyns[ix].gmax = g_max h.tstop = sim_length t_vec = h.Vector() # Time stamp vector t_vec.record(h._ref_t) axon_segments = list(axon) v_vec = [] for axon_segment in axon_segments: v_vec.append(h.Vector()) v_vec[-1].record(axon_segment._ref_v) h.cvode_active(1)
# if segIndex % disp_len == 0: # Demyelinated axon properties # maxRange = 100 # for x in xrange(1,maxRange): # xIndexNorm_ = float(segIndex+(disp_len*3/4)-int(maxRange/2)+x)/float(axonMotor.nseg) # if segIndexNorm_+xIndexNorm_<1: # print x # # print "segIndex: %f" % (segIndex,) # axonMotor(segIndexNorm_+xIndexNorm_).hh.gnabar = 0.012*chan_scale#1e-9 (constant for Myelin study // 0.012*chan_scale for channels study) # axonMotor(segIndexNorm_+xIndexNorm_).hh.gkbar = 0.0036*chan_scale#1e-9 (constant for Myelin study // 0.0036*chan_scale for channels study) # axonMotor(segIndexNorm_+xIndexNorm_).hh.gl = gL#*1e-9 (constant for Myelin study // gL for channels study) # axonMotor(segIndexNorm_+xIndexNorm_).cm = 1. ''' We tried current clamp, but it worked as same as the Alpha Synapse ''' # Insert Alpha Synapse syn = h.AlphaSynapse(somaMotor(1.0)) syn.e = 0 # equilibrium potential in mV # syn.onset = 20 # turn on after this time in ms syn.gmax = 1e6 # set conductance in uS syn.tau = 1e-2 # set time constant # Set up plot t_vec = h.Vector() # record time t_vec.record(h._ref_t) v_vec_soma = h.Vector() # record soma v_vec_soma.record(somaMotor(0.5)._ref_v) # Setting up the recordings probe_rate = 0.01 axon_locs = np.arange(probe_rate, 1,
spine_head.insert('pas') #active conductances? spine_neck = h.Section(name='spine_neck') spine_neck.L = spine_neck_length spine_neck.diam = 0.200 spine_neck.Ra = 250 spine_neck.cm = 1 spine_neck.insert('pas') spineLoc = int(spine_soma_distance) #den_l/2 spine_neck.connect(dend[spineLoc](0.5), 0) spine_head.connect(spine_neck(1), 0) h.define_shape() # Translate into 3D points. syn = h.AlphaSynapse(spine_head(0.5)) syn.gmax = AMPAgmax #uS spike_onset = 20 #ms syn.onset = spike_onset #ms syn.tau = 1.5 #ms off kinetic syn.e = 0 # #uncomment for including of NMDA channels # #insert additional channels to synpase (NMDA for now, add Ca?) # NMDA_syn = h.Exp2SynNMDA(spine_head(0.5)) # conductance is set in uS # NMDA_syn.tau1 = 1 # NMDA_syn.tau2 = 25 # NC = h.NetCon(None, NMDA_syn, 0, 0, NMDAgmax) # connection; from, to, threshold, delay, weight # def synStim(): # NC.event(spike_onset)
def runsim_dendrite( tstop=500.0, dt=0.025, temp=21.0, somaL=15.0, somaD=15.0, somagleak=0.0003, dendL=250.0, dendD=2.0, dendgleak=0.00001, inputPos=0.9, inputStart=10.0, inputDur=1.0, inputAmp=0.5, syn1Pos=0.6, syn1Start=50.0, syn1g=0.01, syn1Erev=0.0, syn1Tau=25.0, syn2Pos=0.4, syn2Start=45.0, syn2g=0.005, syn2Erev=-80.0, syn2Tau=40.0, ): #DEFINE MODEL CELL Soma = h.Section() Soma.L = somaL Soma.nseg = 7 Soma.diam = somaD Soma.insert("hh") Soma.el_hh = -65.0 Soma.gl_hh = somagleak Soma.ena = 50 Soma.gnabar_hh = 0.13 Soma.gkbar_hh = 0.04 Dend = h.Section() Dend.L = dendL dendsegs = int(np.round(dendL / 10.0)) if dendsegs < 3: dendsegs = 3 Dend.nseg = dendsegs Dend.diam = dendD Dend.insert("pas") Dend.g_pas = dendgleak Dend.e_pas = -65.0 for sec in h.allsec(): sec.Ra = 150 Dend.connect(Soma(1)) #SYNAPSES syn1 = h.AlphaSynapse(Dend(syn1Pos)) syn1.onset = syn1Start syn1.tau = syn1Tau syn1.gmax = syn1g syn1.e = syn1Erev syn2 = h.AlphaSynapse(Dend(syn2Pos)) syn2.onset = syn2Start syn2.tau = syn2Tau syn2.gmax = syn2g syn2.e = syn2Erev #GENERAL SETTINGS h.dt = dt # simulation (or "sampling") rate h.celsius = temp # simulation global temperature #INSTRUMENTATION Electrode = h.IClamp(Dend(inputPos)) Electrode.delay = inputStart Electrode.amp = inputAmp Electrode.dur = inputDur SVm = h.Vector() SVm.record(Soma(0.5)._ref_v) DVm = h.Vector() DVm.record(Dend(inputPos)._ref_v) nrngo(tstop, -65.0) # PACK AND EXPORT DATA t = np.linspace(0, tstop - dt, int(np.round(tstop / dt))) SVm = np.array(SVm) DVm = np.array(DVm) return (t, SVm, DVm)
soma.insert('hh') ap_dend.L = 500.0 ap_dend.diam = 2 ap_dend.nseg = 23 ap_dend.insert('hh') ap_dend.gnabar_hh = 0.012 ap_dend.gkbar_hh = 0.0036 ap_dend.gl_hh = 0.00003 ap_dend.connect(soma, 1.0, 0) # synaptic input syn = h.AlphaSynapse(0.5, sec=ap_dend) #syn points to ap_dend,0.5 syn.onset = 5.0 syn.tau = 0.1 syn.gmax = 0.05 cvode = h.CVode() cvode.active(1) cvode.atol(1.0e-5) a = [] b = np.zeros(4) dt = 0.01 tstop = 20 v_init = -65
soma(0.5).hh.gnabar = 0.13 # Change the equilibrium potential of the passive mechanism in the middle segment of the dend to -65 dend(0.5).pas.e = -65 for sec in h.allsec(): for seg in sec: for mech in seg: print sec.name(), seg.x, mech.name() vstim = h.SEClamp(dend(1.0)) vstim.dur1 = 2 vstim.amp1 = -30 # add synapse (custom channel) syn = h.AlphaSynapse(dend(1.0)) syn.e = 0 # equilibrium potential in mV syn.onset = 20 # turn on after this time in ms syn.gmax = 0.1 # set conductance in uS syn.tau = 0.1 # set time constant # add current clamp stimulus stim = h.IClamp(dend(1.0)) stim.amp = 0.3 # input current in nA stim.delay = 40 # turn on after this time in ms stim.dur = 1 # duration of 1 ms # record soma voltage and time t_vec = h.Vector() v_vec_soma = h.Vector() v_vec_dend = h.Vector()
from neuron import h, gui # h for neuron interaction, gui to run simulation from matplotlib import pyplot # For plotting results import pickle soma = h.Section(name='soma') soma.insert('pas') # passive channel in soma asyn = h.AlphaSynapse(soma(0.5)) # insert an alpha synapse to soma segment asyn.onset = 20 asyn.gmax = 1 # recording variables v_vec = h.Vector() t_vec = h.Vector() v_vec.record(soma(0.5)._ref_v) t_vec.record(h._ref_t) h.tstop = 40.0 h.run() # plotting pyplot.figure(figsize=(8,4)) pyplot.plot(t_vec, v_vec) pyplot.xlabel('time (ms)') pyplot.ylabel('mV') pyplot.show(block=False) # save the vectors from simulation with open('t_vec.p', 'w') as t_vec_file: pickle.dump(t_vec.to_python(), t_vec_file) with open('v_vec.p', 'w') as v_vec_file: pickle.dump(v_vec.to_python(), v_vec_file)
print "type(soma(0.5)) =", type(soma(0.5)) ## Observing diff attributes of segments and their variables: mech = soma(0.5).pas print "Soma section .5, passive curent attributes: ", dir(mech) print " Soma section .5, passive curent conductance (g):", mech.g print " Soma section .5, passive curent resting potential (e): ", soma( 0.5).e_pas ## POINT PROCESS #################################################### #Inserting alpha synapse. This is equivalent to NEURON GUI point process menu asyn = h.AlphaSynapse( 0.5, sec=soma ) ## new point process. Pass the a-synapse the segment to whic it will bind ''' print "asyn.e", asyn.e print "asyn.gmax", asyn.gmax print "asyn.onset", asyn.onset print "asyn.tau", asyn.tau ''' print "Alpha synapse attributes: ", dir(asyn) asyn.onset = 20 asyn.gmax = 5 print " " print "CURRENT STATE OF SOMA:"