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


Python moose.reinit函数代码示例

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


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

示例1: main

def main():
	"""
	This snippet shows the use of several objects.
	This snippet sets up a StimulusTable to control a RandSpike which
	sends its outputs to two places: to a SimpleSynHandler on an IntFire,
	which is used to monitor spike arrival, and to various Stats objects.
    Each of these are recorded and plotted.
	The StimulusTable has a sine-wave waveform.
	"""
        make_model()

        moose.reinit()
        moose.start( runtime )
        plots = moose.element( '/plots' )
        plot1 = moose.element( '/plot1' )
        plot2 = moose.element( '/plot2' )
        plotf = moose.element( '/plotf' )
        t = [i * dt for i in range( plot1.vector.size )]
        pylab.plot( t, plots.vector, label='stimulus' )
        pylab.plot( t, plot1.vector, label='spike rate mean' )
        pylab.plot( t, plot2.vector, label='Vm mean' )
        pylab.plot( t, plotf.vector, label='Vm' )
        pylab.legend()
        pylab.show()

	'''
开发者ID:asiaszmek,项目名称:moose,代码行数:26,代码来源:RandSpikeStats.py

示例2: main

def main():
    global synSpineList 
    global synDendList 
    numpy.random.seed( 1234 )
    rdes = buildRdesigneur( )
    for i in elecFileNames:
        print(i)
        rdes.cellProtoList = [ ['./cells/' + i, 'elec'] ]
        rdes.buildModel( )
        assert( moose.exists( '/model' ) )
        synSpineList = moose.wildcardFind( "/model/elec/#head#/glu,/model/elec/#head#/NMDA" )
        temp = set( moose.wildcardFind( "/model/elec/#/glu,/model/elec/#/NMDA" ) )

        synDendList = list( temp - set( synSpineList ) )
        moose.reinit()
        buildPlots( rdes )
        # Run for baseline, tetanus, and post-tetanic settling time 
        t1 = time.time()
        probeStimulus( baselineTime )
        tetanicStimulus( tetTime )
        probeStimulus( postTetTime )
        print(('real time = ', time.time() - t1))

        printPsd( i + ".fig5" )
        saveAndClearPlots( i + ".fig5" )
        moose.delete( '/model' )
        rdes.elecid = moose.element( '/' )
开发者ID:dilawar,项目名称:moose-examples,代码行数:27,代码来源:Fig5BCD.py

示例3: run

def run(nogui):
    
    reader = NML2Reader(verbose=True)

    filename = 'test_files/NML2_SingleCompHHCell.nml'
    print('Loading: %s'%filename)
    reader.read(filename, symmetric=True)
    
    
    msoma = reader.getComp(reader.doc.networks[0].populations[0].id,0,0)
    print(msoma)
    
    
    data = moose.Neutral('/data')
    
    pg = reader.getInput('pulseGen1')
    
    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')
    
    
    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')
    
    simdt = 1e-6
    plotdt = 1e-4
    simtime = 300e-3
    #moose.showmsg( '/clock' )
    for i in range(8):
        moose.setClock( i, simdt )
    moose.setClock( 8, plotdt )
    moose.reinit()
    moose.start(simtime)
    
    print("Finished simulation!")
    
    t = np.linspace(0, simtime, len(vm.vector))
    
    if not nogui:
        import matplotlib.pyplot as plt

        vfile = open('moose_v_hh.dat','w')

        for i in range(len(t)):
            vfile.write('%s\t%s\n'%(t[i],vm.vector[i]))
        vfile.close()
        plt.subplot(211)
        plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
        plt.legend()
        plt.title('Vm')
        plt.subplot(212)
        plt.title('Input')
        plt.plot(t, inj.vector * 1e9, label='injected (nA)')
        #plt.plot(t, gK.vector * 1e6, label='K')
        #plt.plot(t, gNa.vector * 1e6, label='Na')
        plt.legend()
        plt.figure()
        test_channel_gates()
        plt.show()
        plt.close()
开发者ID:hrani,项目名称:moose-core,代码行数:60,代码来源:run_hhcell.py

示例4: simulate

    def simulate(self,simtime=simtime,dt=dt,plotif=False,**kwargs):
        
        self.dt = dt
        self.simtime = simtime
        self.T = np.ceil(simtime/dt)
        self.trange = np.arange(0,self.simtime+dt,dt)   
        
        self._init_network(**kwargs)
        if plotif:
            self._init_plots()
        
        # moose simulation
        # moose auto-schedules
        #moose.useClock( 0, '/network/syns', 'process' )
        #moose.useClock( 1, '/network', 'process' )
        #moose.useClock( 2, '/plotSpikes', 'process' )
        #moose.useClock( 3, '/plotVms', 'process' )
        #moose.useClock( 3, '/plotWeights', 'process' )
        for i in range(10):
            moose.setClock( i, dt )

        t1 = time.time()
        print('reinit MOOSE')
        moose.reinit()
        print(('reinit time t = ', time.time() - t1))
        t1 = time.time()
        print('starting')
        moose.start(self.simtime)
        print(('runtime, t = ', time.time() - t1))

        if plotif:
            self._plot()
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:32,代码来源:ExcInhNet_Ostojic2014_Brunel2000.py

示例5: singleCompt

def singleCompt( name, params ):
    mod = moose.copy( '/library/' + name + '/' + name, '/model' )
    A = moose.element( mod.path + '/A' )
    Z = moose.element( mod.path + '/Z' )
    Z.nInit = 1
    Ca = moose.element( mod.path + '/Ca' )
    CaStim = moose.element( Ca.path + '/CaStim' )
    runtime = params['preStimTime'] + params['stimWidth'] + params['postStimTime'] 
    steptime = 100

    CaStim.expr += ' + x2 * (t > ' + str( runtime ) + ' ) * ( t < ' + str( runtime + steptime ) +  ' )'
    print(CaStim.expr)
    tab = moose.Table2( '/model/' + name + '/Atab' )
    #for i in range( 10, 19 ):
        #moose.setClock( i, 0.01 )
    ampl = moose.element( mod.path + '/ampl' )
    phase = moose.element( mod.path + '/phase' )
    moose.connect( tab, 'requestOut', A, 'getN' )
    ampl.nInit = params['stimAmplitude'] * 1
    phase.nInit = params['preStimTime']

    ksolve = moose.Ksolve( mod.path + '/ksolve' )
    stoich = moose.Stoich( mod.path + '/stoich' )
    stoich.compartment = mod
    stoich.ksolve = ksolve
    stoich.path = mod.path + '/##'
    runtime += 2 * steptime

    moose.reinit()
    moose.start( runtime )
    t = np.arange( 0, runtime + 1e-9, tab.dt )
    return name, t, tab.vector
开发者ID:dilawar,项目名称:moose-examples,代码行数:32,代码来源:Fig2_v4.py

示例6: main

def main():
        """
        This example illustrates loading, and running a kinetic model 
        for a bistable positive feedback system, defined in kkit format. 
        This is based on Bhalla, Ram and Iyengar, Science 2002.

        The core of this model is a positive feedback loop comprising of
        the MAPK cascade, PLA2, and PKC. It receives PDGF and Ca2+ as 
        inputs.

        This model is quite a large one and due to some stiffness in its
        equations, it runs somewhat slowly. 

        The simulation illustrated here shows how the model starts out in
        a state of low activity. It is induced to 'turn on' when a 
        a PDGF stimulus is given for 400 seconds. 
        After it has settled to the new 'on' state, model is made to 
        'turn off'
        by setting the system calcium levels to zero for a while. This
        is a somewhat unphysiological manipulation!
        """
        solver = "gsl"  # Pick any of gsl, gssa, ee..
        #solver = "gssa"  # Pick any of gsl, gssa, ee..
	mfile = '../../genesis/acc35.g'
	runtime = 2000.0
	if ( len( sys.argv ) == 2 ):
                solver = sys.argv[1]
	modelId = moose.loadModel( mfile, 'model', solver )
        # Increase volume so that the stochastic solver gssa 
        # gives an interesting output
        compt = moose.element( '/model/kinetics' )
        compt.volume = 5e-19 

	moose.reinit()
	moose.start( 500 ) 
        moose.element( '/model/kinetics/PDGFR/PDGF' ).concInit = 0.0001
	moose.start( 400 ) 
        moose.element( '/model/kinetics/PDGFR/PDGF' ).concInit = 0.0
	moose.start( 2000 ) 
        moose.element( '/model/kinetics/Ca' ).concInit = 0.0
	moose.start( 500 ) 
        moose.element( '/model/kinetics/Ca' ).concInit = 0.00008
	moose.start( 2000 ) 

	# Display all plots.
        img = mpimg.imread( 'mapkFB.png' )
        fig = plt.figure( figsize=(12, 10 ) )
        png = fig.add_subplot( 211 )
        imgplot = plt.imshow( img )
        ax = fig.add_subplot( 212 )
	x = moose.wildcardFind( '/model/#graphs/conc#/#' )
        t = numpy.arange( 0, x[0].vector.size, 1 ) * x[0].dt
        ax.plot( t, x[0].vector, 'b-', label=x[0].name )
        ax.plot( t, x[1].vector, 'c-', label=x[1].name )
        ax.plot( t, x[2].vector, 'r-', label=x[2].name )
        ax.plot( t, x[3].vector, 'm-', label=x[3].name )
        plt.ylabel( 'Conc (mM)' )
        plt.xlabel( 'Time (seconds)' )
        pylab.legend()
        pylab.show()
开发者ID:2pysarthak,项目名称:moose-examples,代码行数:60,代码来源:mapkFB.py

示例7: deliverStim

def deliverStim(currTime):
	global injectionCurrent	
	global spineVm
	global somaVm
	if numpy.fabs( currTime - baselineTime ) < frameRunTime/2.0 :
		#start
		eList = moose.wildcardFind( '/model/elec/#soma#' )
		assert( len(eList) > 0 )
		eList[0].inject = injectionCurrent
		#print "1. injected current = ", injectionCurrent
		injectionCurrent += deltaCurrent
		#print "del stim first ", moose.element('/clock').currentTime
	if numpy.fabs( currTime - baselineTime - currPulseTime) < frameRunTime/2.0 :
		#end
		eList = moose.wildcardFind( '/model/elec/#soma#' )
		assert( len(eList) > 0 )
		eList[0].inject = 0.0
		#print "2. injected current = ", injectionCurrent
		#print "del stim second ", moose.element('/clock').currentTime
	if runtime - currTime < frameRunTime * 2.0 :
		#print "3. reinit-ing"
		somaVm.append( moose.element( '/graphs/VmTab' ).vector )
		spineVm.append( moose.element( '/graphs/eSpineVmTab' ).vector )
		iList.append(injectionCurrent)
		if injectionCurrent < maxCurrent :
			moose.reinit()	
开发者ID:chaitrasarathy,项目名称:mooseCodes,代码行数:26,代码来源:currentStep_CA3PC-Narayanan2010_v1.0.py

示例8: resetSimulation

 def resetSimulation(self, runTime, updateInterval, simulationInterval):
     self.runTime            = runTime
     self.updateInterval     = updateInterval
     self.simulationInterval = simulationInterval
     self.pause              = False
     moose.reinit()
     self.simulationReset.emit()
开发者ID:NeuroArchive,项目名称:moose,代码行数:7,代码来源:Runner.py

示例9: test

def test():
    global finish_all_
    os.environ['MOOSE_STREAMER_ADDRESS'] = 'http://127.0.0.1:%d'%port_
    done = mp.Value('d', 0)
    q = mp.Queue()
    client = mp.Process(target=socket_client, args=(q, done))
    client.start()

    time.sleep(0.1)

    print( '[INFO] Socket client is running now' )
    ts = models.simple_model_a()
    moose.reinit()
    time.sleep(0.1)
    # If TCP socket is created, some delay is often neccessary before start. Don't
    # know why. probably some latency in a fresh TCP socket. A TCP guru can
    # tell.
    moose.start(50)
    print( 'MOOSE is done' )

    time.sleep(0.5)
    done.value = 1
    res = q.get()
    client.join()

    if not res:
        raise RuntimeWarning('Nothing was streamed')
    for k in res:
        a = res[k][1::2]
        b = moose.element(k).vector
        print(k, len(a), len(b))
        assert( (a==b).all())
    print( 'Test 1 passed' )
开发者ID:hrani,项目名称:moose-core,代码行数:33,代码来源:testDisabled_socket_streamer_tcp.py

示例10: resetAndStartSimulation

 def resetAndStartSimulation(self):
     """TODO this should provide a clean scheduling through all kinds
     of simulation or default scheduling should be implemented in MOOSE
     itself. We need to define a policy for handling scheduling. It can
     be pushed to the plugin-developers who should have knowledge of
     the scheduling criteria for their domain."""
     settings = config.MooseSetting()
     try:
         simdt_kinetics = float(settings[config.KEY_KINETICS_SIMDT])
     except ValueError:
         simdt_kinetics = 0.1
     try:
         simdt_electrical = float(settings[config.KEY_ELECTRICAL_SIMDT])
     except ValueError:
         simdt_electrical = 0.25e-4
     try:
         plotdt_kinetics = float(settings[config.KEY_KINETICS_PLOTDT])
     except ValueError:
         plotdt_kinetics = 0.1
     try:
         plotdt_electrical = float(settings[config.KEY_ELECTRICAL_PLOTDT])
     except ValueError:
         plotdt_electrical = 0.25e-3
     try:
         simtime = float(settings[config.KEY_SIMTIME])
     except ValueError:
         simtime = 1.0
     moose.reinit()
     view = self.plugin.getRunView()
     moose.start(simtime)
     if view.getCentralWidget().plotAll:
         view.getCentralWidget().plotAllData()
     self.setCurrentView('run')        
开发者ID:Vivek-sagar,项目名称:moose-1,代码行数:33,代码来源:mgui.py

示例11: run_single_channel

def run_single_channel(channelname, Gbar, simtime, simdt=testutils.SIMDT, plotdt=testutils.PLOTDT):
    testId = uuid.uuid4().int
    container = moose.Neutral('test%d' % (testId))
    model_container = moose.Neutral('%s/model' % (container.path))
    data_container = moose.Neutral('%s/data' % (container.path))
    params = testutils.setup_single_compartment(
        model_container, data_container,
        channelbase.prototypes[channelname],
        Gbar)
    vm_data = params['Vm']
    gk_data = params['Gk']
    ik_data = params['Ik']
    testutils.setup_clocks(simdt, plotdt)
    testutils.assign_clocks(model_container, data_container)
    moose.reinit()
    print 'Starting simulation', testId, 'for', simtime, 's'
    moose.start(simtime)
    print 'Finished simulation'
    vm_file = 'data/%s_Vm.dat' % (channelname)
    gk_file = 'data/%s_Gk.dat' % (channelname)
    ik_file = 'data/%s_Ik.dat' % (channelname)
    tseries = np.array(range(len(vm_data.vec))) * simdt
    print 'Vm:', len(vm_data.vec), 'Gk', len(gk_data.vec), 'Ik', len(ik_data.vec)
    data = np.c_[tseries, vm_data.vec]
    np.savetxt(vm_file, data)
    print 'Saved Vm in', vm_file
    print len(gk_data.vec), len(vm_data.vec)
    data = np.c_[tseries, gk_data.vec]
    np.savetxt(gk_file, data)
    print 'Saved Gk in', gk_file
    data = np.c_[tseries, ik_data.vec]
    np.savetxt(ik_file, data)
    print 'Saved Gk in', ik_file
    return params
开发者ID:OpenSourceBrain,项目名称:Thalamocortical,代码行数:34,代码来源:channel_test_util.py

示例12: main

def main():
    """
    A toy compartmental neuronal + chemical model that causes bad things
    to happen to the hsolver, as of 28 May 2013. Hopefully this will
    become irrelevant soon.
    """
    fineDt = 1e-5
    coarseDt = 5e-5
    make_spiny_compt()
    make_plots()
    for i in range( 8 ):
        moose.setClock( i, fineDt )
    moose.setClock( 8, coarseDt )
    moose.reinit()
    moose.start( 0.1 )
    display_plots( 'instab.plot' )
    # make Hsolver and rerun
    hsolve = moose.HSolve( '/n/hsolve' )
    for i in range( 8 ):
        moose.setClock( i, coarseDt )
    hsolve.dt = coarseDt
    hsolve.target = '/n/compt'
    moose.reinit()
    moose.start( 0.1 )
    display_plots( 'h_instab.plot' )
    pylab.show()
开发者ID:asiaszmek,项目名称:moose,代码行数:26,代码来源:HsolveInstability.py

示例13: main

def main():
		makeModel()
                '''
                '''
		ksolve = moose.Ksolve( '/model/compartment/ksolve' )
		stoich = moose.Stoich( '/model/compartment/stoich' )
		stoich.compartment = moose.element( '/model/compartment' )
		stoich.ksolve = ksolve
		stoich.path = "/model/compartment/##"
		#solver.method = "rk5"
		#mesh = moose.element( "/model/compartment/mesh" )
		#moose.connect( mesh, "remesh", solver, "remesh" )
                '''
		moose.setClock( 5, 1.0 ) # clock for the solver
		moose.useClock( 5, '/model/compartment/ksolve', 'process' )
                '''

		moose.reinit()
		moose.start( 100.0 ) # Run the model for 100 seconds.
                func = moose.element( '/model/compartment/d/func' )
                if useY:
                    func.expr = "-y0 + 10*y1"
                else:
                    func.expr = "-x0 + 10*x1"
		moose.start( 100.0 ) # Run the model for 100 seconds.
                #moose.showfields( '/model/compartment/d' )
                #moose.showfields( '/model/compartment/d/func' )
                print func.x.value
                print moose.element( '/model/compartment/b' ).n

		# Iterate through all plots, dump their contents to data.plot.
		displayPlots()

		quit()
开发者ID:2pysarthak,项目名称:moose-examples,代码行数:34,代码来源:changeFuncExpression.py

示例14: main

def main():
    makeModel()
    gsolve = moose.Gsolve("/model/compartment/gsolve")
    stoich = moose.Stoich("/model/compartment/stoich")
    stoich.compartment = moose.element("/model/compartment")
    stoich.ksolve = gsolve
    stoich.path = "/model/compartment/##"
    # solver.method = "rk5"
    # mesh = moose.element( "/model/compartment/mesh" )
    # moose.connect( mesh, "remesh", solver, "remesh" )
    moose.setClock(5, 1.0)  # clock for the solver
    moose.useClock(5, "/model/compartment/gsolve", "process")

    moose.reinit()
    moose.start(100.0)  # Run the model for 100 seconds.

    a = moose.element("/model/compartment/a")
    b = moose.element("/model/compartment/b")

    # move most molecules over to bgsolve
    b.conc = b.conc + a.conc * 0.9
    a.conc = a.conc * 0.1
    moose.start(100.0)  # Run the model for 100 seconds.

    # move most molecules back to a
    a.conc = a.conc + b.conc * 0.99
    b.conc = b.conc * 0.01
    moose.start(100.0)  # Run the model for 100 seconds.

    # Iterate through all plots, dump their contents to data.plot.
    displayPlots()

    quit()
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:33,代码来源:scriptGssaSolver.py

示例15: test_elec_alone

def test_elec_alone():
    eeDt = 2e-6
    hSolveDt = 2e-5
    runTime = 0.02

    make_spiny_compt()
    make_elec_plots()
    head2 = moose.element( '/n/head2' )
    moose.setClock( 0, 2e-6 )
    moose.setClock( 1, 2e-6 )
    moose.setClock( 2, 2e-6 )
    moose.setClock( 8, 0.1e-3 )
    moose.useClock( 0, '/n/##[ISA=Compartment]', 'init' )
    moose.useClock( 1, '/n/##[ISA=Compartment]', 'process' )
    moose.useClock( 2, '/n/##[ISA=ChanBase],/n/##[ISA=SynBase],/n/##[ISA=CaConc],/n/##[ISA=SpikeGen]','process')
    moose.useClock( 8, '/graphs/elec/#', 'process' )
    moose.reinit()
    moose.start( runTime )
    dump_plots( 'instab.plot' )
    print "||||", len(moose.wildcardFind('/##[ISA=HHChannel]'))
    # make Hsolver and rerun
    hsolve = moose.HSolve( '/n/hsolve' )
    moose.useClock( 1, '/n/hsolve', 'process' )
    hsolve.dt = 20e-6
    hsolve.target = '/n/compt'
    moose.le( '/n' )
    for dt in ( 20e-6, 50e-6, 100e-6 ):
        print 'running at dt =', dt
        moose.setClock( 0, dt )
        moose.setClock( 1, dt )
        moose.setClock( 2, dt )
        hsolve.dt = dt
        moose.reinit()
        moose.start( runTime )
        dump_plots( 'h_instab' + str( dt ) + '.plot' )
开发者ID:csiki,项目名称:MOOSE,代码行数:35,代码来源:testHsolve.py


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