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


Python ProjectManager.createBlankProjectFile方法代码示例

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


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

示例1: openProjectFile

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
    def openProjectFile(self, projectFilePath, force_readonly=False):
        # Make sure all workflow sub-classes have been loaded,
        #  so we can detect the workflow type in the project.
        import ilastik.workflows
        try:
            # Open the project file
            hdf5File, workflow_class, readOnly = ProjectManager.openProjectFile(projectFilePath, force_readonly)

            # If there are any "creation-time" command-line args saved to the project file,
            #  load them so that the workflow can be instantiated with the same settings 
            #  that were used when the project was first created. 
            project_creation_args = []
            if "workflow_cmdline_args" in hdf5File.keys():
                if len(hdf5File["workflow_cmdline_args"]) > 0:
                    project_creation_args = map(str, hdf5File["workflow_cmdline_args"][...])

            if workflow_class is None:
                # If the project file has no known workflow, we assume pixel classification
                import ilastik.workflows
                workflow_class = ilastik.workflows.pixelClassification.PixelClassificationWorkflow
                import warnings
                warnings.warn( "Your project file ({}) does not specify a workflow type.  "
                               "Assuming Pixel Classification".format( projectFilePath ) )            
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( self,
                                                  workflow_class,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args,
                                                  project_creation_args=project_creation_args )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)

        except ProjectManager.FileMissingError:
            logger.error("Couldn't find project file: {}".format( projectFilePath ))
            raise            
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # For now, we assume that any imported projects are pixel classification workflow projects.
            import ilastik.workflows
            default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from. 
            self.projectManager = ProjectManager( self,
                                                  default_workflow,
                                                  importFromPath=oldProjectFilePath,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args,
                                                  project_creation_args=self._workflow_cmdline_args )

            self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath,readOnly = False)
开发者ID:FabianIsensee,项目名称:ilastik,代码行数:62,代码来源:headlessShell.py

示例2: createAndLoadNewProject

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
 def createAndLoadNewProject(self, newProjectFilePath, workflow_class):
     hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath)
     readOnly = False
     self.projectManager = ProjectManager(
         self, workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args
     )
     self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:9,代码来源:headlessShell.py

示例3: openProjectFile

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
    def openProjectFile(self, projectFilePath):
        # Make sure all workflow sub-classes have been loaded,
        #  so we can detect the workflow type in the project.
        import ilastik.workflows
        try:
            # Open the project file
            hdf5File, workflow_class, _ = ProjectManager.openProjectFile(projectFilePath)
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( workflow_class,
                                                  headless=True,
                                                  workflow_cmdline_args=self._workflow_cmdline_args )
            self.projectManager._loadProject(hdf5File, projectFilePath, readOnly = False)
            
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # For now, we assume that any imported projects are pixel classification workflow projects.
            import ilastik.workflows
            default_workflow = ilastik.workflows.pixelClassification.PixelClassificationWorkflow

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from. 
            self.projectManager = ProjectManager( default_workflow,
                                                  importFromPath=oldProjectFilePath,
                                                  headless=True )
            self.projectManager._importProject(oldProjectFilePath, hdf5File, projectFilePath,readOnly = False)
开发者ID:christophdecker,项目名称:ilastik,代码行数:37,代码来源:headlessShell.py

示例4: HeadlessShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
class HeadlessShell(object):
    """
    For now, this class is just a stand-in for the GUI shell (used when running from the command line).
    """

    def __init__(self):
        self._applets = []
        self.projectManager = ProjectManager()
        self.currentImageIndex = -1

    def addApplet(self, aplt):
        self._applets.append(aplt)
        self.projectManager.addApplet(aplt)

    def changeCurrentInputImageIndex(self, newImageIndex):
        if newImageIndex != self.currentImageIndex:
            # Alert each central widget and viewer control widget that the image selection changed
            for i in range(len(self._applets)):
                self._applets[i].gui.setImageIndex(newImageIndex)

            self.currentImageIndex = newImageIndex

    def openProjectPath(self, projectFilePath):
        try:
            hdf5File, readOnly = self.projectManager.openProjectFile(projectFilePath)
            self.projectManager.loadProject(hdf5File, projectFilePath, readOnly)
        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
            projectFilePath = name + "_imported" + ext

            logger.info("Importing project as '" + projectFilePath + "'")
            projectFile = self.projectManager.createBlankProjectFile(projectFilePath)
            self.projectManager.importProject(oldProjectFilePath, projectFile, projectFilePath)
开发者ID:kemaleren,项目名称:ilastik,代码行数:37,代码来源:headlessShell.py

示例5: create_new_tst_project

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
    def create_new_tst_project(cls):
        # Instantiate 'shell'
        shell = HeadlessShell(  )
        
        # Create a blank project file and load it.
        newProjectFilePath = cls.PROJECT_FILE
        newProjectFile = ProjectManager.createBlankProjectFile(newProjectFilePath, PixelClassificationWorkflow, [])
        newProjectFile.close()
        shell.openProjectFile(newProjectFilePath)
        workflow = shell.workflow
        
        # Add a file
        from ilastik.applets.dataSelection.opDataSelection import DatasetInfo
        info = DatasetInfo()
        info.filePath = cls.SAMPLE_DATA
        opDataSelection = workflow.dataSelectionApplet.topLevelOperator
        opDataSelection.DatasetGroup.resize(1)
        opDataSelection.DatasetGroup[0][0].setValue(info)
        
        
        # Set some features
        ScalesList = [0.3, 0.7, 1, 1.6, 3.5, 5.0, 10.0]    
        FeatureIds = [ 'GaussianSmoothing',
                       'LaplacianOfGaussian',
                       'StructureTensorEigenvalues',
                       'HessianOfGaussianEigenvalues',
                       'GaussianGradientMagnitude',
                       'DifferenceOfGaussians' ]

        opFeatures = workflow.featureSelectionApplet.topLevelOperator
        opFeatures.Scales.setValue( ScalesList )
        opFeatures.FeatureIds.setValue( FeatureIds )

        #                    sigma:   0.3    0.7    1.0    1.6    3.5    5.0   10.0
        selections = numpy.array( [[True, False, False, False, False, False, False],
                                   [True, False, False, False, False, False, False],
                                   [True, False, False, False, False, False, False],
                                   [False, False, False, False, False, False, False],
                                   [False, False, False, False, False, False, False],
                                   [False, False, False, False, False, False, False]] )
        opFeatures.SelectionMatrix.setValue(selections)
    
        # Add some labels directly to the operator
        opPixelClass = workflow.pcApplet.topLevelOperator

        opPixelClass.LabelNames.setValue(['Label 1', 'Label 2'])

        slicing1 = sl[0:1,0:10,0:10,0:1,0:1]
        labels1 = 1 * numpy.ones(slicing2shape(slicing1), dtype=numpy.uint8)
        opPixelClass.LabelInputs[0][slicing1] = labels1

        slicing2 = sl[0:1,0:10,10:20,0:1,0:1]
        labels2 = 2 * numpy.ones(slicing2shape(slicing2), dtype=numpy.uint8)
        opPixelClass.LabelInputs[0][slicing2] = labels2

        # Save and close
        shell.projectManager.saveProject()
        del shell
开发者ID:JensNRAD,项目名称:ilastik_public,代码行数:60,代码来源:testPixelClassificationHeadless.py

示例6: openProjectPath

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
    def openProjectPath(self, projectFilePath):
        try:
            # Open the project file
            hdf5File, readOnly = ProjectManager.openProjectFile(projectFilePath)
            
            # Create our project manager
            # This instantiates the workflow and applies all settings from the project.
            self.projectManager = ProjectManager( self._workflowClass, hdf5File, projectFilePath, readOnly, headless=True )

        except ProjectManager.ProjectVersionError:
            # Couldn't open project.  Try importing it.
            oldProjectFilePath = projectFilePath
            name, ext = os.path.splitext(oldProjectFilePath)
    
            # Create a brand new project file.
            projectFilePath = name + "_imported" + ext
            logger.info("Importing project as '" + projectFilePath + "'")
            hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)

            # Create the project manager.
            # Here, we provide an additional parameter: the path of the project we're importing from. 
            self.projectManager = ProjectManager( self._workflowClass, hdf5File, projectFilePath, readOnly=False, importFromPath=oldProjectFilePath, headless=True )
开发者ID:thorbenk,项目名称:ilastik,代码行数:24,代码来源:headlessShell.py

示例7: create_project_file

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
 def create_project_file(self, workflow_class, project_file_name):
     newProjectFile = ProjectManager.createBlankProjectFile(project_file_name, workflow_class, [])
     newProjectFile.close()
开发者ID:ilastik,项目名称:ilastik,代码行数:5,代码来源:testAllHeadless.py

示例8: IlastikShell

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]

#.........这里部分代码省略.........
            message = "Your current project is about to be closed, but it has unsaved changes which will be lost.\n"
            message += "Are you sure you want to proceed?"
            buttons = QMessageBox.Yes | QMessageBox.Cancel
            response = QMessageBox.warning(self, "Discard unsaved changes?", message, buttons, defaultButton=QMessageBox.Cancel)
            closeProject = (response == QMessageBox.Yes)
            

        if closeProject:
            self.closeCurrentProject()

        return closeProject

    def closeCurrentProject(self):
        for applet in self._applets:
            applet.gui.reset()
        self.projectManager.closeCurrentProject()
        self.enableWorkflow = False
        self.updateAppletControlStates()
        self.updateShellProjectDisplay()
    
    def onNewProjectActionTriggered(self):
        logger.debug("New Project action triggered")
        
        # Make sure the user is finished with the currently open project
        if not self.ensureNoCurrentProject():
            return
        
        newProjectFilePath = self.getProjectPathToCreate()

        if newProjectFilePath is not None:
            self.createAndLoadNewProject(newProjectFilePath)

    def createAndLoadNewProject(self, newProjectFilePath):
        newProjectFile = self.projectManager.createBlankProjectFile(newProjectFilePath)
        self.loadProject(newProjectFile, newProjectFilePath, False)
    
    def getProjectPathToCreate(self, defaultPath=None, caption="Create Ilastik Project"):
        """
        Ask the user where he would like to create a project file.
        """
        if defaultPath is None:
            defaultPath = os.path.expanduser("~/MyProject.ilp")
        
        fileSelected = False
        while not fileSelected:
            projectFilePath = QFileDialog.getSaveFileName(
               self, caption, defaultPath, "Ilastik project files (*.ilp)",
               options=QFileDialog.Options(QFileDialog.DontUseNativeDialog))
            
            # If the user cancelled, stop now
            if projectFilePath.isNull():
                return None
    
            projectFilePath = str(projectFilePath)
            fileSelected = True
            
            # Add extension if necessary
            fileExtension = os.path.splitext(projectFilePath)[1].lower()
            if fileExtension != '.ilp':
                projectFilePath += ".ilp"
                if os.path.exists(projectFilePath):
                    # Since we changed the file path, we need to re-check if we're overwriting an existing file.
                    message = "A file named '" + projectFilePath + "' already exists in this location.\n"
                    message += "Are you sure you want to overwrite it?"
                    buttons = QMessageBox.Yes | QMessageBox.Cancel
                    response = QMessageBox.warning(self, "Overwrite existing project?", message, buttons, defaultButton=QMessageBox.Cancel)
开发者ID:LimpingTwerp,项目名称:applet-workflows,代码行数:70,代码来源:ilastikShell.py

示例9: createBlankProjectFile

# 需要导入模块: from ilastik.shell.projectManager import ProjectManager [as 别名]
# 或者: from ilastik.shell.projectManager.ProjectManager import createBlankProjectFile [as 别名]
 def createBlankProjectFile(self, projectFilePath):
     hdf5File = ProjectManager.createBlankProjectFile(projectFilePath)
     readOnly = False
     self.projectManager = ProjectManager( self._workflowClass,  headless=True )
     self.projectManager._loadProject(hdf5File, projectFilePath, readOnly)
开发者ID:bheuer,项目名称:ilastik,代码行数:7,代码来源:headlessShell.py


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