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 "Number of cells generated: " + str(project.generatedCellPositions.getNumberInAllCellGroups()) print "Number of network connections generated: " + str(project.generatedNetworkConnections.getNumAllSynConns())
def runColumnSimulation(simConfig="TempSimConfig", simDuration=100, simDt=0.025, neuroConstructSeed=1234, simulatorSeed=1234, simulators=["NEURON"], simRefPrefix="Net_", suggestedRemoteRunTime=120, defaultSynapticDelay=0.05, mpiConf=MpiSettings.LOCAL_SERIAL, scaleCortex=0.1, scaleThalamus=0, gabaScaling=1, l4ssAmpaScaling=1, l5PyrGapScaling=1, inNrtTcrNmdaScaling=1, pyrSsNmdaScaling=1, deepBiasCurrent=-1, maxElecLenFRB=0.01, maxElecLenRS=0.01, maxElecLenIN=0.01, maxElecLenSS=0.01, somaNseg=-1, varTimestepNeuron=False, verbose=True, runInBackground=False): print "Running new column simulation..." ############################################ # Full column populations numFRB = 50 # full model: 50 numRS = 1000 # full model: 1000 numSupBask = 90 # full model: 90 numSupAxAx = 90 # full model: 90 numSupLTS = 90 # full model: 90 numL4SpinStell = 240 # full model: 240 numL5TuftIB = 800 # full model: 800 numL5TuftRS = 200 # full model: 200 numDeepBask = 100 # full model: 100 numDeepAxAx = 100 # full model: 100 numDeepLTS = 100 # full model: 100 numL6NonTuftRS = 500 # full model: 500 numTCR = 100 # full model: 100 numnRT = 100 # full model: 100 ####################################### ### Load neuroConstruct project import datetime start = datetime.datetime.now() print "Loading project %s from at %s " % (projFile.getCanonicalPath(), start.strftime("%Y-%m-%d %H:%M")) pm = ProjectManager() project = pm.loadProject(projFile) ### Set duration & timestep & simulation configuration project.simulationParameters.setDt(simDt) simConfig = project.simConfigInfo.getSimConfig(simConfig) simConfig.setSimDuration(simDuration) ### Set simulation reference index = 0 simRef = "%s%i" % (simRefPrefix, index) while File("%s/simulations/%s_N" % (project.getProjectMainDirectory().getCanonicalPath(), simRef)).exists(): simRef = "%s%i" % (simRefPrefix, index) index = index + 1 project.simulationParameters.setReference(simRef) ### Change num in each cell group numFRB = int(scaleCortex * numFRB) numRS = int(scaleCortex * numRS) numSupBask = int(scaleCortex * numSupBask) numSupAxAx = int(scaleCortex * numSupAxAx) numSupLTS = int(scaleCortex * numSupLTS) numL4SpinStell = int(scaleCortex * numL4SpinStell) numL5TuftIB = int(scaleCortex * numL5TuftIB) numL5TuftRS = int(scaleCortex * numL5TuftRS) numDeepBask = int(scaleCortex * numDeepBask) numDeepAxAx = int(scaleCortex * numDeepAxAx) numDeepLTS = int(scaleCortex * numDeepLTS) numL6NonTuftRS = int(scaleCortex * numL6NonTuftRS) numTCR = int(scaleThalamus * numTCR) numnRT = int(scaleThalamus * numnRT) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L23PyrFRB").setMaxNumberCells( numFRB) # Note only works if RandomCellPackingAdapter project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L23PyrRS").setMaxNumberCells(numRS) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_SupBask").setMaxNumberCells(numSupBask) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_SupAxAx").setMaxNumberCells(numSupAxAx) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_SupLTS").setMaxNumberCells(numSupLTS) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L4SpinStell").setMaxNumberCells(numL4SpinStell) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L5TuftIB").setMaxNumberCells(numL5TuftIB) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L5TuftRS").setMaxNumberCells(numL5TuftRS) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_DeepBask").setMaxNumberCells(numDeepBask) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_DeepAxAx").setMaxNumberCells(numDeepAxAx) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_DeepLTS").setMaxNumberCells(numDeepLTS) project.cellGroupsInfo.getCellPackingAdapter( "CG3D_L6NonTuftRS").setMaxNumberCells(numL6NonTuftRS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_TCR").setMaxNumberCells( numTCR) project.cellGroupsInfo.getCellPackingAdapter("CG3D_nRT").setMaxNumberCells( numnRT) ### Change weights in synapses/gap junctions for netConnName in simConfig.getNetConns(): if gabaScaling != 1: SimulationsInfo.addExtraSimProperty("gabaWeightScaling", str(gabaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList( netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).getSynapseType() if synName.count("GABAA") > 0: print "Changing synaptic weight for syn %s in net conn %s by factor %f" % ( synName, netConnName, gabaScaling) project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).setWeightsGenerator( NumberGenerator(gabaScaling)) if l4ssAmpaScaling != 1: SimulationsInfo.addExtraSimProperty("l4ssAmpaScaling", str(l4ssAmpaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList( netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).getSynapseType() if synName.count("Syn_AMPA_L4SS_L4SS") > 0: print "Changing synaptic weight for syn %s in net conn %s by factor %f" % ( synName, netConnName, l4ssAmpaScaling) project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).setWeightsGenerator( NumberGenerator(l4ssAmpaScaling)) if l5PyrGapScaling != 1: SimulationsInfo.addExtraSimProperty("l5PyrGapScaling", str(l5PyrGapScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList( netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).getSynapseType() tgtCG = project.morphNetworkConnectionsInfo.getTargetCellGroup( netConnName) if synName.count("Syn_Elect_DeepPyr_DeepPyr" ) > 0 and tgtCG.count("CG3D_L5") > 0: print "Changing synaptic weight for syn %s in net conn %s by factor %f" % ( synName, netConnName, l5PyrGapScaling) project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).setWeightsGenerator( NumberGenerator(l5PyrGapScaling)) if inNrtTcrNmdaScaling != 1: SimulationsInfo.addExtraSimProperty("inNrtTcrNmdaScaling", str(inNrtTcrNmdaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList( netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).getSynapseType() if synName.count("NMDA") > 0 and ( synName.endswith("_IN") > 0 or synName.endswith("_DeepIN") > 0 or synName.endswith("_SupIN") > 0 or synName.endswith("_SupFS") > 0 or synName.endswith("_DeepFS") > 0 or synName.endswith("_SupLTS") > 0 or synName.endswith("_DeepLTS") > 0 or synName.endswith("_nRT") > 0 or synName.endswith("_TCR") > 0): print "Changing synaptic weight for syn %s in net conn %s by factor %f" % ( synName, netConnName, inNrtTcrNmdaScaling) project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).setWeightsGenerator( NumberGenerator(inNrtTcrNmdaScaling)) if pyrSsNmdaScaling != 1: SimulationsInfo.addExtraSimProperty("pyrSsNmdaScaling", str(pyrSsNmdaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList( netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).getSynapseType() if synName.count("NMDA") > 0 and ( synName.endswith("_SupPyr") > 0 or synName.endswith("_DeepPyr") > 0 or synName.endswith("_L4SS") > 0 or synName.endswith("_L5Pyr") > 0 or synName.endswith("_L5RS") > 0 or synName.endswith("_L5IB") > 0 or synName.endswith("_L6NT") > 0 or synName.endswith("_Pyr") > 0): print "Changing synaptic weight for syn %s in net conn %s by factor %f" % ( synName, netConnName, pyrSsNmdaScaling) project.morphNetworkConnectionsInfo.getSynapseList( netConnName).get(index).setWeightsGenerator( NumberGenerator(pyrSsNmdaScaling)) ### Change bias currents for inputName in simConfig.getInputs(): stim = project.elecInputInfo.getStim(inputName) if deepBiasCurrent >= 0: if stim.getElectricalInput().TYPE == "IClamp" and ( stim.getCellGroup() == "CG3D_L5TuftIB" or stim.getCellGroup() == "CG3D_L5TuftRS" or stim.getCellGroup() == "CG3D_L6NonTuftRS"): print "Changing offset current in %s to %f" % ( stim.getCellGroup(), deepBiasCurrent) stim.setAmp(NumberGenerator(deepBiasCurrent)) project.elecInputInfo.updateStim(stim) ### Change spatial discretisation of some cells. This will impact accuracy & simulation speed if maxElecLenFRB > 0: frbCell = project.cellManager.getCell("L23PyrFRB_varInit") info = CellTopologyHelper.recompartmentaliseCell( frbCell, maxElecLenFRB, project) print "Recompartmentalised FRB cell: " + info if somaNseg > 0: frbCell.getSegmentWithId( 0).getSection().setNumberInternalDivisions(somaNseg) if maxElecLenRS > 0: rsCell = project.cellManager.getCell("L23PyrRS") info = CellTopologyHelper.recompartmentaliseCell( rsCell, maxElecLenRS, project) print "Recompartmentalised RS cell: " + info if somaNseg > 0: rsCell.getSegmentWithId(0).getSection().setNumberInternalDivisions( somaNseg) if maxElecLenIN > 0: inCells = [ "SupBasket", "SupAxAx", "SupLTSInter", "DeepBasket", "DeepAxAx", "DeepLTSInter" ] for inCellName in inCells: 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) nc.generateAndRunGenesis(project, pm, simConfig, simRefG, simulatorSeed, verbose=verbose, runInBackground=runInBackground) sleep(2) # wait a while before running MOOSE... if simulators.count("MOOSE") > 0: simRefM = simRef + "_M" project.simulationParameters.setReference(simRefM) nc.generateAndRunMoose(project, pm, simConfig, simRefM, simulatorSeed, verbose=verbose, runInBackground=runInBackground) sleep(2) # wait a while before running GENESIS... print "Finished running all sims, shutting down..." stop = datetime.datetime.now() print print "Started: %s, finished: %s" % (start.strftime("%Y-%m-%d %H:%M"), stop.strftime("%Y-%m-%d %H:%M")) print
project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepBask").setMaxNumberCells(numDeepBask) project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepAxAx").setMaxNumberCells(numDeepAxAx) project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepLTS").setMaxNumberCells(numDeepLTS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L6NonTuftRS").setMaxNumberCells(numL6NonTuftRS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_TCR").setMaxNumberCells(numTCR) project.cellGroupsInfo.getCellPackingAdapter("CG3D_nRT").setMaxNumberCells(numnRT) ### Change weights in synapses/gap junctions for netConnName in simConfig.getNetConns(): if gabaScaling != 1: SimulationsInfo.addExtraSimProperty("gabaWeightScaling", str(gabaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() if synName.count("GABAA")>0: print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, gabaScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(gabaScaling)) if l4ssAmpaScaling !=1: SimulationsInfo.addExtraSimProperty("l4ssAmpaScaling", str(l4ssAmpaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)):
def runColumnSimulation(simConfig= "TempSimConfig", simDuration = 100, simDt = 0.025, neuroConstructSeed = 1234, simulatorSeed = 1234, simulators = ["NEURON"], simRefPrefix = "Net_", suggestedRemoteRunTime = 120, defaultSynapticDelay = 0.05, mpiConf = MpiSettings.LOCAL_SERIAL, scaleCortex = 0.1, scaleThalamus = 0, gabaScaling = 1, l4ssAmpaScaling = 1, l5PyrGapScaling = 1, inNrtTcrNmdaScaling = 1, pyrSsNmdaScaling = 1, deepBiasCurrent = -1, maxElecLenFRB = 0.01, maxElecLenRS = 0.01, maxElecLenIN = 0.01, maxElecLenSS = 0.01, somaNseg = -1, varTimestepNeuron = False, verbose = True, runInBackground = False): print "Running new column simulation..." ############################################ # Full column populations numFRB = 50 # full model: 50 numRS = 1000 # full model: 1000 numSupBask = 90 # full model: 90 numSupAxAx = 90 # full model: 90 numSupLTS = 90 # full model: 90 numL4SpinStell = 240 # full model: 240 numL5TuftIB = 800 # full model: 800 numL5TuftRS = 200 # full model: 200 numDeepBask = 100 # full model: 100 numDeepAxAx = 100 # full model: 100 numDeepLTS = 100 # full model: 100 numL6NonTuftRS = 500 # full model: 500 numTCR = 100 # full model: 100 numnRT = 100 # full model: 100 ####################################### ### Load neuroConstruct project import datetime start = datetime.datetime.now() print "Loading project %s from at %s " % (projFile.getCanonicalPath(),start.strftime("%Y-%m-%d %H:%M")) pm = ProjectManager() project = pm.loadProject(projFile) ### Set duration & timestep & simulation configuration project.simulationParameters.setDt(simDt) simConfig = project.simConfigInfo.getSimConfig(simConfig) simConfig.setSimDuration(simDuration) ### Set simulation reference index = 0 simRef = "%s%i"%(simRefPrefix,index) while File( "%s/simulations/%s_N"%(project.getProjectMainDirectory().getCanonicalPath(), simRef)).exists(): simRef = "%s%i"%(simRefPrefix,index) index = index+1 project.simulationParameters.setReference(simRef) ### Change num in each cell group numFRB = int(scaleCortex * numFRB) numRS = int(scaleCortex * numRS) numSupBask = int(scaleCortex * numSupBask) numSupAxAx = int(scaleCortex * numSupAxAx) numSupLTS = int(scaleCortex * numSupLTS) numL4SpinStell = int(scaleCortex * numL4SpinStell) numL5TuftIB = int(scaleCortex * numL5TuftIB) numL5TuftRS = int(scaleCortex * numL5TuftRS) numDeepBask = int(scaleCortex * numDeepBask) numDeepAxAx = int(scaleCortex * numDeepAxAx) numDeepLTS = int(scaleCortex * numDeepLTS) numL6NonTuftRS = int(scaleCortex * numL6NonTuftRS) numTCR = int(scaleThalamus * numTCR) numnRT = int(scaleThalamus * numnRT) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L23PyrFRB").setMaxNumberCells(numFRB) # Note only works if RandomCellPackingAdapter project.cellGroupsInfo.getCellPackingAdapter("CG3D_L23PyrRS").setMaxNumberCells(numRS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_SupBask").setMaxNumberCells(numSupBask) project.cellGroupsInfo.getCellPackingAdapter("CG3D_SupAxAx").setMaxNumberCells(numSupAxAx) project.cellGroupsInfo.getCellPackingAdapter("CG3D_SupLTS").setMaxNumberCells(numSupLTS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L4SpinStell").setMaxNumberCells(numL4SpinStell) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L5TuftIB").setMaxNumberCells(numL5TuftIB) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L5TuftRS").setMaxNumberCells(numL5TuftRS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepBask").setMaxNumberCells(numDeepBask) project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepAxAx").setMaxNumberCells(numDeepAxAx) project.cellGroupsInfo.getCellPackingAdapter("CG3D_DeepLTS").setMaxNumberCells(numDeepLTS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_L6NonTuftRS").setMaxNumberCells(numL6NonTuftRS) project.cellGroupsInfo.getCellPackingAdapter("CG3D_TCR").setMaxNumberCells(numTCR) project.cellGroupsInfo.getCellPackingAdapter("CG3D_nRT").setMaxNumberCells(numnRT) ### Change weights in synapses/gap junctions for netConnName in simConfig.getNetConns(): if gabaScaling != 1: SimulationsInfo.addExtraSimProperty("gabaWeightScaling", str(gabaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() if synName.count("GABAA")>0: print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, gabaScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(gabaScaling)) if l4ssAmpaScaling !=1: SimulationsInfo.addExtraSimProperty("l4ssAmpaScaling", str(l4ssAmpaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() if synName.count("Syn_AMPA_L4SS_L4SS")>0: print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, l4ssAmpaScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(l4ssAmpaScaling)) if l5PyrGapScaling !=1: SimulationsInfo.addExtraSimProperty("l5PyrGapScaling", str(l5PyrGapScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() tgtCG = project.morphNetworkConnectionsInfo.getTargetCellGroup(netConnName) if synName.count("Syn_Elect_DeepPyr_DeepPyr")>0 and tgtCG.count("CG3D_L5")>0: print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, l5PyrGapScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(l5PyrGapScaling)) if inNrtTcrNmdaScaling !=1: SimulationsInfo.addExtraSimProperty("inNrtTcrNmdaScaling", str(inNrtTcrNmdaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() if synName.count("NMDA")>0 and (synName.endswith("_IN")>0 or synName.endswith("_DeepIN")>0 or synName.endswith("_SupIN")>0 or synName.endswith("_SupFS")>0 or synName.endswith("_DeepFS")>0 or synName.endswith("_SupLTS")>0 or synName.endswith("_DeepLTS")>0 or synName.endswith("_nRT")>0 or synName.endswith("_TCR")>0): print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, inNrtTcrNmdaScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(inNrtTcrNmdaScaling)) if pyrSsNmdaScaling !=1: SimulationsInfo.addExtraSimProperty("pyrSsNmdaScaling", str(pyrSsNmdaScaling)) synList = project.morphNetworkConnectionsInfo.getSynapseList(netConnName) for index in range(0, len(synList)): synName = project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).getSynapseType() if synName.count("NMDA")>0 and (synName.endswith("_SupPyr")>0 or synName.endswith("_DeepPyr")>0 or synName.endswith("_L4SS")>0 or synName.endswith("_L5Pyr")>0 or synName.endswith("_L5RS")>0 or synName.endswith("_L5IB")>0 or synName.endswith("_L6NT")>0 or synName.endswith("_Pyr")>0): print "Changing synaptic weight for syn %s in net conn %s by factor %f"%(synName, netConnName, pyrSsNmdaScaling) project.morphNetworkConnectionsInfo.getSynapseList(netConnName).get(index).setWeightsGenerator(NumberGenerator(pyrSsNmdaScaling)) ### Change bias currents for inputName in simConfig.getInputs(): stim = project.elecInputInfo.getStim(inputName) if deepBiasCurrent >= 0: if stim.getElectricalInput().TYPE == "IClamp" and (stim.getCellGroup()=="CG3D_L5TuftIB" or stim.getCellGroup()=="CG3D_L5TuftRS" or stim.getCellGroup()=="CG3D_L6NonTuftRS"): print "Changing offset current in %s to %f"%(stim.getCellGroup(), deepBiasCurrent) stim.setAmp(NumberGenerator(deepBiasCurrent)) project.elecInputInfo.updateStim(stim) ### Change spatial discretisation of some cells. This will impact accuracy & simulation speed if maxElecLenFRB > 0: frbCell = project.cellManager.getCell("L23PyrFRB_varInit") info = CellTopologyHelper.recompartmentaliseCell(frbCell, maxElecLenFRB, project) print "Recompartmentalised FRB cell: "+info if somaNseg > 0: frbCell.getSegmentWithId(0).getSection().setNumberInternalDivisions(somaNseg) if maxElecLenRS > 0: rsCell = project.cellManager.getCell("L23PyrRS") info = CellTopologyHelper.recompartmentaliseCell(rsCell, maxElecLenRS, project) print "Recompartmentalised RS cell: "+info if somaNseg > 0: rsCell.getSegmentWithId(0).getSection().setNumberInternalDivisions(somaNseg) if maxElecLenIN > 0: inCells = ["SupBasket", "SupAxAx","SupLTSInter","DeepBasket", "DeepAxAx","DeepLTSInter"] for inCellName in inCells: 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) nc.generateAndRunGenesis(project, pm, simConfig, simRefG, simulatorSeed, verbose=verbose, runInBackground=runInBackground) sleep(2) # wait a while before running MOOSE... if simulators.count("MOOSE")>0: simRefM = simRef+"_M" project.simulationParameters.setReference(simRefM) nc.generateAndRunMoose(project, pm, simConfig, simRefM, simulatorSeed, verbose=verbose, runInBackground=runInBackground) sleep(2) # wait a while before running GENESIS... print "Finished running all sims, shutting down..." stop = datetime.datetime.now() print print "Started: %s, finished: %s" % (start.strftime("%Y-%m-%d %H:%M"),stop.strftime("%Y-%m-%d %H:%M")) print
def testAll(argv=None): if argv is None: argv = sys.argv print "Loading project from "+ projFile.getCanonicalPath() simManager = nc.SimulationManager(projFile, numConcurrentSims = numConcurrentSims, verbose = verbose) ### Change num in each cell group densityGrC = 1.90e6 densityMF = 6.6e5 densityGoC = 4607 totDens = densityGrC + densityMF + densityGoC numMF = int(targetNum * densityMF/totDens) numGoC = int(targetNum * densityGoC/totDens) numGrC = targetNum - numMF - numGoC vol = targetNum/(totDens*1e-9) height = 150 side = math.sqrt(vol/height) info = "Number in %fx%fx%i box (vol: %f mm^3): GrC: %i, MF: %i, GoC: %i, Total: %i"%(side, side, height, vol*1e-9,numGrC, numMF,numGoC, (numGrC +numMF +numGoC)) print info SimulationsInfo.addExtraSimProperty("summary", info) region3D = simManager.project.regionsInfo.getRegionObject("TestGranCellVolume") region3D.setParameter(region3D.WIDTH_PARAM, side) region3D.setParameter(region3D.HEIGHT_PARAM, height) region3D.setParameter(region3D.DEPTH_PARAM, side) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGrC").setMaxNumberCells(numGrC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGoC").setMaxNumberCells(numGoC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingMF").setMaxNumberCells(numMF) ######simManager.project.cellGroupsInfo.getCellPackingAdapter("lg2").setMaxNumberCells(numCells2) allSims = simManager.runMultipleSims(simConfigs = simConfigs, simDt = simDt, simDuration = simDuration, simulators = simulators, runInBackground = runInBackground, varTimestepNeuron = varTimestepNeuron, mpiConfigs = mpiConfigs, suggestedRemoteRunTime = suggestedRemoteRunTime, simRefGlobalPrefix = simAllPrefix, runSims = runSims, maxElecLens = multipleRuns, saveAsHdf5 = saveAsHdf5, saveOnlySpikes = saveOnlySpikes, runMode = runMode) while (len(simManager.allRunningSims)>0): print "Waiting for the following sims to finish: "+str(simManager.allRunningSims) time.sleep(5) # wait a while... simManager.updateSimsRunning() times = [] procNums = [] for sim in allSims: simDir = File(projFile.getParentFile(), "/simulations/"+sim) try: simData = SimulationData(simDir) simData.initialise() simTime = simData.getSimulationProperties().getProperty("RealSimulationTime") print "Simulation: %s took %s seconds"%(sim, simTime) times.append(float(simTime)) paraConfig = simData.getSimulationProperties().getProperty("Parallel configuration") print paraConfig numProc = int(paraConfig[max(paraConfig.find(" host, ")+7, paraConfig.find(" hosts, ")+8):paraConfig.find(" processor")]) procNums.append(numProc) except: print "Error analysing simulation data from: %s"%simDir.getCanonicalPath() print sys.exc_info() print times print procNums ''' import matplotlib.pyplot as plt lines = plt.loglog(times, procNums, 'r:') plt.ylabel('Simulation time') plt.xlabel('Number of processors') plt.show()''' from ucl.physiol.neuroconstruct.gui.plotter import PlotManager from ucl.physiol.neuroconstruct.gui.plotter import PlotCanvas from ucl.physiol.neuroconstruct.dataset import DataSet plotFrame = PlotManager.getPlotterFrame("Time for simulation run on different numbers of processors", 0, 1) plotFrame.setViewMode(PlotCanvas.INCLUDE_ORIGIN_VIEW) info = "Simulation times for: "+str(procNums) dataSet = DataSet(info, info, "#", "s", "Number of processors", "Simulation time") dataSet.setGraphFormat(PlotCanvas.USE_CIRCLES_FOR_PLOT) for i in range(len(times)): dataSet.addPoint(procNums[i],times[i]*procNums[i]) #dataSet.addPoint(procNums[i],times[i]) plotFrame.addDataSet(dataSet)
def testAll(argv=None): if argv is None: argv = sys.argv print "Loading project from "+ projFile.getCanonicalPath() simManager = nc.SimulationManager(projFile, numConcurrentSims = numConcurrentSims, verbose = verbose) ### Change num in each cell group densityGrC = 1.90e6 densityMF = 6.6e5 densityGoC = 4607 totDens = densityGrC + densityMF + densityGoC numMF = int(targetNum * densityMF/totDens) numGoC = int(targetNum * densityGoC/totDens) numGrC = targetNum - numMF - numGoC vol = targetNum/(totDens*1e-9) height = 150 side = math.sqrt(vol/height) info = "Number in %fx%fx%i box (vol: %f mm^3): GrC: %i, MF: %i, GoC: %i, Total: %i"%(side, side, height, vol*1e-9,numGrC, numMF,numGoC, (numGrC +numMF +numGoC)) print info SimulationsInfo.addExtraSimProperty("summary", info) region3D = simManager.project.regionsInfo.getRegionObject("TestGranCellVolume") region3D.setParameter(region3D.WIDTH_PARAM, side) region3D.setParameter(region3D.HEIGHT_PARAM, height) region3D.setParameter(region3D.DEPTH_PARAM, side) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGrC").setMaxNumberCells(numGrC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGoC").setMaxNumberCells(numGoC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingMF").setMaxNumberCells(numMF) ######simManager.project.cellGroupsInfo.getCellPackingAdapter("lg2").setMaxNumberCells(numCells2) pm = simManager.projectManager project = simManager.project pm.doGenerate(simConfigs[0], neuroConstructSeed) while pm.isGenerating(): print "Waiting for the project to be generated with Simulation Configuration: "+str(simConfigs[0]) 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()) fileX = File( "%s/savedNetworks/Net_%s.nml"%(project.getProjectMainDirectory().getCanonicalPath(), targetNum)) print "Saving XML net to %s"%fileX.getCanonicalPath() pm.saveNetworkStructureXML(project, fileX, 0, 0, simConfigs[0], "Physiological Units") fileH = File( "%s/savedNetworks/Net_%s.h5"%(project.getProjectMainDirectory().getCanonicalPath(), targetNum)) print "Saving HDF5 net to %s"%fileH.getCanonicalPath() pm.saveNetworkStructureHDF5(project, fileH, simConfigs[0], "Physiological Units") print "Finished running all sims, shutting down..."
def testAll(argv=None): if argv is None: argv = sys.argv print "Loading project from "+ projFile.getCanonicalPath() simManager = nc.SimulationManager(projFile, numConcurrentSims = numConcurrentSims, verbose = verbose) ### Change num in each cell group densityGrC = 1.90e6 densityMF = 6.6e5 densityGoC = 4607 totDens = densityGrC + densityMF + densityGoC for conf in confs.keys(): numb = conf mpiConfigs = [confs[conf]] perProc = 5000 targetNum = perProc*numb simAllPrefix = "NZ_%i_%i_"%(perProc, numb) # Adds a prefix to simulation reference print "Simulation pref: "+simAllPrefix numMF = int(targetNum * densityMF/totDens) numGoC = int(targetNum * densityGoC/totDens) numGrC = targetNum - numMF - numGoC vol = targetNum/(totDens*1e-9) height = 150 side = math.sqrt(vol/height) info = "Number in %fx%fx%i box (vol: %f mm^3): GrC: %i, MF: %i, GoC: %i, Total: %i"%(side, side, height, vol*1e-9,numGrC, numMF,numGoC, (numGrC +numMF +numGoC)) print info SimulationsInfo.addExtraSimProperty("summary", info) region3D = simManager.project.regionsInfo.getRegionObject("TestGranCellVolume") region3D.setParameter(region3D.WIDTH_PARAM, side) region3D.setParameter(region3D.HEIGHT_PARAM, height) region3D.setParameter(region3D.DEPTH_PARAM, side) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGrC").setMaxNumberCells(numGrC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingGoC").setMaxNumberCells(numGoC) simManager.project.cellGroupsInfo.getCellPackingAdapter("TestScalingMF").setMaxNumberCells(numMF) ######simManager.project.cellGroupsInfo.getCellPackingAdapter("lg2").setMaxNumberCells(numCells2) allSims = simManager.runMultipleSims(simConfigs = simConfigs, simDt = simDt, simDuration = simDuration, simulators = simulators, runInBackground = runInBackground, varTimestepNeuron = varTimestepNeuron, mpiConfigs = mpiConfigs, suggestedRemoteRunTime = suggestedRemoteRunTime, simRefGlobalPrefix = simAllPrefix, runSims = runSims, maxElecLens = multipleRuns, saveAsHdf5 = saveAsHdf5, saveOnlySpikes = saveOnlySpikes, runMode = runMode) if wait: while (len(simManager.allRunningSims)>0): print "Waiting for the following sims to finish: "+str(simManager.allRunningSims) time.sleep(30) # wait a while... simManager.updateSimsRunning() times = [] procNums = [] for sim in allSims: simDir = File(projFile.getParentFile(), "/simulations/"+sim) try: simData = SimulationData(simDir) simData.initialise() simTime = simData.getSimulationProperties().getProperty("RealSimulationTime") print "Simulation: %s took %s seconds"%(sim, simTime) times.append(float(simTime)) paraConfig = simData.getSimulationProperties().getProperty("Parallel configuration") print paraConfig numProc = int(paraConfig[max(paraConfig.find(" host, ")+7, paraConfig.find(" hosts, ")+8):paraConfig.find(" processor")]) procNums.append(numProc) except: print "Error analysing simulation data from: %s"%simDir.getCanonicalPath() print sys.exc_info()
numFRB = 3 numRS = 3 numLTS = 0 numBask = 0 numAxAx = 0 numFRB = 6 numRS = 20 numLTS = 10 numBask = 10 numAxAx = 10 ''' numPyr = 1152 fractFRB = 0.05 SimulationsInfo.addExtraSimProperty("fractFRB", str(fractFRB)) numFRB = int(fractFRB*numPyr) numRS = numPyr - numFRB numLTS = 96 numBask = 96 numAxAx = 96 # Maximum electronic length of compartments (adjusts nseg etc.) maxElecLenFRB = -1 # 0.01 will give ~700, -1 will leave as is maxElecLenRS = -1 # 0.01 will give ~700, -1 will leave as is maxElecLenLTS = -1 # 0.01 will give ~570, -1 will leave as is maxElecLenAxAx = -1 # 0.01 will give ~570, -1 will leave as is maxElecLenBask = -1 # 0.01 will give ~570, -1 will leave as is somaNseg = -1 # 12
def testAll(argv=None): if argv is None: argv = sys.argv print "Loading project from "+ projFile.getCanonicalPath() simManager = nc.SimulationManager(projFile, numConcurrentSims = numConcurrentSims, verbose = verbose) ### Change num in each cell group simManager.project.cellGroupsInfo.getCellPackingAdapter("ExcCells").setMaxNumberCells(numExcCells) simManager.project.cellGroupsInfo.getCellPackingAdapter("INCells").setMaxNumberCells(numINCells) ### Change weights in synapses/gap junctions simConfig = simManager.project.simConfigInfo.getSimConfig(simConfigName) for netConnName in simConfig.getNetConns(): print "Changing synaptic delay in %s to %f"%(netConnName, defaultSynapticDelay) delayGen = NumberGenerator(defaultSynapticDelay) for synProps in simManager.project.morphNetworkConnectionsInfo.getSynapseList(netConnName): synProps.setDelayGenerator(delayGen) # defaultSynapticDelay will be recorded in simulation.props and listed in SimulationBrowser GUI SimulationsInfo.addExtraSimProperty("defaultSynapticDelay", str(defaultSynapticDelay)) allSims = simManager.runMultipleSims(simConfigs = [simConfigName], simDt = simDt, simDuration = simDuration, simulators = simulators, runInBackground = runInBackground, varTimestepNeuron = varTimestepNeuron, mpiConfigs = mpiConfigs, suggestedRemoteRunTime = suggestedRemoteRunTime, simRefGlobalPrefix = simAllPrefix, runSims = runSims, neuroConstructSeed = neuroConstructSeed, simulatorSeed = simulatorSeed) while (len(simManager.allRunningSims)>0): print "Waiting for the following sims to finish: "+str(simManager.allRunningSims) time.sleep(5) # wait a while... simManager.updateSimsRunning() for sim in allSims: simDir = File(projFile.getParentFile(), "/simulations/"+sim) try: simData = SimulationData(simDir) simData.initialise() simTime = simData.getSimulationProperties().getProperty("RealSimulationTime") print "Simulation: %s took %s seconds"%(sim, simTime) except: print "Error analysing simulation data from: %s"%simDir.getCanonicalPath() if mpiConfigs == [MpiSettings.LOCAL_SERIAL] or mpiConfigs == [MpiSettings.MATLEM_1PROC]: simManager.reloadSims(plotVoltageOnly = True, plotSims = plotSims, analyseSims = analyseSims)