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


Python ProjectManager.doGenerate方法代码示例

本文整理汇总了Python中ucl.physiol.neuroconstruct.project.ProjectManager.doGenerate方法的典型用法代码示例。如果您正苦于以下问题:Python ProjectManager.doGenerate方法的具体用法?Python ProjectManager.doGenerate怎么用?Python ProjectManager.doGenerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ucl.physiol.neuroconstruct.project.ProjectManager的用法示例。


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

示例1: File

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
import time
import shutil
import random
import os
import subprocess

# Load the original project
projName = "LarkumEtAl2009"
projFile = File("/home/matteo/neuroConstruct/models/"+projName+"/"+projName+".ncx")

print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())
pm = ProjectManager()
myProject = pm.loadProject(projFile)
simConfig = myProject.simConfigInfo.getSimConfig("Default Simulation Configuration")#
randomseed = random.randint(1000,5000)
pm.doGenerate(simConfig.getName(),  randomseed)
while pm.isGenerating():
    print "Waiting for the project to be generated..."
    time.sleep(2)    
numGenerated = myProject.generatedCellPositions.getNumberInAllCellGroups()

simsRunning = []
def updateSimsRunning():
    simsFinished = []
    for sim in simsRunning:
        timeFile = File(myProject.getProjectMainDirectory(), "simulations/"+sim+"/time.dat")
        #print "Checking file: "+timeFile.getAbsolutePath() +", exists: "+ str(timeFile.exists())
        if (timeFile.exists()):
            simsFinished.append(sim)
    if(len(simsFinished)>0):
        for sim in simsFinished:
开发者ID:pgleeson,项目名称:TestArea,代码行数:33,代码来源:PNMDAs_distributedinput.py

示例2: channels

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
dendritic_group = 'apical_dend_2'

# switch off Na channels (TTX)
reduced_cell_type = project.cellManager.getCell('GJGolgi_Reduced')
vervaeke_cell_type = project.cellManager.getCell('Golgi_210710_C1')
for chan in reduced_cell_type.getChanMechsForGroup('soma_group'):
    if chan.getName() in ['NaP_CML', 'NaR_CML', 'NaT_CML']:
	chan.setDensity(0)
	reduced_cell_type.associateGroupWithChanMech('soma_group', chan)
for chan in vervaeke_cell_type.getChanMechsForGroup('soma_group'):
    if chan.getName() in ['NaP', 'NaR', 'NaT']:
	chan.setDensity(0)
	vervaeke_cell_type.associateGroupWithChanMech('soma_group', chan)

# generate
pm.doGenerate(sim_config_name, 1234)
while pm.isGenerating():
    time.sleep(0.02)

# pick a segment to stimulate on the detailed cell
cth = CellTopologyHelper()
distances_dict = dict(cth.getSegmentDistancesFromRoot(vervaeke_cell_type, dendritic_group))
stim_seg_detailed = random.choice([seg_id for seg_id,dist in distances_dict.items() if 200. < dist < 220.])

# pick a segment to stimulate on the reduced cell
stim_seg_reduced = 6

# map distances of all ancestors of stimulation segment
ancestor_dists = dict(cth.getDistancesFromAncestorSegments(vervaeke_cell_type, stim_seg_detailed))

source_segment_index = 0
开发者ID:RokasSt,项目名称:GJGolgi_ReducedMorph,代码行数:33,代码来源:dendritic_attenuation.py

示例3: runColumnSimulation

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]

#.........这里部分代码省略.........
	    inCell = project.cellManager.getCell(inCellName)
	    info = CellTopologyHelper.recompartmentaliseCell(inCell, maxElecLenIN, project)
	    print "Recompartmentalised "+inCellName+" cell: "+info
	    if somaNseg > 0:
		inCell.getSegmentWithId(0).getSection().setNumberInternalDivisions(somaNseg)


    ### Change parallel configuration

    mpiSettings = MpiSettings()
    simConfig.setMpiConf(mpiSettings.getMpiConfiguration(mpiConf))
    print "Parallel configuration: "+ str(simConfig.getMpiConf())

    if suggestedRemoteRunTime > 0:
	project.neuronFileManager.setSuggestedRemoteRunTime(suggestedRemoteRunTime)
	project.genesisFileManager.setSuggestedRemoteRunTime(suggestedRemoteRunTime)


    ### Change synaptic delay associated with each net conn

    for netConnName in simConfig.getNetConns():
	if netConnName.count("gap")==0:
	    print "Changing synaptic delay in %s to %f"%(netConnName, defaultSynapticDelay)
	    delayGen = NumberGenerator(defaultSynapticDelay)
	    for synProps in project.morphNetworkConnectionsInfo.getSynapseList(netConnName):
		synProps.setDelayGenerator(delayGen)

    # defaultSynapticDelay will be recorded in simulation.props and listed in SimulationBrowser GUI
    SimulationsInfo.addExtraSimProperty("defaultSynapticDelay", str(defaultSynapticDelay))


    ### Generate network structure in neuroConstruct

    pm.doGenerate(simConfig.getName(), neuroConstructSeed)

    while pm.isGenerating():
	    print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
	    sleep(2)


    print "Generated %i cells in %i cell groups" % (project.generatedCellPositions.getNumberInAllCellGroups(), project.generatedCellPositions.getNumberNonEmptyCellGroups())
    print "Generated %i instances in %i network connections" % (project.generatedNetworkConnections.getNumAllSynConns(), project.generatedNetworkConnections.getNumNonEmptyNetConns())
    print "Generated %i instances in %i elect inputs" % (project.generatedElecInputs.getNumberSingleInputs(), project.generatedElecInputs.getNonEmptyInputRefs().size())


    if simulators.count("NEURON")>0:
	
	simRefN = simRef+"_N"
	project.simulationParameters.setReference(simRefN)

	nc.generateAndRunNeuron(project,
				pm,
				simConfig,
				simRefN,
				simulatorSeed,
				verbose=verbose,
				runInBackground=runInBackground,
				varTimestep=varTimestepNeuron)
	    
	sleep(2) # wait a while before running GENESIS...
	
    if simulators.count("GENESIS")>0:
	
	simRefG = simRef+"_G"
	project.simulationParameters.setReference(simRefG)
开发者ID:OpenSourceBrain,项目名称:Thalamocortical,代码行数:69,代码来源:RunColumn.py

示例4: NumberGenerator

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
### Change synaptic delay associated with each net conn

for netConnName in simConfig.getNetConns():
    if netConnName.count("gap")==0:
        print "Changing synaptic delay in %s to %f"%(netConnName, defaultSynapticDelay)
        delayGen = NumberGenerator(defaultSynapticDelay)
        for synProps in project.morphNetworkConnectionsInfo.getSynapseList(netConnName):
            synProps.setDelayGenerator(delayGen)

# defaultSynapticDelay will be recorded in simulation.props and listed in SimulationBrowser GUI
SimulationsInfo.addExtraSimProperty("defaultSynapticDelay", str(defaultSynapticDelay))


### Generate network structure in neuroConstruct

pm.doGenerate(simConfig.getName(), neuroConstructSeed)

while pm.isGenerating():
        print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
        sleep(2)


print "Number of cells generated: " + str(project.generatedCellPositions.getNumberInAllCellGroups())
print "Number of network connections generated: " + str(project.generatedNetworkConnections.getNumAllSynConns())


if simulators.count("NEURON")>0:
    
    simRefN = simRef+"_N"
    project.simulationParameters.setReference(simRefN)
开发者ID:pgleeson,项目名称:TestArea,代码行数:32,代码来源:GenNetworkParallel.py

示例5: testAll

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
def testAll(argv=None):
    if argv is None:
        argv = sys.argv

    # Load an existing neuroConstruct project
    projFile = File("../CElegans.ncx")
    print "Loading project from file: " + projFile.getAbsolutePath() + ", exists: " + str(projFile.exists())

    pm = ProjectManager()
    project = pm.loadProject(projFile)
    print "Loaded project: " + project.getProjectName()

    defSimConfig = project.simConfigInfo.getDefaultSimConfig()
    cellsOnlySimConfig = project.simConfigInfo.getSimConfig("CellsOnly")
    pharyngealSimConfig = project.simConfigInfo.getSimConfig("PharyngealNeurons")

    expectedNumberCells = 302

    ##########################

    print "\n----- Test 1: Check number of cells in sim config " + defSimConfig.getName() + "..."

    pm.doGenerate(defSimConfig.getName(), 1234)

    while pm.isGenerating():
        print "Waiting for the project to be generated with Simulation Configuration: " + str(defSimConfig)
        sleep(2)

    numGenerated = project.generatedCellPositions.getNumberInAllCellGroups()

    print "Number of cells generated: " + str(numGenerated)

    assert numGenerated == expectedNumberCells

    print "Correct number of cells generated!"

    ##########################

    print "\n---- Test 2: number of cells in sim config " + cellsOnlySimConfig.getName() + "..."

    pm.doGenerate(cellsOnlySimConfig.getName(), 1234)

    while pm.isGenerating():
        print "Waiting for the project to be generated with Simulation Configuration: " + str(cellsOnlySimConfig)
        sleep(2)

    numGenerated = project.generatedCellPositions.getNumberInAllCellGroups()

    print "Number of cells generated: " + str(numGenerated)

    assert numGenerated == expectedNumberCells

    print "Correct number of cells generated!"

    ##########################

    filename = "../../CElegansNeuronTables.xls"
    print "\n---- Test 3: confirm settings in project match those in  " + filename + "..."

    from xlrd import open_workbook

    rb = open_workbook(filename)

    print "Opened Excel file: " + filename

    confirmed = 0
    prefix = "NCXLS_"

    for row in range(1, rb.sheet_by_index(0).nrows):
        pre = rb.sheet_by_index(0).cell(row, 0).value
        post = rb.sheet_by_index(0).cell(row, 1).value
        syntype = rb.sheet_by_index(0).cell(row, 2).value
        num = int(rb.sheet_by_index(0).cell(row, 3).value)
        synclass = rb.sheet_by_index(0).cell(row, 4).value

        # print "------------------------------------------\nConnection %i has %i from %s to %s (type: %s, synapse: %s)" %(row, num, pre, post, syntype, synclass)

        netConnName = prefix + pre + "_" + post

        if "GapJunction" in syntype:
            netConnName = netConnName + "_GJ"

        src = project.morphNetworkConnectionsInfo.getSourceCellGroup(netConnName)
        tgt = project.morphNetworkConnectionsInfo.getTargetCellGroup(netConnName)

        if not (src == pre and tgt == post):
            print "------------------------------------------\nConnection %i has %i from %s to %s (type: %s, synapse: %s)" % (
                row,
                num,
                pre,
                post,
                syntype,
                synclass,
            )
            print "*** Couldn't find connection: %s, src: %s, tgt: %s" % (netConnName, src, tgt)
            assert src == pre
            assert tgt == post

        if src == tgt:
            print "------------------------------------------\nConnection %i has %i from %s to %s (type: %s, synapse: %s)" % (
#.........这里部分代码省略.........
开发者ID:mattions,项目名称:CElegansNeuroML,代码行数:103,代码来源:CheckProject.py

示例6: make_fF_Curve

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
	def make_fF_Curve(self,
                          projFile,
                          simulator,
                          simConfig,
                          nTrains,
                          simDuration,
                          analyseStartTime, analyseStopTime,
                          analyseThreshold,
                          maxNumSimultaneousSims = 4):

			# Load neuroConstruct project

			print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

			pm = ProjectManager()
			self.myProject = pm.loadProject(projFile)
			self.simulator = simulator

			simConfig = self.myProject.simConfigInfo.getSimConfig(simConfig)

			simConfig.setSimDuration(simDuration)

			pm.doGenerate(simConfig.getName(), self.neuroConstructSeed)

			while pm.isGenerating():
					print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
					time.sleep(2)

			numGenerated = self.myProject.generatedCellPositions.getNumberInAllCellGroups()

			print "Number of cells generated: " + str(numGenerated)

			simReferences = {}


			if numGenerated > 0:

					print "Generating scripts for simulator: %s..."%simulator

					if simulator == 'NEURON':
						self.myProject.neuronFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.neuronSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.neuronSettings.setGraphicsMode(0) # 0 hides graphs during execution
                        
					if simulator == 'GENESIS':
						self.myProject.genesisFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.genesisSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.genesisSettings.setGraphicsMode(0) # 0 hides graphs during execution


					currentTrain = 0

					ADD_TO_START_FINITIALIZE = self.myProject.neuronSettings.getNativeBlock(NativeCodeLocation.START_FINITIALIZE)
					ADD_TO_RECORD_I = self.myProject.neuronSettings.getNativeBlock(NativeCodeLocation.AFTER_SIMULATION)

					while currentTrain <= nTrains:

							while (len(self.simsRunning)>=maxNumSimultaneousSims):
									print "Sims currently running: "+str(self.simsRunning)
									print "Waiting..."
									time.sleep(3) # wait a while...
									self.updateSimsRunning()


							simRef = "PySim_"+str(currentTrain)

							print "Going to run simulation: "+simRef

							########  Adjusting the amplitude of the Voltage clamp ###############

                                                        TEXT_BEFORE_CREATION = """objref vector, gTrainFile\n""" + "objectvar clamp\n"

                                                        ### TEXT_BEFORE_INIT = "GranuleCell_mod_tonic[0].Soma {\n" + "clampobj = new VClamp(0.5)\n" + "clampobj.dur[0] = " + str(stimDur) + "\n" + "clampobj.amp[0] = " + str(stimAmp) + "\n" +  "}\n" # This should do the trick

                                                        TEXT_START_FINITIALIZE = "\n" + "gTrainFile = new File() \n" + "vector = new Vector(100000) \n" + "access GranuleCell_mod_tonic[0].Soma \n" + "clamp = new SEClamp(0.5) \n" + "clamp.amp1 = 0 \n" + "clamp.dur1 = 1e9 \n" + """gTrainFile.ropen("E:/neuroConstruct/models/Dan_GranCell/gTrains_nS/gAMPA_""" + str(currentTrain) + """.txt") \n""" + "vector.scanf(gTrainFile) \n" + "gTrainFile.close \n" + "for i = 0, vector.size() -1 { \n" + "     if (vector.x[i] <= 0) { \n" + "          vector.x[i] = 1e-20 \n" + "              } \n" + "        } \n" + "for i = 0, vector.size() -1 { \n" + "    vector.x[i] = ( 1 / vector.x[i] ) * 1000 \n" + "    } \n" + "vector.play(&clamp.rs, 0.03) \n" # This

                                                        TEXT_START_FINITIALIZE = TEXT_START_FINITIALIZE + ADD_TO_START_FINITIALIZE

                                                        TEXT_TO_RECORD_I = """// currently not used \n"""

                                                        TEXT_TO_RECORD_I = TEXT_TO_RECORD_I + ADD_TO_RECORD_I

                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.BEFORE_CELL_CREATION, TEXT_BEFORE_CREATION)
                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.START_FINITIALIZE, TEXT_START_FINITIALIZE)
                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.AFTER_SIMULATION, TEXT_TO_RECORD_I)

					
							print "Next Train: "+ str(currentTrain)

							self.myProject.simulationParameters.setReference(simRef)

							if simulator == "NEURON":
									self.myProject.neuronFileManager.generateTheNeuronFiles(simConfig,
																							None,
																							NeuronFileManager.RUN_HOC,
																							self.simulatorSeed)

									print "Generated NEURON files for: "+simRef

									compileProcess = ProcessManager(self.myProject.neuronFileManager.getMainHocFile())
#.........这里部分代码省略.........
开发者ID:pgleeson,项目名称:TestArea,代码行数:103,代码来源:Generate_fF_Curve.py

示例7: MultiSim

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
class MultiSim(object):
    pconf = None
    logger = None
    proj_path = None
    pm = None
    myProject = None
    simConfig = None
    stimulation = None
    cellName = None
    simulatorSeed = None
    numGenerated = 0
    maxNumSimultaneousSims = 1
    simsRunning = []

    # A value of 0 or lower deactivates timeout.
    sim_timeout = 0
    
    def __init__(self, pconf):
        configDict = pconf.parse_project_data()
        self.pconf = pconf
        self.logger = pconf.get_logger("neurosim")
        self.proj_path = self.pconf.local_path(configDict["proj_path"])
        self.pm = ProjectManager()
        
        projFile = File(self.proj_path)
        self.sim_timeout = self.pconf.get_float("sim_timeout", "Simulation")
        self.myProject = self.pm.loadProject(projFile)
        self.simConfig = self.myProject.simConfigInfo.getSimConfig(self.pconf.get("sim_config", "Simulation"))
    #-----------------------------------------------------------
    def generate(self):

        neuroConstructSeed = int(self.pconf.get("neuroConstructSeed", "NeuroConstruct"))
        self.stimulation = self.pconf.get("stimulation", "Simulation")
        self.cellName = self.pconf.get("cell", "Simulation")
        self.simulatorSeed = int(self.pconf.get("simulatorSeed", "NeuroConstruct"))
        self.pm.doGenerate(self.simConfig.getName(), neuroConstructSeed)
        self.logger.debug("Waiting for the project to be generated...")
        t = 0.0
        startTime = time.time()
        while self.pm.isGenerating():
            self.logger.debug("Waiting...")
            time.sleep(0.050)
            t += 0.050
            if t > 5.0:
                self.logger.debug("Waiting...")
                t = 0.0
            if self.sim_timeout > 0 and (time.time() - startTime) > self.sim_timeout:
                self.logger.error("Project data could not be created due to timeout.")
                raise SimTimeoutError(self.sim_timeout, "Simulation timeout occured during project generation.")
        self.numGenerated = self.myProject.generatedCellPositions.getNumberInAllCellGroups()
        self.logger.debug("Number of cells generated: " + str(self.numGenerated))

        if self.numGenerated > 0:
            self.logger.info("Generating NEURON scripts...")
            self.myProject.neuronSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
            # hier kann man entscheiden, ob Bilder angezeigt werden sollen oder nicht: 
                # ist ersteres auskommentiert, werden Bilder angezeigt und bei Einkommentierung des Zweiten auch automatisch wieder geschlossen
            self.myProject.neuronSettings.setNoConsole()

            max_sim_threads = self.pconf.get("maxSimThreads")
            if max_sim_threads == "auto":
                self.maxNumSimultaneousSims = available_cpu_count()
            else:
                self.maxNumSimultaneousSims = max(1, int(max_sim_threads))
    #-----------------------------------------------------------
    def run(self, prefix, dataList):
        """Runs all simulations defined by dataList for the loaded project.

        Each sim will be named (prefix + i) and dataList contains a
        dict with at least "densities", "channels" and "locations" keys.
        """
        try:
            for i in range(len(dataList)):
                self.waitForSimsRunning(self.maxNumSimultaneousSims - 1)
                if not self.runSim(i, prefix, dataList[i]):
                    sys.exit(0)
            self.waitForSimsRunning(0)
            self.logger.info("Finished running " + str(len(dataList)) + " simulations for project " + self.proj_path)
            return
        except (KeyboardInterrupt, SystemExit):
            raise
        except SimTimeoutError, e:
            self.logger.warning("Timeout occured: " + e.msg)
            sys.exit(10)
开发者ID:ChristophMetzner,项目名称:ROB-SS14-BachProj,代码行数:86,代码来源:neurosim.py

示例8: testAll

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
def testAll(argv=None):
    if argv is None:
        argv = sys.argv

    # Load an existing neuroConstruct project
    projFile = File("../CElegans.ncx")
    print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

    pm = ProjectManager()
    project = pm.loadProject(projFile)
    print "Loaded project: " + project.getProjectName()


    defSimConfig = project.simConfigInfo.getDefaultSimConfig()
    cellsOnlySimConfig = project.simConfigInfo.getSimConfig("CellsOnly")
    pharyngealSimConfig = project.simConfigInfo.getSimConfig("PharyngealNeurons")
    mdl08SimConfig = project.simConfigInfo.getSimConfig("MDL08Connections")

    expectedNumberCells = 302 

    
    ##########################
    
    print "\n----- Test 1: Check number of cells in sim config "+defSimConfig.getName()+"..."


    pm.doGenerate(defSimConfig.getName(), 1234)

    while pm.isGenerating():
            print "Waiting for the project to be generated with Simulation Configuration: "+str(defSimConfig)
            sleep(2)

    numGenerated = project.generatedCellPositions.getNumberInAllCellGroups()

    print "Number of cells generated: " + str(numGenerated)

    assert numGenerated == expectedNumberCells

    print "Correct number of cells generated!"

    ##########################

    print "\n---- Test 2: number of cells in sim config "+cellsOnlySimConfig.getName()+"..."


    pm.doGenerate(cellsOnlySimConfig.getName(), 1234)

    while pm.isGenerating():
            print "Waiting for the project to be generated with Simulation Configuration: "+str(cellsOnlySimConfig)
            sleep(2)

    numGenerated = project.generatedCellPositions.getNumberInAllCellGroups()

    print "Number of cells generated: " + str(numGenerated)

    assert numGenerated == expectedNumberCells

    print "Correct number of cells generated!"
    
    ##########################

    filename = "../../CElegansNeuronTables.xls"
    print "\n---- Test 3: confirm settings in project match those in  "+filename+"..."

    from xlrd import open_workbook
    rb = open_workbook(filename)

    print "Opened Excel file: "+ filename

    confirmed = 0
    prefix = "NCXLS_"

    for row in range(1,rb.sheet_by_index(0).nrows):
      pre = rb.sheet_by_index(0).cell(row,0).value
      post = rb.sheet_by_index(0).cell(row,1).value
      syntype = rb.sheet_by_index(0).cell(row,2).value
      num = int(rb.sheet_by_index(0).cell(row,3).value)
      synclass = rb.sheet_by_index(0).cell(row,4).value

      #print "------------------------------------------\nConnection %i has %i from %s to %s (type: %s, synapse: %s)" %(row, num, pre, post, syntype, synclass)


      netConnName = prefix+pre+"_"+post

      if "GapJunction" in syntype:
            netConnName = netConnName + "_GJ"

      src = project.morphNetworkConnectionsInfo.getSourceCellGroup(netConnName)
      tgt = project.morphNetworkConnectionsInfo.getTargetCellGroup(netConnName)

      synlist = project.morphNetworkConnectionsInfo.getSynapseList(netConnName)

      #print synlist

      assert synclass == synlist[0].getSynapseType()

      if '_GJ' in synclass and synclass != 'Generic_GJ':
        print "Only allowed gap junction synapse is Generic_GJ, not "+synclass
        assert synclass == 'Generic_GJ'
      
#.........这里部分代码省略.........
开发者ID:Jueast,项目名称:CElegansNeuroML,代码行数:103,代码来源:CheckProject.py

示例9: str

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

pm = ProjectManager()
project = pm.loadProject(projFile)
print "Loaded project: " + project.getProjectName()


simConfig = project.simConfigInfo.getSimConfig("CellsOnly")

expectedNumberCells = 302


##########################


pm.doGenerate(simConfig.getName(), 1234)

while pm.isGenerating():
        print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
        sleep(2)

numGenerated = project.generatedCellPositions.getNumberInAllCellGroups()

print "Number of cells generated: " + str(numGenerated)

assert numGenerated == expectedNumberCells

print "Correct number of cells generated!"

nmlFileName = "GeneratedNeuroML.xml"
开发者ID:Jueast,项目名称:CElegansNeuroML,代码行数:32,代码来源:GenerateNeuroML.py

示例10: generateF_ICurve

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
	def generateF_ICurve(self,
                         projFile,
                         simulator,
                         simConfig,
                         preStimAmp, preStimDel, preStimDur,
                         stimAmpLow, stimAmpInc, stimAmpHigh,
                         stimDel, stimDur,
                         simDuration,
                         analyseStartTime, analyseStopTime,
                         analyseThreshold,
                         maxNumSimultaneousSims = 4):

			# Load neuroConstruct project

			print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

			pm = ProjectManager()
			self.myProject = pm.loadProject(projFile)
			self.simulator = simulator

			simConfig = self.myProject.simConfigInfo.getSimConfig(simConfig)

			simConfig.setSimDuration(simDuration)

			pm.doGenerate(simConfig.getName(), self.neuroConstructSeed)

			while pm.isGenerating():
					print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
					time.sleep(2)

			numGenerated = self.myProject.generatedCellPositions.getNumberInAllCellGroups()

			print "Number of cells generated: " + str(numGenerated)

			simReferences = {}


			if numGenerated > 0:

					print "Generating scripts for simulator: %s..."%simulator

					if simulator == 'NEURON':
						self.myProject.neuronFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.neuronSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.neuronSettings.setGraphicsMode(0) # 0 hides graphs during execution
                        
					if simulator == 'GENESIS':
						self.myProject.genesisFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.genesisSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.genesisSettings.setGraphicsMode(0) # 0 hides graphs during execution


					stimAmp = stimAmpLow

					while stimAmp <= stimAmpHigh:

							while (len(self.simsRunning)>=maxNumSimultaneousSims):
									print "Sims currently running: "+str(self.simsRunning)
									print "Waiting..."
									time.sleep(3) # wait a while...
									self.updateSimsRunning()


							simRef = "PySim_"+str(float(stimAmp))

							print "Going to run simulation: "+simRef

							########  Adjusting the amplitude of the current clamp ###############

                                                        # preStim = self.myProject.elecInputInfo.getStim(simConfig.getInputs().get(0))
							preStim = self.myProject.elecInputInfo.getStim("Input_3")

							preStim.setAmp(NumberGenerator(preStimAmp))
							preStim.setDel(NumberGenerator(preStimDel))
							preStim.setDur(NumberGenerator(preStimDur))
							self.myProject.elecInputInfo.updateStim(preStim)


							# stim = self.myProject.elecInputInfo.getStim(simConfig.getInputs().get(1))
							stim = self.myProject.elecInputInfo.getStim("Input_4")
							

							stim.setAmp(NumberGenerator(stimAmp))
							stim.setDel(NumberGenerator(stimDel))
							stim.setDur(NumberGenerator(stimDur))
							self.myProject.elecInputInfo.updateStim(stim)

							print "Next stim: "+ str(stim)

							self.myProject.simulationParameters.setReference(simRef)

							if simulator == "NEURON":
									self.myProject.neuronFileManager.generateTheNeuronFiles(simConfig,
																							None,
																							NeuronFileManager.RUN_HOC,
																							self.simulatorSeed)

									print "Generated NEURON files for: "+simRef

									compileProcess = ProcessManager(self.myProject.neuronFileManager.getMainHocFile())
#.........这里部分代码省略.........
开发者ID:pgleeson,项目名称:TestArea,代码行数:103,代码来源:GenerateF_ICurve.py

示例11: SingleCellNML2generator

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
def SingleCellNML2generator(projString=" ",ConfigDict={},ElecLenList=[],somaNseg=None,savingDir=None,shell=None):
    
    projFile=File(os.getcwd(),projString)
    
    pm=ProjectManager()
    
    for config in ConfigDict.keys():
    
        project=pm.loadProject(projFile)
        
        nmlfm = NeuroMLFileManager(project)
        
        compSummary={}
       
        compSummary[config]={}
        
        if " " in config:
           configPath=config.replace(" ","_")
        else:
           configPath=config
           
        if savingDir !=None:
        
           full_path_to_config=r'../%s/%s'%(savingDir,configPath)
           
        else:
        
           full_path_to_config=r'../%s'%(configPath)
        
        for maxElecLen in ElecLenList:
            compSummary[config][str(maxElecLen)]={}
            cell=project.cellManager.getCell(ConfigDict[config])
            
            if maxElecLen > 0:

	       info = CellTopologyHelper.recompartmentaliseCell(cell, maxElecLen, project)
	       print "Recompartmentalising cell %s"%ConfigDict[config]
	       if somaNseg != None:
	          cell.getSegmentWithId(0).getSection().setNumberInternalDivisions(somaNseg)
	       if savingDir !=None: 
	          cellpath = r'../%s/%s/%s_%f'%(savingDir,configPath,configPath,maxElecLen)
	       else:
	          cellpath = r'../%s/%s_%f'%(configPath,configPath,maxElecLen)
	       
	    else:
	       if savingDir !=None:
	          cellpath = r'../%s/%s/%s_default'%(savingDir,configPath,configPath)
	       else:
	          cellpath = r'../%s/%s_default'%(configPath,configPath)
	       
	    summary=str(cell.getMorphSummary()) 
	    summary_string=summary.split("_")
	    for feature in summary_string:
	        feature_split=feature.split(":")
	        compSummary[config][str(maxElecLen)][feature_split[0]]=feature_split[1]
	    # the format of summary :  Segs:122_Secs:61_IntDivs:1458
	    print("Will be printing a cell morphology summary")
	    print compSummary[config][str(maxElecLen)]
	    ######### it turns out that this does not save recompartmentalized cells - all saved cells have identical spatial discretization; 
	    ##### generateNeuroML2 receives the parent projFile but not the loaded project which is  modified by the CellTopologyHelper.recompartmentaliseCell()
	    
	    ##################### neuroConstruct block #############################################################################
	    
	    neuroConstructSeed=1234
	    verbose=True
	    pm.doGenerate(config, neuroConstructSeed)

            while pm.isGenerating():
                  if verbose: 
                     print("Waiting for the project to be generated with Simulation Configuration: "+config)
                     time.sleep(5)
                     
	    simConfig = project.simConfigInfo.getSimConfig(config)
	    
	    seed=1234
	    genDir = File(projFile.getParentFile(), "generatedNeuroML2")
            nmlfm.generateNeuroMLFiles(simConfig,
                                       NeuroMLConstants.NeuroMLVersion.getLatestVersion(),
                                       LemsConstants.LemsOption.LEMS_WITHOUT_EXECUTE_MODEL,
                                       OriginalCompartmentalisation(),
                                       seed,
                                       False,
                                       True,
                                       genDir,
                                       "GENESIS Physiological Units",
                                       False)
            
            ########################################################################################################################
            
            if not os.path.exists(cellpath):
               print("Creating a new directory %s"%cellpath)
               os.makedirs(cellpath)
            else:
               print("A directory %s already exists"%cellpath)
              
               
            src_files = os.listdir("../../neuroConstruct/generatedNeuroML2/")
            for file_name in src_files:
                full_file_name = os.path.join("../../neuroConstruct/generatedNeuroML2/", file_name)
                if (os.path.isfile(full_file_name)):
#.........这里部分代码省略.........
开发者ID:OpenSourceBrain,项目名称:Thalamocortical,代码行数:103,代码来源:RunNeuroConstruct.py

示例12: generateV_ICurve

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
	def generateV_ICurve(self,
                         projFile,
                         simulator,
                         simConfig,
                         stimAmpLow, stimAmpInc, stimAmpHigh,
                         stimDur,
                         simDuration,
                         maxNumSimultaneousSims = 4):

			# Load neuroConstruct project

			print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

			pm = ProjectManager()
			self.myProject = pm.loadProject(projFile)
			self.simulator = simulator

			simConfig = self.myProject.simConfigInfo.getSimConfig(simConfig)

			simConfig.setSimDuration(simDuration)

			pm.doGenerate(simConfig.getName(), self.neuroConstructSeed)

			while pm.isGenerating():
					print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfig)
					time.sleep(2)

			numGenerated = self.myProject.generatedCellPositions.getNumberInAllCellGroups()

			print "Number of cells generated: " + str(numGenerated)

			simReferences = {}


			if numGenerated > 0:

					print "Generating scripts for simulator: %s..."%simulator

					if simulator == 'NEURON':
						self.myProject.neuronFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.neuronSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.neuronSettings.setGraphicsMode(0) # 0 hides graphs during execution
                        
					if simulator == 'GENESIS':
						self.myProject.genesisFileManager.setQuitAfterRun(1) # Remove this line to leave the NEURON sim windows open after finishing
						self.myProject.genesisSettings.setCopySimFiles(1) # 1 copies hoc/mod files to PySim_0 etc. and will allow multiple sims to run at once
						self.myProject.genesisSettings.setGraphicsMode(0) # 0 hides graphs during execution


					stimAmp = stimAmpLow

					ADD_TO_BEFORE_INIT = self.myProject.neuronSettings.getNativeBlock(NativeCodeLocation.BEFORE_INITIAL)
					ADD_TO_RECORD_I = self.myProject.neuronSettings.getNativeBlock(NativeCodeLocation.AFTER_SIMULATION)
					ADD_TO_START_FINITIALIZE = self.myProject.neuronSettings.getNativeBlock(NativeCodeLocation.START_FINITIALIZE)

					while stimAmp <= stimAmpHigh:

							while (len(self.simsRunning)>=maxNumSimultaneousSims):
									print "Sims currently running: "+str(self.simsRunning)
									print "Waiting..."
									time.sleep(3) # wait a while...
									self.updateSimsRunning()


							simRef = "PySim_"+str(float(stimAmp))

							print "Going to run simulation: "+simRef

							########  Adjusting the amplitude of the Voltage clamp ###############

                                                        TEXT_BEFORE_CREATION = "objref clampobj" + "\n" + "objref record_current" + "\n" + "objref data_save" + "\n"

                                                        # TEXT_BEFORE_INIT = "GranuleCell_mod_tonic[0].Soma {\n" + "clampobj = new SEClamp(0.5)\n" + "clampobj.dur1 = 150.0" + "\n" + "clampobj.amp1 = -100.0" + "\n" + "clampobj.dur2 = " + str(stimDur) + "\n" + "clampobj.amp2 = " + str(stimAmp) + "\n" + "clampobj.dur3 = 150.0" + "\n" + "clampobj.amp3 = -100.0" + "\n" + "clampobj.rs = 0.00001\n " + "}\n" # This should do the trick

                                                        # TEXT_BEFORE_INIT = TEXT_BEFORE_INIT + ADD_TO_BEFORE_INIT

                                                        TEXT_START_FINITIALIZE = "GranuleCell_mod_tonic[0].Soma {\n" + "clampobj = new SEClamp(0.5)\n" + "clampobj.dur1 = 150.0" + "\n" + "clampobj.amp1 = -100.0" + "\n" + "clampobj.dur2 = " + str(stimDur) + "\n" + "clampobj.amp2 = " + str(stimAmp) + "\n" + "clampobj.dur3 = 150.0" + "\n" + "clampobj.amp3 = -40.0" + "\n" + "clampobj.rs = 0.00001\n" + "record_current = new Vector()" + "\n" + "record_current.record(&clampobj.i)" + "\n" + "}\n" #This should do the trick

                                                        TEXT_START_FINITIALIZE = TEXT_START_FINITIALIZE + ADD_TO_START_FINITIALIZE

                                                        TEXT_TO_RECORD_I = """data_save = new File() \n""" + """strdef filename \n""" + """sprint(filename, """" + self.myProject.getProjectMainDirectory().getAbsolutePath() + """/simulations/current%.3f.txt", clampobj.amp2) \n""" + """data_save.wopen(filename) \n""" + """record_current.printf(data_save) \n""" + """data_save.close() \n"""

                                                        TEXT_TO_RECORD_I = TEXT_TO_RECORD_I + ADD_TO_RECORD_I

                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.BEFORE_CELL_CREATION, TEXT_BEFORE_CREATION)
                                                        # self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.BEFORE_INITIAL, TEXT_BEFORE_INIT)
                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.START_FINITIALIZE, TEXT_START_FINITIALIZE)
                                                        self.myProject.neuronSettings.setNativeBlock(NativeCodeLocation.AFTER_SIMULATION, TEXT_TO_RECORD_I)

					
							print "Next stim: "+ str(stimAmp)

							self.myProject.simulationParameters.setReference(simRef)

							if simulator == "NEURON":
									self.myProject.neuronFileManager.generateTheNeuronFiles(simConfig,
																							None,
																							NeuronFileManager.RUN_HOC,
																							self.simulatorSeed)

#.........这里部分代码省略.........
开发者ID:pgleeson,项目名称:TestArea,代码行数:103,代码来源:GenerateV_ICurve.py

示例13: File

# 需要导入模块: from ucl.physiol.neuroconstruct.project import ProjectManager [as 别名]
# 或者: from ucl.physiol.neuroconstruct.project.ProjectManager import doGenerate [as 别名]
project_file = File(project_path)
project = pm.loadProject(project_file)


n_trials = 25
sim_refs = []

for gj_conn_type in ['2010', '2012']:
    sim_config_name = 'coupling_strength_' + gj_conn_type + 'gap'
    sim_config = project.simConfigInfo.getSimConfig(sim_config_name)
    project.neuronSettings.setNoConsole()
    for trial in range(n_trials):
        print('=====new trial: regenerating network=====')
        # generate
        nC_seed = Long(random.getrandbits(32))
        pm.doGenerate(sim_config_name, nC_seed)
        while pm.isGenerating():
            time.sleep(0.02)
        print('network generated')
        ##=== save network structure ===
        cell_positions_file = open(utils.cs_cell_positions_file(timestamp,
                                                                gj_conn_type,
                                                                trial),
                                   'wb')
        edge_list_file = open(utils.cs_edge_list_file(timestamp,
                                                      gj_conn_type,
                                                      trial),
                               'wb')
        cell_positions_writer = csv.writer(cell_positions_file)
        edge_list_writer = csv.writer(edge_list_file)
        # extract connectivity structure
开发者ID:RokasSt,项目名称:GJGolgi_ReducedMorph,代码行数:33,代码来源:coupling_strength.py


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