示例#1
0
 def create_nc_project(self):
     """Creates a neuroConstruct project from the NeuroML2 file(s)."""
     from java.io import File
     from ucl.physiol.neuroconstruct.project import Project
     from ucl.physiol.neuroconstruct.cell.converters import MorphMLConverter
     project = Project.createNewProject('/Users/rgerkin/', self.model_name,
                                        None)
     morphDir = File(
         "%s/osb/showcase/neuroConstructShowcase/Ex3_Morphology/importedMorphologies/"
         % NC_HOME)
     morphmlFile = File(morphDir, "SimplePurkinjeCell.morph.xml")
     converter = MorphMLConverter()
     cell = converter.loadFromMorphologyFile(morphmlFile, "NewCell")
     project.cellManager.addCellType(cell)  # Actually add it to the project
     project.cellGroupsInfo.setCellType(
         "DefaultCellGroup", cell.getInstanceName(
         ))  # Set the type of an existing cell group to this
     project.saveProject()
示例#2
0
projFile = File("TestPython/TestPython.neuro.xml")
print "Loading project from file: " + projFile.getAbsolutePath(
) + ", exists: " + str(projFile.exists())

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

morphDir = File(
    "../osb/showcase/neuroConstructShowcase/Ex3_Morphology/importedMorphologies/"
)
morphmlFile = File(morphDir, "SimplePurkinjeCell.morph.xml")

print "Going to load morphology from: " + morphmlFile.getCanonicalPath()

converter = MorphMLConverter()
cell = converter.loadFromMorphologyFile(morphmlFile, "NewCell")

print "Loaded cell: " + cell.getInstanceName() + " with " + str(
    cell.getAllSegments().size()) + " segments"

myProject.cellManager.addCellType(cell)  # Actually add it to the project
myProject.cellGroupsInfo.setCellType(
    "SampleCellGroup",
    cell.getInstanceName())  # Set the type of an existing cell group to this

# Now the project can be generated as in Ex5_MultiSimGenerate.py

#      * OR *

# Save project
projFile = File("TestPython/TestPython.neuro.xml")
print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

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


morphDir = File("../nCexamples/Ex3_Morphology/importedMorphologies/")
morphmlFile = File(morphDir, "SimplePurkinjeCell.morph.xml")


print "Going to load morphology from: " + morphmlFile.getCanonicalPath()

converter = MorphMLConverter()
cell = converter.loadFromMorphologyFile(morphmlFile, "NewCell") 

print "Loaded cell: " + cell.getInstanceName() + " with " + str(cell.getAllSegments().size()) +" segments" 

myProject.cellManager.addCellType(cell) # Actually add it to the project
myProject.cellGroupsInfo.setCellType("SampleCellGroup", cell.getInstanceName()) # Set the type of an existing cell group to this



# Now the project can be generated as in Ex5_MultiSimGenerate.py

#      * OR *


# Save project
projFile = File(sys.argv[1])
print "Loading project from file: " + projFile.getAbsolutePath()+", exists: "+ str(projFile.exists())

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

saveDir = File(sys.argv[2])
print "Going to save NeuroML files to: " + saveDir.getAbsolutePath()

level = NeuroMLLevel.NEUROML_LEVEL_3
version = NeuroMLVersion.NEUROML_VERSION_1

MorphMLConverter.saveAllCellsInNeuroML(myProject,
                                       OriginalCompartmentalisation(),
                                       level,
                                       version,
                                       None,
                                       saveDir)

# Note: look also in Java class ucl.physiol.neuroconstruct.neuroml.NeuroMLPythonFileManager
# for the method generateNeuroMLFiles() which can be used to export all cells, channels and
# generated network structure to individual NeuroML files or as one large Level 3 file.

print "Done!"




    print "Usage: \n    ../nC.sh -python Ex7_ExtractNeuroML.py neuroConstruct_project_file folder_for_NeuroML"
    print "Example: \n    ../nC.sh -python Ex7_ExtractNeuroML.py TestPython/TestPython.neuro.xml /tmp"
    print "or: \n    ..\\nC.bat -python Ex7_ExtractNeuroML.py TestPython\\TestPython.neuro.xml c:\\temp"
    sys.exit(1)

# Load neuroConstruct project

projFile = File(sys.argv[1])
print "Loading project from file: " + projFile.getAbsolutePath(
) + ", exists: " + str(projFile.exists())

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

saveDir = File(sys.argv[2])
print "Going to save NeuroML files to: " + saveDir.getAbsolutePath()

level = NeuroMLLevel.NEUROML_LEVEL_3
version = NeuroMLVersion.NEUROML_VERSION_1

MorphMLConverter.saveAllCellsInNeuroML(myProject,
                                       OriginalCompartmentalisation(), level,
                                       version, None, saveDir)

# Note: look also in Java class ucl.physiol.neuroconstruct.neuroml.NeuroMLPythonFileManager
# for the method generateNeuroMLFiles() which can be used to export all cells, channels and
# generated network structure to individual NeuroML files or as one large Level 3 file.

print "Done!"