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


Python moose.copy函数代码示例

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


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

示例1: create_compartment

def create_compartment(path):
    comp = moose.Compartment(path)
    comp.diameter = soma_dia
    comp.Em = EREST_ACT + 10.613e-3
    comp.initVm = EREST_ACT
    sarea = np.pi * soma_dia * soma_dia
    comp.Rm = 1/(0.3e-3 * 1e4 * sarea)
    comp.Cm = 1e-6 * 1e4 * sarea
    if moose.exists('/library/na'):
        nachan = moose.element(moose.copy('/library/na', comp, 'na'))
    else:
        nachan = create_na_chan(comp.path)
    nachan.Gbar = 120e-3 * sarea * 1e4
    moose.showfield(nachan)
    moose.connect(nachan, 'channel', comp, 'channel')
    if moose.exists('/library/k'):
        kchan = moose.element(moose.copy('/library/k', comp, 'k'))
    else:
        kchan = create_k_chan(comp.path)
    kchan.Gbar = 36e-3 * sarea * 1e4
    moose.connect(kchan, 'channel', comp, 'channel')
    synchan = moose.SynChan(comp.path + '/synchan')
    synchan.Gbar = 1e-8
    synchan.tau1 = 2e-3
    synchan.tau2 = 2e-3
    synchan.Ek = 0.0
    m = moose.connect(comp, 'channel', synchan, 'channel')
    spikegen = moose.SpikeGen(comp.path + '/spikegen')
    spikegen.threshold = 0.0
    m = moose.connect(comp, 'VmOut', spikegen, 'Vm')
    return comp
开发者ID:dilawar,项目名称:moose-examples,代码行数:31,代码来源:compartment_net_no_array.py

示例2: installCellFromProtos

    def installCellFromProtos( self ):
        if self.stealCellFromLibrary:
            moose.move( self.elecid, self.model )
            if self.elecid.name != 'elec':
                self.elecid.name = 'elec'
        else:
            moose.copy( self.elecid, self.model, 'elec' )
            self.elecid = moose.element( self.model.path + '/elec' )
            self.elecid.buildSegmentTree() # rebuild: copy has happened.
        if hasattr( self, 'chemid' ):
            self.validateChem()
            if self.stealCellFromLibrary:
                moose.move( self.chemid, self.model )
                if self.chemid.name != 'chem':
                    self.chemid.name = 'chem'
            else:
                moose.copy( self.chemid, self.model, 'chem' )
                self.chemid = moose.element( self.model.path + '/chem' )

        ep = self.elecid.path
        somaList = moose.wildcardFind( ep + '/#oma#[ISA=CompartmentBase]' )
        if len( somaList ) == 0:
            somaList = moose.wildcardFind( ep + '/#[ISA=CompartmentBase]' )
        if len( somaList ) == 0:
            raise BuildError( "installCellFromProto: No soma found" )
        maxdia = 0.0
        for i in somaList:
            if ( i.diameter > maxdia ):
                self.soma = i
开发者ID:DineshDevPandey,项目名称:moose,代码行数:29,代码来源:rdesigneur.py

示例3: creaetHHComp

def creaetHHComp(parent='/library', name='hhcomp', diameter=1e-6, length=1e-6):
    """Create a compartment with Hodgkin-Huxley type ion channels (Na and
    K).

    Returns a 3-tuple: (compartment, nachannel, kchannel)

    """
    compPath = '{}/{}'.format(parent, name)
    mc = MooseCompartment( compPath, length, diameter, {})
    c = mc.mc_
    sarea = mc.surfaceArea

    if moose.exists('/library/na'):
        moose.copy('/library/na', c.path, 'na')
    else:
        create_na_chan(parent = c.path)

    na = moose.element('%s/na' % (c.path))

    # Na-conductance 120 mS/cm^2
    na.Gbar = 120e-3 * sarea * 1e4
    na.Ek = 115e-3 + EREST_ACT

    moose.connect(c, 'channel', na, 'channel')
    if moose.exists('/library/k'):
        moose.copy('/library/k', c.path, 'k')
    else:
        create_k_chan(parent = c.path)

    k = moose.element('%s/k' % (c.path))
    # K-conductance 36 mS/cm^2
    k.Gbar = 36e-3 * sarea * 1e4
    k.Ek = -12e-3 + EREST_ACT
    moose.connect(c, 'channel', k, 'channel')
    return (c, na, k)
开发者ID:hrani,项目名称:moose-core,代码行数:35,代码来源:moose_sim.py

示例4: create_hhcomp

def create_hhcomp(parent='/library', name='hhcomp', diameter=-30e-6, length=0.0):
    """Create a compartment with Hodgkin-Huxley type ion channels (Na and
    K).

    Returns a 3-tuple: (compartment, nachannel, kchannel)

    """
    comp, sarea = create_passive_comp(parent, name, diameter, length)
    if moose.exists('/library/na'):
        moose.copy('/library/na', comp.path, 'na')
    else:
        create_na_chan(parent=comp.path)
    na = moose.element('%s/na' % (comp.path))
    # Na-conductance 120 mS/cm^2
    na.Gbar = 120e-3 * sarea * 1e4 
    na.Ek = 115e-3 + EREST_ACT
    moose.connect(comp, 'channel', na, 'channel')
    if moose.exists('/library/k'):
        moose.copy('/library/k', comp.path, 'k')
    else:
        create_k_chan(parent=comp.path)
    k = moose.element('%s/k' % (comp.path))
    # K-conductance 36 mS/cm^2
    k.Gbar = 36e-3 * sarea * 1e4 
    k.Ek = -12e-3 + EREST_ACT
    moose.connect(comp, 'channel', k, 'channel')
    return comp, na, k
开发者ID:csiki,项目名称:MOOSE,代码行数:27,代码来源:hhcomp.py

示例5: poolMerge

def poolMerge(comptA,comptB,poolNotcopiedyet):

    aCmptGrp = moose.wildcardFind(comptA.path+'/#[TYPE=Neutral]')
    aCmptGrp = aCmptGrp +(moose.element(comptA.path),)

    bCmptGrp = moose.wildcardFind(comptB.path+'/#[TYPE=Neutral]')
    bCmptGrp = bCmptGrp +(moose.element(comptB.path),)

    objA = moose.element(comptA.path).parent.name
    objB = moose.element(comptB.path).parent.name
    for bpath in bCmptGrp:
        grp_cmpt = ((bpath.path).replace(objB,objA)).replace('[0]','')
        if moose.exists(grp_cmpt) :
            if moose.element(grp_cmpt).className != bpath.className:
                grp_cmpt = grp_cmpt+'_grp'
                bpath.name = bpath.name+"_grp"
                l = moose.Neutral(grp_cmpt)
        else:
            #moose.Neutral(grp_cmpt)
            src = bpath
            srcpath = (bpath.parent).path
            des = srcpath.replace(objB,objA)
            moose.copy(bpath,moose.element(des))

        apath = moose.element(bpath.path.replace(objB,objA))

        bpoollist = moose.wildcardFind(bpath.path+'/#[ISA=PoolBase]')
        apoollist = moose.wildcardFind(apath.path+'/#[ISA=PoolBase]')
        for bpool in bpoollist:
            if bpool.name not in [apool.name for apool in apoollist]:
                copied = copy_deleteUnlyingPoolObj(bpool,apath)
                if copied == False:
                    #hold it for later, this pool may be under enzyme, as cplx
                    poolNotcopiedyet.append(bpool)
开发者ID:pgleeson,项目名称:moose-core,代码行数:34,代码来源:merge.py

示例6: __init__

 def __init__(self, path):
     if not moose.exists(path):
         path_tokens = path.rpartition('/')
         moose.copy(self.prototype, path_tokens[0], path_tokens[-1])
     moose.Neutral.__init__(self, path)
     self.solver = moose.HSolve('{}/solver'.format(path, 'solver'))
     self.solver.target = path
     self.solver.dt = config.simulationSettings.simulationDt
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:8,代码来源:cells.py

示例7: buildFromMemory

    def buildFromMemory( self, ePath, cPath, doCopy = False ):
        if not self.validateFromMemory( ePath, cPath ):
            return
        if doCopy:
            x = moose.copy( cPath, self.model )
            self.chemid = moose.element( x )
            self.chemid.name = 'chem'
            x = moose.copy( ePath, self.model )
            self.elecid = moose.element( x )
            self.elecid.name = 'elec'
        else:
            self.elecid = moose.element( ePath )
            self.chemid = moose.element( cPath )
            if self.elecid.path != self.model.path + '/elec':
                if ( self.elecid.parent != self.model ):
                    moose.move( self.elecid, self.model )
                self.elecid.name = 'elec'
            if self.chemid.path != self.model.path + '/chem':
                if ( self.chemid.parent != self.model ):
                    moose.move( self.chemid, self.model )
                self.chemid.name = 'chem'


        ep = self.elecid.path
        somaList = moose.wildcardFind( ep + '/#oma#[ISA=CompartmentBase]' )
        if len( somaList ) == 0:
            somaList = moose.wildcardFind( ep + '/#[ISA=CompartmentBase]' )
        assert( len( somaList ) > 0 )
        maxdia = 0.0
        for i in somaList:
            if ( i.diameter > maxdia ):
                self.soma = i
        #self.soma = self.comptList[0]
        self._decorateWithSpines()
        self.spineList = moose.wildcardFind( ep + '/#spine#[ISA=CompartmentBase],' + ep + '/#head#[ISA=CompartmentBase]' )
        if len( self.spineList ) == 0:
            self.spineList = moose.wildcardFind( ep + '/#head#[ISA=CompartmentBase]' )
        nmdarList = moose.wildcardFind( ep + '/##[ISA=NMDAChan]' )

        self.comptList = moose.wildcardFind( ep + '/#[ISA=CompartmentBase]')
        print "Rdesigneur: Elec model has ", len( self.comptList ), \
            " compartments and ", len( self.spineList ), \
            " spines with ", len( nmdarList ), " NMDARs"


        self._buildNeuroMesh()


        self._configureSolvers()
        for i in self.adaptorList:
            print i
            self._buildAdaptor( i[0],i[1],i[2],i[3],i[4],i[5],i[6] )
开发者ID:dharmasam9,项目名称:moose-core,代码行数:52,代码来源:rdesigneur.py

示例8: create_LIF

def create_LIF():
    neuromlR = NeuroML()
    neuromlR.readNeuroMLFromFile("cells_channels/LIF.morph.xml")
    libcell = moose.Neuron("/library/LIF")
    LIFCellid = moose.copy(libcell, moose.Neutral("/cells"), "IF1")
    LIFCell = moose.Neuron(LIFCellid)
    return LIFCell
开发者ID:BhallaLab,项目名称:moose-examples,代码行数:7,代码来源:LIFxml_firing.py

示例9: setup_single_compartment

def setup_single_compartment(container_path, channel_proto, Gbar):
    comp = make_testcomp(container_path)
    channel = moose.copy(channel_proto, comp, channel_proto.name)[0]
    moose.connect(channel, 'channel', comp, 'channel')
    channel.Gbar = Gbar
    pulsegen = make_pulsegen(container_path)
    moose.connect(pulsegen, 'outputOut', comp, 'injectMsg')
    vm_table = moose.Table('%s/Vm' % (container_path))
    moose.connect(vm_table, 'requestData', comp, 'get_Vm')
    gk_table = moose.Table('%s/Gk' % (container_path))
    moose.connect(gk_table, 'requestData', channel, 'get_Gk')
    ik_table = moose.Table('%s/Ik' % (container_path))
    moose.connect(ik_table, 'requestData', channel, 'get_Ik')
    moose.setClock(0, simdt)
    moose.setClock(1, simdt)
    moose.setClock(2, simdt)
    moose.useClock(0, '%s/##[TYPE=Compartment]' % (container_path), 'init')
    moose.useClock(1, '%s/##[TYPE=Compartment]' % (container_path), 'process')
    moose.useClock(2, '%s/##[TYPE!=Compartment]' % (container_path), 'process')

    return {'compartment': comp,
            'stimulus': pulsegen,
            'channel': channel,
            'Vm': vm_table,
            'Gk': gk_table,
            'Ik': ik_table}
开发者ID:Vivek-sagar,项目名称:moose-1,代码行数:26,代码来源:hsolvetestutil.py

示例10: addCaPool

def addCaPool(model,OutershellThickness,BufCapacity,comp,caproto,tau=None,tauScale=None):
    #create the calcium pools in each compartment
    capool = moose.copy(caproto, comp, caproto.name)[0]
    capool.thick = OutershellThickness
    capool.diameter = comp.diameter
    capool.length = comp.length
    radius = comp.diameter/2.
    if capool.thick > radius:
        capool.thick = radius
    if capool.length:
        vol = np.pi * comp.length * (radius**2 - (radius-capool.thick)**2)
    else:
        vol = 4./3.*np.pi*(radius**3-(radius-capool.thick)**3)
    if tau is not None:
        capool.tau = tau#*np.pi*comp.diameter*comp.length *0.125e10 #/(np.pi*comp.length*(comp.diameter/2)**2) #
        if tauScale is not None:
            if tauScale == 'SurfaceArea':
                capool.tau = tau * (np.pi * comp.diameter * comp.length) / 8.478e-11 # normalize to primdend surface area
            elif tauScale == 'Volume':
                capool.tau = tau / vol
            elif tauScale == 'SVR': #surface to volume ratio
                capool.tau = tau / (np.pi * comp.diameter * comp.length)/vol


    capool.B = 1. / (constants.Faraday*vol*2) / BufCapacity #volume correction

    connectVDCC_KCa(model,comp,capool,'current','concOut')
    connectNMDA(comp,capool,'current','concOut')
    #print('Adding CaConc to '+capool.path)
    return capool
开发者ID:neurord,项目名称:spspine,代码行数:30,代码来源:calcium.py

示例11: copyChannel

    def copyChannel(self, chdens, comp, condDensity, erev):
        """Copy moose prototype for `chdens` condutcance density to `comp`
        compartment.

        """
        proto_chan = None
        if chdens.ion_channel in self.proto_chans:
            proto_chan = self.proto_chans[chdens.ion_channel]
        else:
            for innerReader in self.includes.values():
                if chdens.ionChannel in innerReader.proto_chans:
                    proto_chan = innerReader.proto_chans[chdens.ion_channel]
                    break
        if not proto_chan:
            raise Exception('No prototype channel for %s referred to by %s' % (chdens.ion_channel, chdens.id))

        if self.verbose:
            print('Copying %s to %s, %s; erev=%s'%(chdens.id, comp, condDensity, erev))
        orig = chdens.id
        chid = moose.copy(proto_chan, comp, chdens.id)
        chan = moose.element(chid)
        for p in self.paths_to_chan_elements.keys():
            pp = p.replace('%s/'%chdens.ion_channel,'%s/'%orig)
            self.paths_to_chan_elements[pp] = self.paths_to_chan_elements[p].replace('%s/'%chdens.ion_channel,'%s/'%orig)
        #print(self.paths_to_chan_elements)
        chan.Gbar = sarea(comp) * condDensity
        chan.Ek = erev
        moose.connect(chan, 'channel', comp, 'channel')
        return chan    
开发者ID:pgleeson,项目名称:moose-core,代码行数:29,代码来源:reader.py

示例12: create_neuron

def create_neuron(model, ntype, ghkYN):
    p_file = find_morph_file(model,ntype)
    try:
        cellproto=moose.loadModel(p_file, ntype)
    except IOError:
        print('could not load model from {!r}'.format(p_file))
        raise
    #######channels
    Cond = model.Condset[ntype]
    for comp in moose.wildcardFind('{}/#[TYPE=Compartment]'.format(ntype)):
        #If we are using GHK, just create one GHK per compartment, connect it to comp
        #calcium concentration is connected in a different function
        if ghkYN:
            ghkproto=moose.element('/library/ghk')
            ghk=moose.copy(ghkproto,comp,'ghk')[0]
            moose.connect(ghk,'channel',comp,'channel')
        else:
            ghk=[]
        for channame in Cond.keys():
            c = _util.distance_mapping(Cond[channame], comp)
            if c > 0:
                log.debug('Testing Cond If {} {}', channame, c)
                calciumPermeable = model.Channels[channame].calciumPermeable
                add_channel.addOneChan(channame, c, comp, ghkYN, ghk, calciumPermeable=calciumPermeable)

        #Compensate for actual, experimentally estimated spine density.
        #This gives a model that can be simulated with no explicit spines or
        #any number of explicitly modeled spines up to the actual spine density:
        spines.compensate_for_spines(model,comp,model.param_cond.NAME_SOMA)

    return cellproto
开发者ID:neurord,项目名称:spspine,代码行数:31,代码来源:cell_proto.py

示例13: create_population

def create_population(container, netparams, name_soma):
    netpath = container.path
    proto=[]
    neurXclass={}
    locationlist=[]
    #determine total number of neurons
    size,numneurons,vol=count_neurons(netparams)
    pop_percent=[]
    for neurtype in netparams.pop_dict.keys():
        if moose.exists(neurtype):
            proto.append(moose.element(neurtype))
            neurXclass[neurtype]=[]
            pop_percent.append(netparams.pop_dict[neurtype].percent)
    #create cumulative array of probabilities for selecting neuron type
    choicearray=np.cumsum(pop_percent)
    if choicearray[-1]<1.0:
        log.info("Warning!!!! fractional populations sum to {}",choicearray[-1])
    #array of random numbers that will be used to select neuron type
    rannum = np.random.uniform(0,choicearray[-1],numneurons)
    #Error check for last element in choicearray equal to 1.0
    log.info("numneurons= {} {} choicarray={}", size, numneurons, choicearray)
    log.debug("rannum={}", rannum)
    for i,xloc in enumerate(np.linspace(netparams.grid[0]['xyzmin'], netparams.grid[0]['xyzmax'], size[0])):
        for j,yloc in enumerate(np.linspace(netparams.grid[1]['xyzmin'], netparams.grid[1]['xyzmax'], size[1])):
            for k,zloc in enumerate(np.linspace(netparams.grid[2]['xyzmin'], netparams.grid[2]['xyzmax'], size[2])):
                #for each location in grid, assign neuron type, update soma location, add in spike generator
                neurnumber=i*size[2]*size[1]+j*size[2]+k
                neurtypenum=np.min(np.where(rannum[neurnumber]<choicearray))
                log.debug("i,j,k {} {} {} neurnumber {} type {}", i,j,k, neurnumber, neurtypenum)
                typename = proto[neurtypenum].name
                tag = '{}_{}'.format(typename, neurnumber)
                new_neuron=moose.copy(proto[neurtypenum],netpath, tag)
                neurXclass[typename].append(container.path + '/' + tag)
                comp=moose.element(new_neuron.path + '/'+name_soma)
                comp.x=i*xloc
                comp.y=j*yloc
                comp.z=k*zloc
                log.debug("x,y,z={},{},{} {}", comp.x, comp.y, comp.z, new_neuron.path)
                locationlist.append([new_neuron.name,comp.x,comp.y,comp.z])
                #spike generator - can this be done to the neuron prototype?
                spikegen = moose.SpikeGen(comp.path + '/spikegen')
                #should these be parameters in netparams?
                spikegen.threshold = 0.0
                spikegen.refractT=1e-3
                m = moose.connect(comp, 'VmOut', spikegen, 'Vm')
    #Create variability in neurons of network
    for neurtype in netparams.chanvar.keys():
        for chan,var in netparams.chanvar[neurtype].items():
            #single multiplier for Gbar for all the channels compartments
            if var>0:
                log.debug('adding variability to {} soma {}, variance: {}', neurtype,chan, var)
                GbarArray=abs(np.random.normal(1.0, var, len(neurXclass[neurtype])))
                for ii,neurname in enumerate(neurXclass[neurtype]):
                    soma_chan_path=neurname+'/'+name_soma+'/'+chan
                    if moose.exists(soma_chan_path):
                        chancomp=moose.element(soma_chan_path)
                        chancomp.Gbar=chancomp.Gbar*GbarArray[ii]
    #
    return {'location': locationlist,
            'pop':neurXclass}
开发者ID:neurord,项目名称:spspine,代码行数:60,代码来源:pop_funcs.py

示例14: make_new_synapse

def make_new_synapse(syn_name, postcomp, syn_name_full, nml_params):
    ## if channel does not exist in library load it from xml file
    if not moose.exists("/library/" + syn_name):
        cmlR = ChannelML(nml_params)
        model_filename = syn_name + ".xml"
        model_path = utils.find_first_file(model_filename, nml_params["model_dir"])
        if model_path is not None:
            cmlR.readChannelMLFromFile(model_path)
        else:
            raise IOError(
                "For mechanism {0}: files {1} not found under {2}.".format(
                    mechanismname, model_filename, self.model_dir
                )
            )
    ## deep copies the library SynChan and SynHandler
    ## to instances under postcomp named as <arg3>
    synid = moose.copy(moose.element("/library/" + syn_name), postcomp, syn_name_full)
    # synhandlerid = moose.copy(moose.element('/library/'+syn_name+'/handler'), postcomp,syn_name_full+'/handler') This line was a bug: double handler
    synhandler = moose.element(synid.path + "/handler")
    syn = moose.SynChan(synid)
    synhandler = moose.element(synid.path + "/handler")  # returns SimpleSynHandler or STDPSynHandler

    ## connect the SimpleSynHandler or the STDPSynHandler to the SynChan (double exp)
    moose.connect(synhandler, "activationOut", syn, "activation")
    # mgblock connections if required
    childmgblock = moose_utils.get_child_Mstring(syn, "mgblockStr")
    #### connect the post compartment to the synapse
    if childmgblock.value == "True":  # If NMDA synapse based on mgblock, connect to mgblock
        mgblock = moose.Mg_block(syn.path + "/mgblock")
        moose.connect(postcomp, "channel", mgblock, "channel")
    else:  # if SynChan or even NMDAChan, connect normally
        moose.connect(postcomp, "channel", syn, "channel")
开发者ID:BhallaLab,项目名称:moose,代码行数:32,代码来源:ChannelML.py

示例15: create_LIF

def create_LIF():
    neuromlR = NeuroML()
    neuromlR.readNeuroMLFromFile('cells_channels/LIF.morph.xml')
    libcell = moose.Neuron('/library/LIF')
    LIFCellid = moose.copy(libcell,moose.Neutral('/cells'),'IF1')
    LIFCell = moose.Neuron(LIFCellid)
    return LIFCell
开发者ID:dilawar,项目名称:moose-examples,代码行数:7,代码来源:LIFxml_firing.py


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