当前位置: 首页>>代码示例>>Python>>正文


Python h.run函数代码示例

本文整理汇总了Python中neuron.h.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

def run(tstop=1000, dt=0, V=-65):
    h.load_file('stdrun.hoc')
    #h.finitialize(V)
    if dt > 0:
        h.dt = dt
    h.tstop = tstop
    h.run()
开发者ID:David--Hunt,项目名称:CA3project,代码行数:7,代码来源:nrnutils.py

示例2: passive_soma

def passive_soma(quad, show=False):
  """
  Creates the model with basic pyramidal passive properties.
  """
  # Load the hoc into neuron
  h('xopen(%s)' %quad.hocfile)
  h.load_file('stdrun.hoc')
  seclist = list(h.allsec())
  for sec in seclist:
    sec.insert('pas')
    sec.Ra = 200.
  
  # Current injection into soma or tip
  soma_sec = return_soma_seg(quad, h)
  stim_loc = 0.
  stim = h.IClamp(stim_loc, sec=soma_sec)
  stim.delay = 1 # ms
  stim.dur = 1 # ms
  stim.amp = 20 # nA
  
  # Run sim and record data
  (v, labels) = ez_record(h) # PyNeuron to record all compartments
  t, I = h.Vector(), h.Vector()
  t.record(h._ref_t)
  I.record(stim._ref_i)
  h.init()
  h.tstop = 10 # s?
  h.run()
  v = ez_convert(v) # Convert v to numpy 2D array
  
  # If show, plot, else just return v
  if show:
开发者ID:ratliffj,项目名称:code,代码行数:32,代码来源:morpho_Neuron.py

示例3: simulate

def simulate(tstop=25):
    """Initialize and run a simulation.

    :param tstop: Duration of the simulation.
    """
    h.tstop = tstop
    h.run()
开发者ID:rdarie,项目名称:Spinal-Cord-Modeling,代码行数:7,代码来源:simrun.py

示例4: test_simple_synaptic_input

def test_simple_synaptic_input():
    soma = h.Section()
    soma.insert("hh")
    soma.insert("pas")
    tl = TargetLocation(soma, 0.5)
    proc = h.ExpSyn 

    ac = ArtificialCell()
    fire_times = np.linspace(0,50,10)
    firetimes = h.Vector(fire_times)
    ac.setFireTimes(firetimes)
    
    ic = InputConnection(ac, tl, proc)

    v = h.Vector()
    v.record(soma(0.5)._ref_v)
   
    h.tstop = 100
    h.run()

    test_result = np.array(v)
    correct = np.load("test_simple_synaptic_input_data.npy")

    print sum(abs(test_result - correct))

    #pyl.plot(test_result)
    #pyl.plot(correct)
    #pyl.show()

    assert np.all(test_result == correct)
开发者ID:mpelko,项目名称:neurovivo,代码行数:30,代码来源:test_network.py

示例5: simulation

def simulation(tstop, with_time = False):
    """
    runs the simulation and returns the current and
    time vectors as Numpy arrays
    """
    h.load_file('stdrun.hoc')
    h.v_init = -70
    
    h.tstop = tstop
    VC_patch.dur1 = tstop

    # define vectors
    current = h.Vector()
    current.record(VC_patch._ref_i)
   
    if with_time is True:
        time = h.Vector()
        time.record(h._ref_t)

    h.run()

    if with_time is True:
        return (time, np.array(current)*1000.)
    else:
        return np.array(current)*1000. 
开发者ID:JoseGuzman,项目名称:CA3-cable,代码行数:25,代码来源:Fig18A.py

示例6: main

def main():
    soma = h.Section()
    soma.insert('pas')
    soma.L = 100
    soma.diam = 100
    weight_min = 0.005
    weight_max = 0.05
    mu = (np.log(weight_min)+np.log(weight_max))/2
    sigma = (np.log(weight_max)-mu)/3
    weights = np.sort(np.exp(np.random.normal(mu,sigma,size=200)))
    synapses = [AMPASynapse(soma, 0.5, 0, w) for w in weights]
    for i,syn in enumerate(synapses):
        syn.set_presynaptic_spike_times([10+i*50])
    rec = {}
    for lbl in 't','v','g':
        rec[lbl] = h.Vector()
    rec['t'].record(h._ref_t)
    rec['v'].record(soma(0.5)._ref_v)
    rec['g'].record(syn.syn._ref_g)
    h.load_file('stdrun.hoc')
    h.v_init = -70
    h.celsius = 37
    h.tstop = len(weights)*50 + 100
    h.run()
    import pylab as p
    p.subplot(2,1,1)
    p.plot(rec['t'],rec['v'],'k')
    p.ylabel('Voltage (mV)')
    p.subplot(2,1,2)
    p.plot(rec['t'],rec['g'],'r')
    p.xlabel('Time (ms)')
    p.ylabel('Conductance (uS)')
    p.show()
开发者ID:David--Hunt,项目名称:CA3project,代码行数:33,代码来源:synapses.py

示例7: go

    def go(self):
        self.set_recording()
        h.dt = self.dt
        h.tstop = self.sim_time
        h.finitialize(-60)#self.v_init)
        h.init()
        h.run()

        self.rec_i = self.rec_ina.to_python()
开发者ID:CNS-OIST,项目名称:channeltune,代码行数:9,代码来源:simulation.py

示例8: find_vrest

def find_vrest(h, section_name):
    h.load_file("stdrun.hoc")
    tstop = 100
    h.dt = dt = 0.1
    soma, sec = fetch_soma_sec(section_name)
    h.init()
    h.cvode.re_init()
    t_vec, soma_vm, sec_vm = record(soma, sec)
    h.execute('tstop = 100')
    h.run()
    vrest = np.array(sec_vm)[-1]
    return vrest
开发者ID:ccluri,项目名称:L5Pyr,代码行数:12,代码来源:agnesnrn.py

示例9: get_vRest

def get_vRest(myEPas):
    """ 
    this functions returns the voltage in the given section
    as a function ePas. 
    
    Example:
    >>> get_vRest(soma(0.5), myEPas=-68)
    """
    mycell.soma.e_pas = myEPas
    
    h.run()
    return mycell.soma.v
开发者ID:JoseGuzman,项目名称:CA3-cable,代码行数:12,代码来源:calculateepas.py

示例10: run

def run():
    """
    Runs sim and plots figures, saves to outfig
    """
    t_vec.record(h._ref_t)
    v_vec.record(dend(0.5)._ref_v)
    h.tstop = 20000       #stop sim at 20000 ms or 20 s

    h.run()  # run sim
    outfig = "v" + date + ".png"
    pp.plot(t_vec, v_vec)    # plot time versus voltage
    pp.savefig(outfig)       # save figure using outfig
开发者ID:joeykabariti,项目名称:JKRepo,代码行数:12,代码来源:ihrxd.py

示例11: simulate_voltage

def simulate_voltage(tstop, list_seg):
    """ runs a simulation and recall the voltage vectors
    defined in segments entered in **args
    return a list of HocVector objects
    """
    myvector_list = list()
    for seg in list_seg:
        myvector_list.append(HocVector(seg))

    h.tstop = tstop
    h.run()

    # return a list of HocVector objects
    return myvector_list
开发者ID:JoseGuzman,项目名称:CA3-cable,代码行数:14,代码来源:CA3simulations.py

示例12: custom_cable

def custom_cable(length=526., tiprad=1.4, somarad=15.4, inj=1.2, 
                 tinj=1., injloc=1., Ra=35.4):
  """
  Simulate a simple passive current injection. Length=um, rads=um,
  inj=nA, tinj=ms, injloc=1 (tip). 
  Recorded from all 11 segments.
  """
  # Set up model
  h.load_file('stdrun.hoc')
  cell = h.Section()
  cell.nseg = 11   # It is a good idea to have nseg be an odd number
  cell.Ra = 35.4   # Ohm*cm
  cell.insert('pas')
  
  # Create structure
  h.pt3dadd(0,0,0,somarad,sec=cell)
  h.pt3dadd(length,0,0,tiprad,sec=cell)
  stim = h.IClamp(injloc, sec=cell)
  stim.delay = 5 # ms
  stim.dur = tinj # ms
  stim.amp = inj # nA
  print("Stim: %.2f nA, %.2f ms, at location %.2f" %(stim.amp, stim.dur,
                                                     injloc))
  
  # Segment positions, equall spaced from 0 to 1
  seg_positions = np.linspace(0,1,cell.nseg)
  # Use toolbox to record v
  # ez_record records v in all compartments by default
  (v,v_labels) = ez_record(h)
  # Manually record time and current
  t, I = h.Vector(), h.Vector()
  t.record(h._ref_t)
  I.record(stim._ref_i)
  
  # Run the simulation 
  h.init()
  h.tstop = 30
  h.run()
  # Use toolbox convert v into a numpy 2D array
  v = ez_convert(v) 
  
  # Plotting options
  fig = plt.figure()
  for i in range(cell.nseg):
    t = [v[u][i] for u in range(len(v))]
    ax = fig.add_subplot(cell.nseg, 1, i+1)
    ax.plot(t)
  plt.show()
  return h, v
开发者ID:ratliffj,项目名称:code,代码行数:49,代码来源:morpho_Neuron.py

示例13: main

def main(args):
    global nseg, nchan, simulator, _args
    _args = args
    loadModel(args.swc_file, args)
    print("Done loading")

    h.init()
    print("[INFO] Running NEURON for %s sec" % args.sim_time)
    t1 = time.time()
    h.tstop = 1e3 * float(args.sim_time)
    h.run()
    t = time.time() - t1
    print("Time taken by neuron: %s sec" % t)

    makePlots()
开发者ID:BhallaLab,项目名称:benchmarks,代码行数:15,代码来源:loader_neuron.py

示例14: passive_cable

def passive_cable(stimloc=1., stimdur=5., show=False):
  """
  This simulates a pulse injected into a simple passive cable.
  """
  # Set up model
  h.load_file('stdrun.hoc')
  cell = h.Section()
  cell.nseg = 11   # It is a good idea to have nseg be an odd number
  cell.Ra = 35.4   # Ohm*cm
  cell.insert('pas')
  
  # create 3d structure
  h.pt3dadd(0,0,0,1.0,sec=cell)
  h.pt3dadd(1732,1732,1732,1.0,sec=cell)
  # Specify current injection
  stim = h.IClamp(stimloc,sec=cell) # Stim @ 1th end of segment
  stim.delay = 5   # ms
  stim.dur = stimdur   # ms
  stim.amp = 0.2   # nA
  print("Stim: %.2f nA, %.2f ms, at location %.2f" %(stim.amp, stim.dur,
                                                     stimloc))
  
  # Segment positions, equall spaced from 0 to 1
  seg_positions = np.linspace(0,1,cell.nseg)
  # Use toolbox to record v
  # ez_record records v in all compartments by default
  (v,v_labels) = ez_record(h)
  # Manually record time and current
  t, I = h.Vector(), h.Vector()
  t.record(h._ref_t)
  I.record(stim._ref_i)
  
  # Run the simulation 
  h.init()
  h.tstop = 30
  h.run()
  # Use toolbox convert v into a numpy 2D array
  v = ez_convert(v)
  
  # Plotting options
  if show:
    fig = plt.figure()
    for i in range(cell.nseg):
      t = [v[u][i] for u in range(len(v))]
      ax = fig.add_subplot(cell.nseg, 1, i+1)
      ax.plot(t)
    plt.show()
  return h, v
开发者ID:ratliffj,项目名称:code,代码行数:48,代码来源:morpho_Neuron.py

示例15: iclamp

def iclamp(cell, sec, i_inj, v_init, tstop, dt, celsius=35, pos_i=0.5, pos_v=0.5):
    """
    Runs a NEURON simulation of the cell for the given parameters.

    :param sec: List with 1st entry the name of the section and 2nd entry the index (or None in case of soma)
    :type sec: list[str, int]
    :param i_inj: Amplitude of the injected current for all times t.
    :type i_inj: array_like
    :param v_init: Initial membrane potential of the cell.
    :type v_init: float
    :param tstop: Duration of a whole run.
    :type tstop: float
    :param dt: Time step.
    :type dt: float
    :param celsius: Temperature during the simulation (affects ion channel kinetics).
    :type celsius: float
    :param pos_i: Position of the IClamp on the Section (number between 0 and 1).
    :type pos_i: float
    :param pos_v: Position of the recording electrode on the Section (number between 0 and 1).
    :type pos_v: float
    :return: Membrane potential of the cell and time recorded at each time step.
    :rtype: tuple of three ndarrays
    """

    section = cell.substitute_section(sec[0], sec[1])

    # time
    t = np.arange(0, tstop + dt, dt)

    # insert an IClamp with the current trace from the experiment
    stim, i_vec, t_vec = section.play_current(i_inj, t, pos_i)

    # record the membrane potential
    v = section.record('v', pos_v)
    t = h.Vector()
    t.record(h._ref_t)

    # run simulation
    h.celsius = celsius
    h.v_init = v_init
    h.tstop = tstop
    h.steps_per_ms = 1 / dt  # change steps_per_ms before dt, otherwise dt not changed properly
    h.dt = dt
    h.run()

    return np.array(v), np.array(t)
开发者ID:cafischer,项目名称:nrn_wrapper,代码行数:46,代码来源:__init__.py


注:本文中的neuron.h.run函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。