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)
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) # 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 = False) 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)
def createAndLoadNewProject(self, newProjectFilePath, workflow_class): hdf5File = ProjectManager.createBlankProjectFile(newProjectFilePath) readOnly = False self.projectManager = ProjectManager( workflow_class, headless=True, workflow_cmdline_args=self._workflow_cmdline_args ) self.projectManager._loadProject(hdf5File, newProjectFilePath, readOnly)
def __init__(self, workflow=[], parent=None, flags=QtCore.Qt.WindowFlags(0), sideSplitterSizePolicy=SideSplitterSizePolicy.Manual): QMainWindow.__init__(self, parent=parent, flags=flags) # Register for thunk events (easy UI calls from non-GUI threads) self.thunkEventHandler = ThunkEventHandler(self) self._sideSplitterSizePolicy = sideSplitterSizePolicy self.projectManager = ProjectManager() import inspect, os ilastikShellFilePath = os.path.dirname( inspect.getfile(inspect.currentframe())) uic.loadUi(ilastikShellFilePath + "/ui/ilastikShell.ui", self) self._applets = [] self.appletBarMapping = {} self.setAttribute(Qt.WA_AlwaysShowToolTips) if 'Ubuntu' in platform.platform(): # Native menus are prettier, but aren't working on Ubuntu at this time (Qt 4.7, Ubuntu 11) self.menuBar().setNativeMenuBar(False) (self._projectMenu, self._shellActions) = self._createProjectMenu() self._settingsMenu = self._createSettingsMenu() self.menuBar().addMenu(self._projectMenu) self.menuBar().addMenu(self._settingsMenu) self.updateShellProjectDisplay() self.progressDisplayManager = ProgressDisplayManager(self.statusBar) for applet in workflow: self.addApplet(applet) self.appletBar.expanded.connect(self.handleAppleBarItemExpanded) self.appletBar.clicked.connect(self.handleAppletBarClick) self.appletBar.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel) # By default, make the splitter control expose a reasonable width of the applet bar self.mainSplitter.setSizes([300, 1]) self.currentAppletIndex = 0 self.currentImageIndex = -1 self.populatingImageSelectionCombo = False self.imageSelectionCombo.currentIndexChanged.connect( self.changeCurrentInputImageIndex) self.enableWorkflow = False # Global mask applied to all applets self._controlCmds = [ ] # Track the control commands that have been issued by each applet so they can be popped. self._disableCounts = [ ] # Controls for each applet can be disabled by his peers.
def __init__(self): self._applets = [] self.projectManager = ProjectManager() self.currentImageIndex = -1