コード例 #1
0
def transformNMDAR( path ):
    for i in moose.wildcardFind( path + "/##/#NMDA#[ISA!=NMDAChan]" ):
        chanpath = i.path
        pa = i.parent
        i.name = '_temp'
        if ( chanpath[-3:] == "[0]" ):
            chanpath = chanpath[:-3]
        nmdar = moose.NMDAChan( chanpath )
        sh = moose.SimpleSynHandler( chanpath + '/sh' )
        moose.connect( sh, 'activationOut', nmdar, 'activation' )
        sh.numSynapses = 1
        sh.synapse[0].weight = 1
        nmdar.Ek = i.Ek
        nmdar.tau1 = i.tau1
        nmdar.tau2 = i.tau2
        nmdar.Gbar = i.Gbar
        nmdar.CMg = 12
        nmdar.KMg_A = 1.0 / 0.28
        nmdar.KMg_B = 1.0 / 62
        nmdar.temperature = 300
        nmdar.extCa = 1.5
        nmdar.intCa = 0.00008
        nmdar.intCaScale = 1
        nmdar.intCaOffset = 0.00008
        nmdar.condFraction = 0.02
        moose.delete( i )
        moose.connect( pa, 'channel', nmdar, 'channel' )
        caconc = moose.wildcardFind( pa.path + '/#[ISA=CaConcBase]' )
        if ( len( caconc ) < 1 ):
            print('no caconcs found on ', pa.path)
        else:
            moose.connect( nmdar, 'ICaOut', caconc[0], 'current' )
            moose.connect( caconc[0], 'concOut', nmdar, 'assignIntCa' )
コード例 #2
0
ファイル: rdesigneur.py プロジェクト: DineshDevPandey/moose
 def _addSpine( self, parent, spineProto, pos, angle, x, y, z, size, k ):
     spine = moose.copy( spineProto, parent.parent, 'spine' + str(k) )
     kids = spine[0].children
     coords = []
     ppos = np.array( [parent.x0, parent.y0, parent.z0] )
     for i in kids:
         #print i.name, k
         j = i[0]
         j.name += str(k)
         #print 'j = ', j
         coords.append( [j.x0, j.y0, j.z0] )
         coords.append( [j.x, j.y, j.z] )
         self._scaleSpineCompt( j, size )
         moose.move( i, self.elecid )
     origin = coords[0]
     #print 'coords = ', coords
     # Offset it so shaft starts from surface of parent cylinder
     origin[0] -= parent.diameter / 2.0 
     coords = np.array( coords )
     coords -= origin # place spine shaft base at origin.
     rot = np.array( [x, [0,0,0], [0,0,0]] )
     coords = np.dot( coords, rot )
     moose.delete( spine )
     moose.connect( parent, "raxial", kids[0], "axial" )
     self._reorientSpine( kids, coords, ppos, pos, size, angle, x, y, z )
コード例 #3
0
 def _addSpine(self, parent, spineProto, pos, angle, x, y, z, size, k):
     spine = moose.copy(spineProto, parent.parent, 'spine' + str(k))
     kids = spine[0].children
     coords = []
     ppos = np.array([parent.x0, parent.y0, parent.z0])
     for i in kids:
         #print i.name, k
         j = i[0]
         j.name += str(k)
         #print 'j = ', j
         coords.append([j.x0, j.y0, j.z0])
         coords.append([j.x, j.y, j.z])
         self._scaleSpineCompt(j, size)
         moose.move(i, self.elecid)
     origin = coords[0]
     #print 'coords = ', coords
     # Offset it so shaft starts from surface of parent cylinder
     origin[0] -= parent.diameter / 2.0
     coords = np.array(coords)
     coords -= origin  # place spine shaft base at origin.
     rot = np.array([x, [0, 0, 0], [0, 0, 0]])
     coords = np.dot(coords, rot)
     moose.delete(spine)
     moose.connect(parent, "raxial", kids[0], "axial")
     self._reorientSpine(kids, coords, ppos, pos, size, angle, x, y, z)
コード例 #4
0
ファイル: bigElec.py プロジェクト: BhallaLab/benchmarks
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( '/model' )
        rdes.soma.inject = inject
        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 ) )
        print("[INFO] reinitialzing")
        moose.reinit()
        buildPlots( rdes )
        # Run for baseline, tetanus, and post-tetanic settling time 
        t1 = time.time()
        moose.start( runtime )
        print('runtime = ', runtime, '; real time = ', time.time() - t1)

        saveAndClearPlots( "bigElec" )
        moose.delete( '/model' )
        rdes.elecid = moose.element( '/' )
コード例 #5
0
ファイル: rdesigneurProtos.py プロジェクト: BhallaLab/moose
def transformNMDAR(path):
    for i in moose.wildcardFind(path + "/##/#NMDA#[ISA!=NMDAChan]"):
        chanpath = i.path
        pa = i.parent
        i.name = "_temp"
        if chanpath[-3:] == "[0]":
            chanpath = chanpath[:-3]
        nmdar = moose.NMDAChan(chanpath)
        sh = moose.SimpleSynHandler(chanpath + "/sh")
        moose.connect(sh, "activationOut", nmdar, "activation")
        sh.numSynapses = 1
        sh.synapse[0].weight = 1
        nmdar.Ek = i.Ek
        nmdar.tau1 = i.tau1
        nmdar.tau2 = i.tau2
        nmdar.Gbar = i.Gbar
        nmdar.CMg = 12
        nmdar.KMg_A = 1.0 / 0.28
        nmdar.KMg_B = 1.0 / 62
        nmdar.temperature = 300
        nmdar.extCa = 1.5
        nmdar.intCa = 0.00008
        nmdar.intCaScale = 1
        nmdar.intCaOffset = 0.00008
        nmdar.condFraction = 0.02
        moose.delete(i)
        moose.connect(pa, "channel", nmdar, "channel")
        caconc = moose.wildcardFind(pa.path + "/#[ISA=CaConcBase]")
        if len(caconc) < 1:
            print("no caconcs found on ", pa.path)
        else:
            moose.connect(nmdar, "ICaOut", caconc[0], "current")
            moose.connect(caconc[0], "concOut", nmdar, "assignIntCa")
コード例 #6
0
    def buildModel(self, modelPath='/model'):
        if moose.exists(modelPath):
            print("rdesigneur::buildModel: Build failed. Model '", modelPath,
                  "' already exists.")
            return
        self.model = moose.Neutral(modelPath)
        self.modelPath = modelPath
        try:
            # Protos made in the init phase. Now install the elec and
            # chem protos on model.
            self.installCellFromProtos()
            # Now assign all the distributions
            self.buildPassiveDistrib()
            self.buildChanDistrib()
            self.buildSpineDistrib()
            self.buildChemDistrib()
            self._configureSolvers()
            self.buildAdaptors()
            self._buildPlots()
            self._buildMoogli()
            self._buildStims()
            self._configureClocks()
            self._printModelStats()

        except BuildError as msg:
            print("Error: rdesigneur: model build failed:", msg)
            moose.delete(self.model)
コード例 #7
0
def updateDisplay():
    makeYmodel()
    tabvec = moose.wildcardFind('/model/graphs/plot#')
    moose.element('/model/elec/').name = 'Y'
    vecYdend = moose.wildcardFind('/model/Y/soma,/model/Y/dend#')
    vecYbranch1 = moose.wildcardFind('/model/Y/branch1#')
    vecYbranch2 = moose.wildcardFind('/model/Y/branch2#')
    moose.reinit()
    dt = interval1
    currtime = 0.0
    for i in lines:
        moose.start(dt)
        currtime += dt
        #print "############## NumDendData = ", len( vecYdend )
        i.YdendLines.set_ydata([v.Vm * 1000 for v in vecYdend])
        i.Ybranch1Lines.set_ydata([v.Vm * 1000 for v in vecYbranch1])
        i.Ybranch2Lines.set_ydata([v.Vm * 1000 for v in vecYbranch2])
        dt = interval2

    moose.start(runtime - currtime)

    #print "############## len (tabvec)  = ", len( tabvec[0].vector )
    for i, tab in zip(tplot, tabvec):
        i.set_ydata(tab.vector * 1000)

    moose.delete('/model')
    moose.delete('/library')
コード例 #8
0
def loadAndRun(solver=True):
    simtime = 500e-3
    model = moose.loadModel('../data/h10.CNG.swc', '/cell')
    comp = moose.element('/cell/apical_e_177_0')
    soma = moose.element('/cell/soma')
    for i in range(10):
        moose.setClock(i, dt)
    if solver:
        solver = moose.HSolve('/cell/solver')
        solver.target = soma.path
        solver.dt = dt
    stim = moose.PulseGen('/cell/stim')
    stim.delay[0] = 50e-3
    stim.delay[1] = 1e9
    stim.level[0] = 1e-9
    stim.width[0] = 2e-3
    moose.connect(stim, 'output', comp, 'injectMsg')
    tab = moose.Table('/cell/Vm')
    moose.connect(tab, 'requestOut', comp, 'getVm')
    tab_soma = moose.Table('/cell/Vm_soma')
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.reinit()
    print('[INFO] Running for %s' % simtime)
    moose.start(simtime )
    vec = tab_soma.vector
    moose.delete( '/cell' )
    return vec
コード例 #9
0
def main(standalone=False):
    mfile = os.path.join(os.path.dirname(__file__), 'OSC_diff_vols.g')
    runtime = 4000.0
    modelId = moose.loadModel(mfile, 'model', 'ee')
    kin = moose.element('/model/kinetics')
    compt1 = moose.element('/model/compartment_1')
    compt1.x1 += kin.x1
    compt1.x0 += kin.x1
    fixXreacs.fixXreacs('/model')
    #fixXreacs.restoreXreacs( '/model' )
    #fixXreacs.fixXreacs( '/model' )

    ks1 = moose.Ksolve('/model/kinetics/ksolve')
    ds1 = moose.Dsolve('/model/kinetics/dsolve')
    s1 = moose.Stoich('/model/kinetics/stoich')
    s1.compartment = moose.element('/model/kinetics')
    s1.ksolve = ks1
    s1.dsolve = ds1
    s1.path = '/model/kinetics/##'

    ks2 = moose.Ksolve('/model/compartment_1/ksolve')
    ds2 = moose.Dsolve('/model/compartment_1/dsolve')
    s2 = moose.Stoich('/model/compartment_1/stoich')
    s2.compartment = moose.element('/model/compartment_1')
    s2.ksolve = ks2
    s2.dsolve = ds2
    s2.path = '/model/compartment_1/##'

    ds2.buildMeshJunctions(ds1)

    moose.reinit()
    moose.start(runtime)
    # I don't have an analytic way to assess oscillations
    assert (countCrossings('/model/graphs/conc2/M.Co', 0.001) == 4)
    moose.delete('/model')
コード例 #10
0
ファイル: run92_simple.py プロジェクト: Ainurrohmah/Scripts
def main( runTime ):
    try:
        moose.delete('/acc92')
        print("Deleted old model")
    except Exception as  e:
        print("Could not clean. model not loaded yet")

    moose.loadModel('acc92_caBuff.g',loadpath,'gsl')  
    ca = moose.element(loadpath+'/kinetics/Ca')
    pr = moose.element(loadpath+'/kinetics/protein')
    clockdt = moose.Clock('/clock').dts 
    moose.setClock(8, 0.1)#simdt
    moose.setClock(18, 0.1)#plotdt
    print clockdt
    print " \t \t simdt ", moose.Clock('/clock').dts[8],"plotdt ",moose.Clock('/clock').dts[18]
    ori =  ca.concInit
    tablepath = loadpath+'/kinetics/Ca'
    tableele = moose.element(tablepath)
    table = moose.Table2(tablepath+'.con')
    x = moose.connect(table, 'requestOut', tablepath, 'getConc')
    tablepath1 = loadpath+'/kinetics/protein'
    tableele1 = moose.element(tablepath1)
    table1 = moose.Table2(tablepath1+'.con')
    x1 = moose.connect(table1, 'requestOut', tablepath1, 'getConc')

    ca.concInit = ori
    print("[INFO] Running for 4000 with Ca.conc %s " % ca.conc)
    moose.start(4000)

    ca.concInit = 5e-03
    print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
    moose.start(20)

    ca.concInit = ori
    moose.start( runTime ) #here give the interval time 

    ca.concInit = 5e-03
    print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
    moose.start(20)

    ca.concInit = ori
    print("[INFO] Running for 2000 with Ca.conc %s " % ca.conc)
    moose.start(2000)

    pylab.figure()
    pylab.subplot(2, 1, 1)
    t = numpy.linspace(0.0, moose.element("/clock").runTime, len(table.vector)) # sec
    pylab.plot( t, table.vector, label="Ca Conc (interval- 8000s)" )
    pylab.legend()
    pylab.subplot(2, 1, 2)
    t1 = numpy.linspace(0.0, moose.element("/clock").runTime, len(table1.vector)) # sec
    pylab.plot( t1, table1.vector, label="Protein Conc (interval- 8000s)" )
    pylab.legend()
    pylab.savefig( os.path.join( dataDir, '%s_%s.png' % (table1.name, runTime) ) )

    print('[INFO] Saving data to csv files in %s' % dataDir)
    tabPath1 = os.path.join( dataDir, '%s_%s.csv' % (table.name, runTime))
    numpy.savetxt(tabPath1, numpy.matrix([t, table.vector]).T, newline='\n')
    tabPath2 = os.path.join( dataDir, '%s_%s.csv' % (table1.name, runTime) )
    numpy.savetxt(tabPath2, numpy.matrix([t1, table1.vector]).T, newline='\n')
コード例 #11
0
ファイル: fixXreacs.py プロジェクト: AdrianW15/moose
def removeEnzFromPool(pool):
    kids = moose.wildcardFind(pool.path + "/#")
    for i in kids:
        if i.isA['EnzBase']:
            moose.delete(i)
        elif i.isA['Function']:
            moose.delete(i)
コード例 #12
0
def main():
    global params
    fig = plt.figure(figsize=(6, 10), facecolor='white')

    library = moose.Neutral('/library')

    for ii in range(len(sys.argv)):
        if sys.argv[ii][:2] == '--':
            argName = sys.argv[ii][2:]
            if argName in params:
                params[argName] = float(sys.argv[ii + 1])
                if argName == 'sequence':
                    params[argName] = sys.argv[ii + 1]  # Leave it as a str.

    moose.seed(int(params['seed']))
    '''
    '''
    makePassiveSoma('cell', params['dendLength'], params['dendDiameter'])
    moose.le('/library')
    panelBCsingleCompt(fig)
    moose.le('/library')
    moose.delete('/library/soma')
    params['dendLength'] = 60e-6
    makePassiveSoma('cell', params['dendLength'], params['dendDiameter'])
    panelEFspatialSeq(fig)
    plt.tight_layout()
    plt.show()
コード例 #13
0
ファイル: Fig5BCD.py プロジェクト: dilawar/moose-examples
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( '/' )
コード例 #14
0
ファイル: rdesigneur.py プロジェクト: asiaszmek/moose-core
    def buildModel( self, modelPath = '/model' ):
        if moose.exists( modelPath ):
            print("rdesigneur::buildModel: Build failed. Model '",
                modelPath, "' already exists.")
            return
        self.model = moose.Neutral( modelPath )
        self.modelPath = modelPath
        try:
            # Protos made in the init phase. Now install the elec and 
            # chem protos on model.
            self.installCellFromProtos()
            # Now assign all the distributions
            self.buildPassiveDistrib()
            self.buildChanDistrib()
            self.buildSpineDistrib()
            self.buildChemDistrib()
            self._configureSolvers()
            self.buildAdaptors()
            self._buildPlots()
            self._buildMoogli()
            self._buildStims()
            self._configureClocks()
            self._printModelStats()

        except BuildError as msg:
            print("Error: rdesigneur: model build failed:", msg)
            moose.delete( self.model )
コード例 #15
0
ファイル: conv_to_sbml.py プロジェクト: BhallaLab/HillTau
def conv(fname):
    kfile = "./KKIT_MODELS/" + fname + ".g"
    modelId = moose.loadModel("./KKIT_MODELS/" + fname + ".g", 'model',
                              'none')[0]
    sfile = "./SBML_MODELS/" + fname + ".xml"
    moose.mooseWriteSBML('/model', sfile)
    moose.delete(modelId)
コード例 #16
0
ファイル: MWindow.py プロジェクト: dilawar/moose-gui
    def newModelDialogSlot(self):
        if self.popup is not None:
            self.popup.close()
        newModelDialog = DialogWidget()
        if newModelDialog.exec_():
            modelPath = str(newModelDialog.modelPathEdit.text()).strip()
            if len(modelPath) == 0:
                raise mexception.ElementNameError('Model path cannot be empty')
            if re.search('[ /]',modelPath) is not None:
                raise mexception.ElementNameError('Model path should not containe / or whitespace')
            plugin = str(newModelDialog.getcurrentRadioButton())
            if moose.exists(modelPath+'/model'):
                moose.delete(modelPath)

            modelContainer = moose.Neutral('%s' %(modelPath))
            modelRoot = moose.Neutral('%s/%s' %(modelContainer.path,"model"))
            if not moose.exists(modelRoot.path+'/info'):
                moose.Annotator(modelRoot.path+'/info')
            
            modelAnno = moose.element(modelRoot.path+'/info')
            modelAnno.modeltype = "new_kkit"
            modelAnno.dirpath = " "
            self.loadedModelsAction(modelRoot.path,plugin)
            self.setPlugin(plugin, modelRoot.path)
            self.objectEditSlot('/', False)
コード例 #17
0
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('/model')
        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('/')
コード例 #18
0
def updateDisplay():
    makeYmodel()
    tabvec = moose.wildcardFind( '/model/graphs/plot#' )
    moose.element( '/model/elec/' ).name = 'Y'
    vecYdend = moose.wildcardFind( '/model/Y/soma,/model/Y/dend#' )
    vecYbranch1 = moose.wildcardFind( '/model/Y/branch1#' )
    vecYbranch2 = moose.wildcardFind( '/model/Y/branch2#' )
    moose.reinit()
    dt = interval1
    currtime = 0.0
    for i in lines:
        moose.start( dt )
        currtime += dt
        #print "############## NumDendData = ", len( vecYdend )
        i.YdendLines.set_ydata( [v.Vm*1000 for v in vecYdend] )
        i.Ybranch1Lines.set_ydata( [v.Vm*1000 for v in vecYbranch1] )
        i.Ybranch2Lines.set_ydata( [v.Vm*1000 for v in vecYbranch2] )
        dt = interval2

    moose.start( runtime - currtime )

    #print "############## len (tabvec)  = ", len( tabvec[0].vector )
    for i, tab in zip( tplot, tabvec ):
        i.set_ydata( tab.vector * 1000 )
    
    moose.delete( '/model' )
    moose.delete( '/library' )
コード例 #19
0
ファイル: fixXreacs.py プロジェクト: AdrianW15/moose
def disconnectReactant(reacOrEnz, reactant, duppool):
    outMsgs = reacOrEnz.msgOut
    infoPath = duppool.path + '/info'
    if moose.exists(infoPath):
        info = moose.element(infoPath)
    else:
        info = moose.Annotator(infoPath)

    #moose.le( reactant )
    notes = ""
    #moose.showmsg( reacOrEnz )
    for i in outMsgs:
        #print "killing msg from {} to {}\nfor {} and {}".format( reacOrEnz.path, reactant.path, i.srcFieldsOnE1[0], i.srcFieldsOnE2[0] )
        if i.e1 == reactant:
            msgStr = identifyMsg(i.e2, i.e2.srcFieldsOnE2[0], i.e1)
            if len(msgStr) > 0:
                notes += msgStr
                moose.delete(i)
        elif i.e2 == reactant:
            msgStr = identifyMsg(i.e1[0], i.srcFieldsOnE1[0], i.e2[0])
            if len(msgStr) > 0:
                notes += msgStr
                moose.delete(i)
    #print "MSGS to rebuild:", notes
    info.notes += notes
コード例 #20
0
ファイル: issue_93.py プロジェクト: rahulgayatri23/moose-core
def loadAndRun(solver=True):
    simtime = 500e-3
    model = moose.loadModel('../data/h10.CNG.swc', '/cell')
    comp = moose.element('/cell/apical_e_177_0')
    soma = moose.element('/cell/soma')
    for i in range(10):
        moose.setClock(i, dt)
    if solver:
        solver = moose.HSolve('/cell/solver')
        solver.target = soma.path
        solver.dt = dt
    stim = moose.PulseGen('/cell/stim')
    stim.delay[0] = 50e-3
    stim.delay[1] = 1e9
    stim.level[0] = 1e-9
    stim.width[0] = 2e-3    
    moose.connect(stim, 'output', comp, 'injectMsg')
    tab = moose.Table('/cell/Vm')
    moose.connect(tab, 'requestOut', comp, 'getVm')
    tab_soma = moose.Table('/cell/Vm_soma')
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.reinit()
    print('[INFO] Running for %s' % simtime)
    moose.start(simtime )
    vec = tab_soma.vector 
    moose.delete( '/cell' )
    return vec
コード例 #21
0
ファイル: profile.py プロジェクト: sanjayankur31/moose-core
def profile_creation_destruction():
    print('Create and delete')
    t = time.time()
    for i in range(10000):
        moose.Neutral('a')
        moose.delete('a')
    print('Time taken %g s' % time.time() - t)
コード例 #22
0
def saveAndClearPlots(name):
    print 'saveAndClearPlots( ', name, ' )'
    for i in moose.wildcardFind("/graphs/#"):
        #print i
        #plot stuff
        i.xplot(name + '.xplot', i.name)
    moose.delete("/graphs")
コード例 #23
0
def saveAndClearPlots( name ):
    print 'saveAndClearPlots( ', name, ' )'
    for i in moose.wildcardFind( "/graphs/#" ):
        #print i
        #plot stuff
        i.xplot( name + '.xplot', i.name )
    moose.delete( "/graphs" )
コード例 #24
0
 def _buildNeuroMesh(self):
     comptlist = moose.wildcardFind(self.chemid.path + '/#[ISA=ChemCompt]')
     sortedComptList = sorted(comptlist, key=lambda x: -x.volume)
     # A little juggling here to put the chem pathways onto new meshes.
     self.chemid.name = 'temp_chem'
     newChemid = moose.Neutral(self.model.path + '/chem')
     self.dendCompt = moose.NeuroMesh(newChemid.path + '/dend')
     self.dendCompt.geometryPolicy = 'cylinder'
     self.dendCompt.separateSpines = 0
     if len(sortedComptList) == 3:
         self.dendCompt.separateSpines = 1
         self.spineCompt = moose.SpineMesh(newChemid.path + '/spine')
         moose.connect(self.dendCompt, 'spineListOut', self.spineCompt,
                       'spineList')
         self.psdCompt = moose.PsdMesh(newChemid.path + '/psd')
         moose.connect(self.dendCompt, 'psdListOut', self.psdCompt,
                       'psdList', 'OneToOne')
     #Move the old reac systems onto the new compartments.
     self._moveCompt(sortedComptList[0], self.dendCompt)
     if len(sortedComptList) == 3:
         self._moveCompt(sortedComptList[1], self.spineCompt)
         self._moveCompt(sortedComptList[2], self.psdCompt)
     self.dendCompt.diffLength = self.diffusionLength
     self.dendCompt.subTree = self.cellPortionElist
     moose.delete(self.chemid)
     self.chemid = newChemid
コード例 #25
0
ファイル: rdesigneur.py プロジェクト: physicalist/moose
    def buildModel( self, modelPath ):
        if not moose.exists( '/library' ):
            library = moose.Neutral( '/library' )
        if moose.exists( modelPath ):
            print "rdesigneur::buildModel: Build failed. Model '", \
                modelPath, "' already exists."
            return
        self.model = moose.Neutral( modelPath )
        try:
            self.buildCellProto()
            self.buildChanProto()
            self.buildSpineProto()
            self.buildChemProto()
            # Protos made. Now install the elec and chem protos on model.
            self.installCellFromProtos()
            # Now assign all the distributions
            self.buildPassiveDistrib()
            self.buildChanDistrib()
            self.buildSpineDistrib()
            self.buildChemDistrib()
            self._configureSolvers()
            self.buildAdaptors()
            self._configureClocks()
            self._printModelStats()

        except BuildError, msg:
            print "Error: rdesigneur: model build failed: ", msg
            moose.delete( self.model )
コード例 #26
0
ファイル: rdesigneur.py プロジェクト: DineshDevPandey/moose
    def buildModel( self, modelPath ):
        if not moose.exists( '/library' ):
            library = moose.Neutral( '/library' )
        if moose.exists( modelPath ):
            print "rdesigneur::buildModel: Build failed. Model '", \
                modelPath, "' already exists."
            return
        self.model = moose.Neutral( modelPath )
        try:
            self.buildCellProto()
            self.buildChanProto()
            self.buildSpineProto()
            self.buildChemProto()
            # Protos made. Now install the elec and chem protos on model.
            self.installCellFromProtos()
            # Now assign all the distributions
            self.buildPassiveDistrib()
            self.buildChanDistrib()
            self.buildSpineDistrib()
            self.buildChemDistrib()
            self._configureSolvers()
            self.buildAdaptors()
            self._configureClocks()
            self._printModelStats()

        except BuildError, msg:
            print "Error: rdesigneur: model build failed: ", msg
            moose.delete( self.model )
コード例 #27
0
def copy_deleteUnlyingPoolObj(pool, path):
    # check if this pool is under compartement or under enzyme?(which is enzyme_cplx)
    # if enzyme_cplx then don't copy untill this perticular enzyme is copied
    # case: This enzyme_cplx might exist in modelA if enzyme exist then this
    # will automatically copie's the pool
    copied = False

    if pool.parent.className not in [
            "Enz", "ZombieEnz", "MMenz", "ZombieMMenz"
    ]:
        if path.className in ["Neutral", "CubeMesh", "CyclMesh"]:
            poolcopied = moose.copy(pool, path)
            copied = True
            # deleting function and enzyme which gets copied if exist under pool
            # This is done to ensure daggling function / enzyme not copied.
            funclist = []
            for types in ['setConc', 'setN', 'increment']:
                funclist.extend(moose.element(poolcopied).neighbors[types])

            for fl in funclist:
                moose.delete(fl)
            enzlist = moose.element(poolcopied).neighbors['reac']
            for el in list(set(enzlist)):
                moose.delete(el.path)
    return copied
コード例 #28
0
ファイル: test_Xreacs3.py プロジェクト: hrani/moose-core
def main( standalone = False ):
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #29
0
def test_xreac4():
    runtime = 200
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( 2.0 * moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #30
0
ファイル: profile.py プロジェクト: sanjayankur31/moose-core
def profile_creation():
    print('Only creation')
    moose.Neutral('x')
    t = time.time()
    for i in range(10000):
        moose.Neutral('x/x%d' % i)
    print('Time taken %g s' % time.time() - t)
    moose.delete('x')
コード例 #31
0
def main( standalone = False ):
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #32
0
ファイル: test_Xreacs4a.py プロジェクト: hrani/moose-core
def main( standalone = False ):
    runtime = 200
    displayInterval = 2
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( 2.0 * moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #33
0
ファイル: setsolver.py プロジェクト: asiaszmek/moose
def deleteSolver(modelRoot):
	compts = moose.wildcardFind(modelRoot+'/##[ISA=ChemCompt]')
	for compt in compts:
		if moose.exists(compt.path+'/stoich'):
			st = moose.element(compt.path+'/stoich')
			st_ksolve = st.ksolve
			moose.delete(st)
			if moose.exists((st_ksolve).path):
				moose.delete(st_ksolve)
コード例 #34
0
def remove_objects():
    print("setup before yield")
    yield
    print("teardown after yield")
    for i in ('/data', '/pulse', '/D1', '/D2', '/library'):
        try:
            moose.delete(i)
        except ValueError:
            pass
コード例 #35
0
ファイル: pyrun.py プロジェクト: lhhhu1990/moose
def main():
    """
You can use the PyRun class to run Python statements from MOOSE at
runtime. This opens up many possibilities of interleaving computing in
Python and MOOSE. You can also use this for debugging simulations.
	"""
    run_sequence()
    moose.delete('/model')
    input_output()
コード例 #36
0
ファイル: merge.py プロジェクト: tdeuling/moose
def deleteSolver(modelRoot):
    compts = moose.wildcardFind(modelRoot + '/##[ISA=ChemCompt]')
    for compt in compts:
        if moose.exists(compt.path + '/stoich'):
            st = moose.element(compt.path + '/stoich')
            st_ksolve = st.ksolve
            moose.delete(st)
            if moose.exists((st_ksolve).path):
                moose.delete(st_ksolve)
コード例 #37
0
def reload_moose():
    import moose
    print('reloading moose')
    for p in ['/model', '/library']:
        if moose.exists(p):
            moose.delete(p)
    # If someone has changed the clock-ticks then we need to reset them.
    # And relaod just to make sure and other values are initialized.
    reload(moose)
コード例 #38
0
ファイル: pyrun.py プロジェクト: dilawar/moose-examples
def main():
	"""
You can use the PyRun class to run Python statements from MOOSE at
runtime. This opens up many possibilities of interleaving computing in
Python and MOOSE. You can also use this for debugging simulations.
	"""
	run_sequence()
	moose.delete('/model')
	input_output()
コード例 #39
0
def test_msgs():
    if moose.exists('/model'):
        moose.delete('/model')
    rdes = rd.rdesigneur(
        stimList=[['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8']],
        plotList=[['soma', '1', '.', 'Vm', 'Soma membrane potential']])
    rdes.buildModel()
    msgs = moose.listmsg(rdes.soma)
    assert len(msgs) == 3, msgs
コード例 #40
0
def test_xreacs7():
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )

    assert( almostEq( moose.element( 'model/endo/t' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #41
0
def main(standalone=False):
    runtime = 200
    displayInterval = 2
    makeModel()
    moose.reinit()
    moose.start(runtime)
    assert (almostEq(2.0 * moose.element('model/compartment/s').conc,
                     moose.element('/model/endo/s').conc))
    moose.delete('/model')
コード例 #42
0
def remove_objects():
    print ("setup before yield")
    yield
    print ("teardown after yield")
    for i in ('/data', '/pulse', '/D1', '/D2', '/library'):
        try:
            moose.delete(i)
        except ValueError:
            pass
コード例 #43
0
def ts(chem, ht, ampl, plotPos, title=''):
    tsettle = 500  # This turns out to be needed for both models.
    tpre = 10
    tstim = 1
    tpost = 50
    modelId = moose.loadModel(chem, 'model', 'gsl')[0]
    Ca = moose.element('/model/kinetics/Ca')
    output = moose.element('/model/kinetics/synAMPAR')
    iplot = moose.element('/model/graphs/conc1/Ca.Co')
    oplot = moose.element('/model/graphs/conc2/synAMPAR.Co')
    moose.setClock(iplot.tick, plotDt)
    for i in range(10, 20):
        moose.setClock(i, plotDt)

    Ca.concInit = 0.08e-3
    moose.reinit()
    moose.start(tsettle)
    moose.start(tpre)
    Ca.concInit = ampl
    moose.start(tstim)
    Ca.concInit = 0.08e-3
    moose.start(tpost)
    ivec = iplot.vector
    ovec = oplot.vector
    ivec = ivec[int(tsettle / plotDt):]
    ovec = ovec[int(tsettle / plotDt):]
    x = np.array(range(len(ivec))) * plotDt
    ax = plotBoilerplate(char[plotPos],
                         plotPos,
                         title,
                         xlabel="Time (s)",
                         ylabel="[synAMPAR] ($\mu$M)")
    #ax.plot( x , 1000 * ivec, label = "input" )
    ax.plot(x, 1000 * ovec, label="output")
    moose.delete('/model')

    jsonDict = hillTau.loadHillTau(ht)
    hillTau.scaleDict(jsonDict, hillTau.getQuantityScale(jsonDict))
    model = hillTau.parseModel(jsonDict)
    model.dt = plotDt
    inputMolIndex = model.molInfo.get("Ca").index
    outputMolIndex = model.molInfo.get("synAMPAR").index

    model.advance(tpre + tsettle)
    model.conc[inputMolIndex] = ampl
    model.advance(tstim)
    model.conc[inputMolIndex] = 0.08e-3
    model.advance(tpost)
    plotvec = np.transpose(np.array(model.plotvec))
    x = np.array(range(plotvec.shape[1] - int(tsettle / plotDt))) * plotDt
    reacn = "this is ht"
    #ax = plotBoilerplate( "B", plotPos+1, reacn, xlabel = "Time (s)" )
    #ax.plot( x , 1000 * plotvec[inputMolIndex], label = "input" )
    ax.plot(x,
            1000 * plotvec[outputMolIndex][int(tsettle / plotDt):],
            label="output")
コード例 #44
0
ファイル: setsolver.py プロジェクト: NeuroArchive/moose
def deleteSolver(modelRoot):
	if moose.wildcardFind(modelRoot+'/##[ISA=ChemCompt]'):
		compt = moose.wildcardFind(modelRoot+'/##[ISA=ChemCompt]')
		if ( moose.exists( compt[0].path+'/stoich' ) ):
			st = moose.element(compt[0].path+'/stoich')
			if moose.exists((st.ksolve).path):
				moose.delete(st.ksolve)
			moose.delete( compt[0].path+'/stoich' )
	for x in moose.wildcardFind( modelRoot+'/data/graph#/#' ):
                x.tick = -1
コード例 #45
0
ファイル: setsolver.py プロジェクト: physicalist/moose
def deleteSolver(modelRoot):
    if moose.wildcardFind(modelRoot + '/##[ISA=ChemCompt]'):
        compt = moose.wildcardFind(modelRoot + '/##[ISA=ChemCompt]')
        if (moose.exists(compt[0].path + '/stoich')):
            st = moose.element(compt[0].path + '/stoich')
            if moose.exists((st.ksolve).path):
                moose.delete(st.ksolve)
            moose.delete(compt[0].path + '/stoich')
    for x in moose.wildcardFind(modelRoot + '/data/graph#/#'):
        x.tick = -1
コード例 #46
0
ファイル: test_pymoose.py プロジェクト: asiaszmek/moose-core
 def testDelete(self):
     print('Testing delete ...', end=' ')
     msg = self.src1.connect('raxial', self.dest1, 'axial')
     src2 = moose.PulseGen('/pulsegen')
     msg2 = moose.connect(src2, 'output', self.dest1, 'injectMsg')
     moose.delete(msg)
     # accessing deleted element should raise error
     with self.assertRaises(ValueError):
         p = msg.path
     p = msg2.path # this should not raise any error
コード例 #47
0
ファイル: x_compt.py プロジェクト: NeuroArchive/moose
def moveCompt( path, oldParent, newParent ):
	meshEntries = moose.element( newParent.path + '/mesh' )
	# Set up vol messaging from new compts to all their child objects.
	for x in moose.wildcardFind( path + '/##[ISA=PoolBase]' ):
		moose.connect( meshEntries, 'mesh', x, 'mesh', 'OneToOne' )
	orig = moose.element( path )
	moose.move( orig, newParent )
	moose.delete( moose.vec( oldParent.path ) )
	chem = moose.element( '/model/chem' )
	moose.move( newParent, chem )
コード例 #48
0
ファイル: test_Xreacs6.py プロジェクト: dilawar/moose
def test_xreac6():
    for i in range( 10, 18):
        moose.setClock( i, 0.01 )
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )
    moose.delete( '/model' )
コード例 #49
0
ファイル: test_pymoose.py プロジェクト: tdeuling/moose
 def testDelete(self):
     print('Testing delete ...', end=' ')
     msg = self.src1.connect('raxial', self.dest1, 'axial')
     src2 = moose.PulseGen('/pulsegen')
     msg2 = moose.connect(src2, 'output', self.dest1, 'injectMsg')
     moose.delete(msg)
     # accessing deleted element should raise error
     with self.assertRaises(ValueError):
         p = msg.path
     p = msg2.path  # this should not raise any error
コード例 #50
0
ファイル: test_rdesigneur.py プロジェクト: hrani/moose-core
def test2( ):
    if moose.exists( '/model' ):
        moose.delete( '/model' )

    rdes = rd.rdesigneur(
        stimList = [['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8' ]],
        plotList = [['soma', '1', '.', 'Vm', 'Soma membrane potential']]
    )
    rdes.buildModel()
    moose.reinit()
    moose.start( 0.3 )
コード例 #51
0
ファイル: test_Xenz1.py プロジェクト: hrani/moose-core
def main( standalone = False ):
    for i in range( 10, 18 ):
        moose.setClock( i, 0.001 )
    runtime = 100
    displayInterval = 2
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( moose.element( 'model/compartment/prd' ).n,
        moose.element( '/model/endo/sub' ).n ) )
    moose.delete( '/model' )
コード例 #52
0
ファイル: mload.py プロジェクト: Vivek-sagar/moose-1
def loadFile(filename, target, merge=True):
    """Try to load a model from specified `filename` under the element
    `target`.

    if `merge` is True, the contents are just loaded at target. If
    false, everything is deleted from the parent of target unless the
    parent is root.

    Returns
    -------
    a dict containing at least these three entries:
    
    modeltype: type of the loaded model.

    subtype: subtype of the loaded model, None if no specific subtype

    modelroot: root element of the model, None if could not be located - as is the case with Python scripts
    """
    istext = True
    with open(filename, 'rb') as infile:
        istext = mtypes.istextfile(infile)
    if not istext:
        print 'Cannot handle any binary formats yet'
        return None
    parent, child = posixpath.split(target)
    p = moose.Neutral(parent)
    if not merge and p.path != '/':
        for ch in p.children:
            moose.delete(ch)
    try:
        modeltype = mtypes.getType(filename)
        subtype = mtypes.getSubtype(filename, modeltype)
    except KeyError:
        raise FileLoadError('Do not know how to handle this filetype: %s' % (filename))
    pwe = moose.getCwe()
    if modeltype == 'genesis':
        if subtype == 'kkit' or subtype == 'prototype':
            model = moose.loadModel(filename, target)            
        else:
            print 'Only kkit and prototype files can be loaded.'
    elif modeltype == 'cspace':
            model = moose.loadModel(filename, target)        
    elif modeltype == 'xml' and subtype == 'neuroml':
        model = neuroml.loadNeuroML_L123(filename)
    else:
        raise FileLoadError('Do not know how to handle this filetype: %s' % (filename))
    moose.setCwe(pwe) # The MOOSE loadModel changes the current working element to newly loaded model. We revert that behaviour
    # TODO: check with Aditya how to specify the target for
    # neuroml reader
    return {'modeltype': modeltype, 
            'subtype': subtype, 
            'model': model}
コード例 #53
0
def moosedeleteChemSolver(modelRoot):
    """Delete solvers from Chemical Compartment

    """
    compts = moose.wildcardFind(modelRoot + '/##[ISA=ChemCompt]')
    for compt in compts:
        if moose.exists(compt.path + '/stoich'):
            st = moose.element(compt.path + '/stoich')
            st_ksolve = st.ksolve
            moose.delete(st)
            if moose.exists((st_ksolve).path):
                moose.delete(st_ksolve)
                print("Solver is deleted for modelpath %s " % modelRoot)
コード例 #54
0
def switchSolvers( solver ):
        if ( moose.exists( 'model/kinetics/stoich' ) ):
            moose.delete( '/model/kinetics/stoich' )
            moose.delete( '/model/kinetics/ksolve' )
        compt = moose.element( '/model/kinetics' )
        if ( solver == 'gsl' ):
            ksolve = moose.Ksolve( '/model/kinetics/ksolve' )
        if ( solver == 'gssa' ):
            ksolve = moose.Gsolve( '/model/kinetics/ksolve' )
        if ( solver != 'ee' ):
            stoich = moose.Stoich( '/model/kinetics/stoich' )
            stoich.compartment = compt
            stoich.ksolve = ksolve
            stoich.path = "/model/kinetics/##"
コード例 #55
0
def main():
    global synSpineList 
    global synDendList 
    global opFile
    numpy.random.seed( 1234 )
    rdes = buildRdesigneur()
    
    print "SIMULATION START"
    for i in elecFileNames:
		print i
		rdes.cellProtoList = [ ['./cells/' + i, 'elec'] ]
		opFile = i.split('.')[0] + '_batch.txt'
		rdes.buildModel( '/model' )
		#inject
		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 ) )
		print "num spine, dend syns = ", len( synSpineList ), len( synDendList )
		moose.reinit()
		#for i in moose.wildcardFind( '/model/elec/#apical#/#[ISA=CaConcBase]' ):
			#print i.path, i.length, i.diameter, i.parent.length, i.parent.diameter

		buildPlots( rdes )
		# Run for baseline, tetanus, and post-tetanic settling time 
		t1 = time.time()
		#build3dDisplay( rdes )
		steps = int(runtime / frameRunTime)
		for i in range(steps):
			curtime = i * frameRunTime 
			deliverStim( curtime )
			moose.start( frameRunTime)
		displayPlots()
		dendPath = moose.wildcardFind('/graphs/caDendTab[]')
		headPath = moose.wildcardFind('/graphs/caHeadTab[]')
		vmPath = moose.wildcardFind('/graphs/VmTab[0]')
				
    
		print 'SIMULATION IS COMPLETE, STARTING ANALYSIS . . '
		execfile('analyzeSynScript.py')
		#computeCaValues(opFile)
		print 'ANALYSIS COMPLETED'
		print 'real time = ', time.time() - t1
		
		moose.delete( '/model' )
		moose.delete( '/graphs' )
		rdes.elecid = moose.element( '/' )
		
		print "finished"
コード例 #56
0
ファイル: test_Xreacs5.py プロジェクト: hrani/moose-core
def main( standalone = False ):
    for i in range( 10, 18):
        moose.setClock( i, 0.001 )
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )

    e1 = moose.element( 'model/compartment/s' )
    e2 = moose.element( 'model/endo/s' )
    assert almostEq(2.0 * e1.conc, e2.conc), \
            "Expected %g, Got %g" % (e1.conc, e2.conc )

    moose.delete( '/model' )
コード例 #57
0
ファイル: Fig2_v4.py プロジェクト: dilawar/moose-examples
def runPanelCDEF( name, dist, seqDt, numSpine, seq, stimAmpl ):
    preStim = 10.0
    blanks = 20
    rdes = rd.rdesigneur(
        useGssa = False,
        turnOffElec = True,
        chemPlotDt = 0.1,
        #diffusionLength = params['diffusionLength'],
        diffusionLength = 1e-6,
        cellProto = [['cell', 'soma']],
        chemProto = [['dend', name]],
        chemDistrib = [['dend', 'soma', 'install', '1' ]],
        plotList = [['soma', '1', 'dend' + '/A', 'n', '# of A']],
    )
    rdes.buildModel()
    #for i in range( 20 ):
        #moose.setClock( i, 0.02 )
    A = moose.vec( '/model/chem/dend/A' )
    Z = moose.vec( '/model/chem/dend/Z' )
    print(moose.element( '/model/chem/dend/A/Adot' ).expr)
    print(moose.element( '/model/chem/dend/B/Bdot' ).expr)
    print(moose.element( '/model/chem/dend/Ca/CaStim' ).expr)
    phase = moose.vec( '/model/chem/dend/phase' )
    ampl = moose.vec( '/model/chem/dend/ampl' )
    vel = moose.vec( '/model/chem/dend/vel' )
    vel.nInit = 1e-6 * seqDt
    ampl.nInit = stimAmpl
    stride = int( dist ) / numSpine
    phase.nInit = 10000
    Z.nInit = 0
    for j in range( numSpine ):
        k = int(blanks + j * stride)
        Z[k].nInit = 1
        phase[k].nInit = preStim + seq[j] * seqDt
    moose.reinit()
    runtime = 50
    snapshot = preStim + seqDt * (numSpine - 0.8)
    print(snapshot)
    #snapshot = 26
    moose.start( snapshot )
    avec = moose.vec( '/model/chem/dend/A' ).n
    moose.start( runtime - snapshot )
    tvec = []
    for i in range( 5 ):
        tab = moose.element( '/model/graphs/plot0[' + str( blanks + i * stride ) + ']' )
        dt = tab.dt
        tvec.append( tab.vector )
    moose.delete( '/model' )
    return dt, tvec, avec
コード例 #58
0
ファイル: diffusionOnly.py プロジェクト: NeuroArchive/moose
def loadChem( neuroCompt, spineCompt, psdCompt ):
	# We need the compartments to come in with a volume of 1 to match the
	# original CubeMesh.
	assert( neuroCompt.volume == 1.0 )
	assert( spineCompt.volume == 1.0 )
	assert( psdCompt.volume == 1.0 )
	assert( neuroCompt.mesh.num == 1 )
	print 'volume = ', neuroCompt.mesh[0].volume
	#assert( neuroCompt.mesh[0].volume == 1.0 ) 
	#an unfortunate mismatch
	# So we'll have to resize the volumes of the current compartments to the
	# new ones.

	modelId = moose.loadModel( 'diffonly.g', '/model', 'ee' )
	#moose.le( '/model/model' )
	#moose.le( '/model/model/kinetics' )
	#moose.le( '/model/model/kinetics/PSD' )
	#moose.le( '/model/model/kinetics/SPINE' )
	moose.delete( moose.vec( '/model/model/kinetics/PSD/kreac' ) )
	moose.delete( moose.vec( '/model/model/kinetics/SPINE/kreac' ) )
	#moose.le( '/model/model/kinetics/PSD' )
	#moose.le( '/model/model/kinetics/SPINE' )
	pCaCaM = moose.element( '/model/model/kinetics/PSD/Ca_CaM' )
	pCaCaM.concInit = 0.001
	dCaCaM = moose.element( '/model/model/kinetics/PSD/Ca_CaM' )
	sCaCaM = moose.element( '/model/model/kinetics/SPINE/Ca_CaM' )
	print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
	#moose.delete( moose.vec( '/model/model/kinetics/SPINE/Ca_CaM' ) )
	#CaCaM2 = moose.element( '/model/model/kinetics/SPINE/Ca_CaM' )
	#CaCaM2.concInit = 0.001
	chem = moose.element( '/model/model' )
	chem.name = 'chem'
	oldS = moose.element( '/model/chem/compartment_1' )
	oldP = moose.element( '/model/chem/compartment_2' )
	oldN = moose.element( '/model/chem/kinetics' )
	print 'oldvols[p,s,d] = ', oldP.volume, oldS.volume, oldN.volume
	print 'newvols[p,s,d] = ', psdCompt.mesh[0].volume, spineCompt.mesh[0].volume, neuroCompt.mesh[0].volume
	oldN.volume = neuroCompt.mesh[0].volume
	oldS.volume = spineCompt.mesh[0].volume
	oldP.volume = psdCompt.mesh[0].volume
	print 'after redoing vols'
	print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
	moveCompt( '/model/chem/kinetics/SPINE', oldS, spineCompt )
	moveCompt( '/model/chem/kinetics/PSD', oldP, psdCompt )
	# Need to do the DEND last because the oldN is /kinetics, 
	# and it will be deleted.
	moveCompt( '/model/chem/kinetics/DEND', oldN, neuroCompt )
	print 'after moving to new compts'
	print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
コード例 #59
0
ファイル: testXreacs3.py プロジェクト: hrani/moose-core
def main( standalone = False ):
    runtime = 100
    makeModel()
    moose.reinit()
    moose.start( runtime )
    assert( almostEq( moose.element( 'model/compartment/s' ).conc,
        moose.element( '/model/endo/s' ).conc ) )

    if standalone:
        fig = plt.figure( figsize=(12,10) )
        ax1 = fig.add_subplot(211)
        doPlot( ax1, 1, '# of molecules' )
        ax2 = fig.add_subplot(212)
        doPlot( ax2, 4, 'conc (mM)' )
        plt.show()
    moose.delete( '/model' )