def onUsePrecomputedFeaturesButtonClicked(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog filename = QFileDialog.getOpenFileName(self, 'Open Feature List', '.', options=options) #sanity checks on the given file if not filename: return if not os.path.exists(filename): QMessageBox.critical(self, "Open Feature List", "File '%s' does not exist" % filename) return f = open(filename, 'r') with f: for line in f: line = line.strip() if len(line) == 0: continue if not os.path.exists(line): QMessageBox.critical(self, "Open Feature List", "File '%s', referenced in '%s', does not exist" % (line, filename)) return try: h = h5py.File(line, 'r') with h: assert len(h["data"].shape) == 3 except: QMessageBox.critical(self, "Open Feature List", "File '%s', referenced in '%s', could not be opened as an HDF5 file or does not contain a 3D dataset called 'data'" % (line, filename)) return self.topLevelOperatorView.FeatureListFilename.setValue(filename) self.topLevelOperatorView._setupOutputs() self.onFeaturesSelectionsChanged()
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir + "/drawer.ui") self._drawer.selectFeaturesButton.pressed.connect( self._selectFeaturesButtonPressed) if not ilastik_config.getboolean("ilastik", "debug"): self._drawer.exportButton.setVisible(False) self._drawer.exportButton.pressed.connect( self._exportFeaturesButtonPressed) slot = self.topLevelOperatorView.Features if slot.ready(): selectedFeatures = self.topLevelOperatorView.Features([]).wait() else: selectedFeatures = None nfeatures = 0 if selectedFeatures is not None: for plugin_features in selectedFeatures.values(): nfeatures += len(plugin_features) self._drawer.featuresSelected.setText( "{} features computed, \nsome may have multiple channels".format( nfeatures)) # get the applet reference from the workflow (needed for the progressSignal) self.applet = self.topLevelOperatorView.parent.parent.objectExtractionApplet
def getImageFileNamesToOpen(self, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ file_dialog = QFileDialog(self, "Select Images") extensions = OpDataSelection.SupportedExtensions filter_strs = ["*." + x for x in extensions] filters = ["{filt} ({filt})".format(filt=x) for x in filter_strs] filt_all_str = "Image files (" + ' '.join(filter_strs) + ')' file_dialog.setFilters([filt_all_str] + filters) # do not display file types associated with a filter # the line for "Image files" is too long otherwise file_dialog.setNameFilterDetailsVisible(False) # select multiple files file_dialog.setFileMode(QFileDialog.ExistingFiles) if ilastik_config.getboolean("ilastik", "debug"): file_dialog.setOption(QFileDialog.DontUseNativeDialog, True) if file_dialog.exec_(): fileNames = file_dialog.selectedFiles() # Convert from QtString to python str fileNames = map(encode_from_qstring, fileNames) return fileNames return []
def initAppletDrawerUi(self): # Load the ui file (find it in our own directory) localDir = os.path.split(__file__)[0] self._drawer = uic.loadUi(localDir+"/drawer.ui") self._drawer.selectFeaturesButton.pressed.connect(self._selectFeaturesButtonPressed) if not ilastik_config.getboolean("ilastik", "debug"): self._drawer.exportButton.setVisible(False) self._drawer.exportButton.pressed.connect(self._exportFeaturesButtonPressed) slot = self.topLevelOperatorView.Features if slot.ready(): selectedFeatures = self.topLevelOperatorView.Features([]).wait() else: selectedFeatures = None nfeatures = 0 if selectedFeatures is not None: for plugin_features in selectedFeatures.itervalues(): nfeatures += len(plugin_features) self._drawer.featuresSelected.setText("{} features computed, \nsome may have multiple channels".format(nfeatures)) # get the applet reference from the workflow (needed for the progressSignal) self.applet = self.topLevelOperatorView.parent.parent.objectExtractionApplet
def getImageFileNamesToOpen(cls, parent_window, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ extensions = OpDataSelection.SupportedExtensions filter_strs = ["*." + x for x in extensions] filters = ["{filt} ({filt})".format(filt=x) for x in filter_strs] filt_all_str = "Image files (" + " ".join(filter_strs) + ")" fileNames = [] if ilastik_config.getboolean("ilastik", "debug"): # use Qt dialog in debug mode (more portable?) file_dialog = QFileDialog(parent_window, "Select Images") file_dialog.setOption(QFileDialog.DontUseNativeDialog, True) # do not display file types associated with a filter # the line for "Image files" is too long otherwise file_dialog.setFilters([filt_all_str] + filters) file_dialog.setNameFilterDetailsVisible(False) # select multiple files file_dialog.setFileMode(QFileDialog.ExistingFiles) file_dialog.setDirectory(defaultDirectory) if file_dialog.exec_(): fileNames = file_dialog.selectedFiles() else: # otherwise, use native dialog of the present platform fileNames = QFileDialog.getOpenFileNames(parent_window, "Select Images", defaultDirectory, filt_all_str) # Convert from QtString to python str fileNames = map(encode_from_qstring, fileNames) return fileNames
def chooseNewExportDirectory(self): """ The user wants to choose a new export directory. """ # Launch the "Open File" dialog options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog defaultpath = self.topLevelOperator.WorkingDirectory.value directoryName = QFileDialog.getExistingDirectory(self, "Export Directory", defaultpath, options=options) # Stop now if the user canceled if directoryName.isNull(): return self.chosenExportDirectory = str(directoryName) self.drawer.outputDirEdit.setText(directoryName) # Auto-check the radio button for this option if necessary if not self.drawer.saveToDirButton.isChecked(): self.drawer.saveToDirButton.setChecked(True) else: self.handleExportLocationOptionChanged()
def _update_debug_mode(parsed_args): # Force debug mode if any of these flags are active. if parsed_args.debug or ilastik_config.getboolean("ilastik", "debug"): # There are two places that debug mode can be checked. # Make sure both are set. ilastik_config.set("ilastik", "debug", "true") parsed_args.debug = True
def handleAddStackButtonClicked(self): """ The user clicked the "Import Stack Directory" button. """ # Find the directory of the most recently opened image file mostRecentStackDirectory = PreferencesManager().get( 'DataSelection', 'recent stack directory' ) if mostRecentStackDirectory is not None: defaultDirectory = os.path.split(mostRecentStackDirectory)[0] else: defaultDirectory = os.path.expanduser('~') options = QFileDialog.Options(QFileDialog.ShowDirsOnly) if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog # Launch the "Open File" dialog directoryName = QFileDialog.getExistingDirectory(self, "Image Stack Directory", defaultDirectory, options=options) # If the user didn't cancel if not directoryName.isNull(): PreferencesManager().set('DataSelection', 'recent stack directory', str(directoryName)) globString = self.getGlobString( str(directoryName).replace("\\","/" ) ) if globString is not None: self.importStackFromGlobString( globString )
def getImageFileNamesToOpen(self, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ extensions = OpDataSelection.SupportedExtensions filt = "Image files (" + ' '.join('*.' + x for x in extensions) + ')' dlg = QFileDialog( self, "Select Images", defaultDirectory, filt ) dlg.setOption( QFileDialog.HideNameFilterDetails, False ) if ilastik_config.getboolean("ilastik", "debug"): dlg.setOption( QFileDialog.DontUseNativeDialog, True ) dlg.setViewMode( QFileDialog.Detail ) dlg.setFileMode( QFileDialog.ExistingFiles ) if True: # FIXME: Test scripts can't allow modal dialogs dlg.show() if dlg.result() == QDialog.Accepted: fileNames = dlg.selectedFiles() else: fileNames = [] if dlg.exec_(): fileNames = dlg.selectedFiles() else: fileNames = [] # Convert from QtString to python str fileNames = [str(s) for s in fileNames] return fileNames
def _update_debug_mode(parsed_args): # Force debug mode if any of these flags are active. if parsed_args.debug or ilastik_config.getboolean('ilastik', 'debug'): # There are two places that debug mode can be checked. # Make sure both are set. ilastik_config.set('ilastik', 'debug', 'true') parsed_args.debug = True
def connectLane(self, laneIndex): # Get a handle to each operator opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex) opTrainingFeatures = self.featureSelectionApplet.topLevelOperator.getLane(laneIndex) opClassify = self.pcApplet.topLevelOperator.getLane(laneIndex) opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex) # Input Image -> Feature Op # and -> Classification Op (for display) opTrainingFeatures.InputImage.connect( opData.Image ) opClassify.InputImages.connect( opData.Image ) if ilastik_config.getboolean('ilastik', 'debug'): opClassify.PredictionMasks.connect( opData.ImageGroup[self.DATA_ROLE_PREDICTION_MASK] ) # Feature Images -> Classification Op (for training, prediction) opClassify.FeatureImages.connect( opTrainingFeatures.OutputImage ) opClassify.CachedFeatureImages.connect( opTrainingFeatures.CachedOutputImage ) # Training flags -> Classification Op (for GUI restrictions) opClassify.LabelsAllowedFlags.connect( opData.AllowLabels ) # Data Export connections opDataExport.RawData.connect( opData.ImageGroup[self.DATA_ROLE_RAW] ) opDataExport.RawDatasetInfo.connect( opData.DatasetGroup[self.DATA_ROLE_RAW] ) opDataExport.ConstraintDataset.connect( opData.ImageGroup[self.DATA_ROLE_RAW] ) opDataExport.Inputs.resize( len(self.EXPORT_NAMES) ) opDataExport.Inputs[0].connect( opClassify.HeadlessPredictionProbabilities ) opDataExport.Inputs[1].connect( opClassify.SimpleSegmentation ) opDataExport.Inputs[2].connect( opClassify.HeadlessUncertaintyEstimate ) opDataExport.Inputs[3].connect( opClassify.FeatureImages ) for slot in opDataExport.Inputs: assert slot.partner is not None
def _onExportTifButtonPressed(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog directory = QFileDialog.getExistingDirectory(self, 'Select Directory',os.getenv('HOME'), options=options) if directory is None: print "cancelled." return print 'Saving results as tiffs...' label2color = self.mainOperator.label2color lshape = list(self.mainOperator.LabelImage.meta.shape) for t, label2color_at in enumerate(label2color): if len(label2color_at) == 0: continue print 'exporting tiffs for t = ' + str(t) roi = SubRegion(self.mainOperator.LabelImage, start=[t,] + 4*[0,], stop=[t+1,] + list(lshape[1:])) labelImage = self.mainOperator.LabelImage.get(roi).wait() relabeled = relabel(labelImage[0,...,0],label2color_at) for i in range(relabeled.shape[2]): out_im = relabeled[:,:,i] out_fn = str(directory) + '/vis_t' + str(t).zfill(4) + '_z' + str(i).zfill(4) + '.tif' vigra.impex.writeImage(np.asarray(out_im,dtype=np.uint32), out_fn) print 'Tiffs exported.'
def initAppletDrawerUi(self): super(ConservationTrackingGui, self).initAppletDrawerUi() self._allowedTimeoutInputRegEx = re.compile('^[0-9]*$') self._drawer.timeoutBox.textChanged.connect(self._onTimeoutBoxChanged) if not ilastik_config.getboolean("ilastik", "debug"): assert self._drawer.trackletsBox.isChecked() self._drawer.trackletsBox.hide() assert not self._drawer.hardPriorBox.isChecked() self._drawer.hardPriorBox.hide() assert not self._drawer.opticalBox.isChecked() self._drawer.opticalBox.hide() self._drawer.maxDistBox.hide() # hide the maximal distance box self._drawer.label_2.hide() # hie the maximal distance label self._drawer.label_5.hide() # hide division threshold label self._drawer.divThreshBox.hide() self._drawer.label_25.hide() # hide avg. obj size label self._drawer.avgSizeBox.hide() self.mergerLabels = [self._drawer.merg1, self._drawer.merg2, self._drawer.merg3, self._drawer.merg4, self._drawer.merg5, self._drawer.merg6, self._drawer.merg7] for i in range(len(self.mergerLabels)): self._labelSetStyleSheet(self.mergerLabels[i], self.mergerColors[i+1]) self._onMaxObjectsBoxChanged() self._drawer.maxObjectsBox.valueChanged.connect(self._onMaxObjectsBoxChanged)
def menus(self): m = QMenu("&Export", self.volumeEditorWidget) #m.addAction("Export Object Information").triggered.connect(self.show_export_dialog) if ilastik_config.getboolean("ilastik", "debug"): m.addAction("Export All Label Info").triggered.connect( self.exportLabelInfo ) m.addAction("Import New Label Info").triggered.connect( self.importLabelInfo ) return [m]
def chooseNewExportDirectory(self): """ The user wants to choose a new export directory. """ with Tracer(traceLogger): # Launch the "Open File" dialog options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog defaultpath = self.topLevelOperator.WorkingDirectory.value directoryName = QFileDialog.getExistingDirectory( self, "Export Directory", defaultpath, options=options) # Stop now if the user canceled if directoryName.isNull(): return self.chosenExportDirectory = str(directoryName) self.drawer.outputDirEdit.setText(directoryName) # Auto-check the radio button for this option if necessary if not self.drawer.saveToDirButton.isChecked(): self.drawer.saveToDirButton.setChecked(True) else: self.handleExportLocationOptionChanged()
def repairFile(self, path, filt=None): """get new path to lost file""" from PyQt4.QtGui import QFileDialog, QMessageBox text = "The file at {} could not be found any more. Do you want to search for it at another directory?".format( path) c = QMessageBox.critical(None, "update external data", text, QMessageBox.Ok | QMessageBox.Cancel) if c == QMessageBox.Cancel: raise RuntimeError("Could not find external data: " + path) options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog fileName = QFileDialog.getOpenFileName(None, "repair files", path, filt, options=options) if fileName.isEmpty(): raise RuntimeError("Could not find external data: " + path) else: return str(fileName)
def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(output_mode=default_config.OutputMode.BOTH) else: default_config.init(output_mode=default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS) startUpdateInterval(10) # 10 second periodic refresh
def initAppletDrawerUi(self): super(ConservationTrackingGui, self).initAppletDrawerUi() self._allowedTimeoutInputRegEx = re.compile('^[0-9]*$') self._drawer.timeoutBox.textChanged.connect(self._onTimeoutBoxChanged) if not ilastik_config.getboolean("ilastik", "debug"): assert self._drawer.trackletsBox.isChecked() self._drawer.trackletsBox.hide() assert not self._drawer.hardPriorBox.isChecked() self._drawer.hardPriorBox.hide() assert not self._drawer.opticalBox.isChecked() self._drawer.opticalBox.hide() self._drawer.maxDistBox.hide() # hide the maximal distance box self._drawer.label_2.hide() # hie the maximal distance label self._drawer.label_5.hide() # hide division threshold label self._drawer.divThreshBox.hide() self._drawer.label_25.hide() # hide avg. obj size label self._drawer.avgSizeBox.hide() self.mergerLabels = [ self._drawer.merg1, self._drawer.merg2, self._drawer.merg3, self._drawer.merg4, self._drawer.merg5, self._drawer.merg6, self._drawer.merg7 ] for i in range(len(self.mergerLabels)): self._labelSetStyleSheet(self.mergerLabels[i], self.mergerColors[i + 1]) self._onMaxObjectsBoxChanged() self._drawer.maxObjectsBox.valueChanged.connect( self._onMaxObjectsBoxChanged)
def testBasic(self): # NOTE: In this test, cmd-line args to nosetests will also end up getting "parsed" by ilastik. # That shouldn't be an issue, since the pixel classification workflow ignores unrecognized options. # See if __name__ == __main__ section, below. args = "--project=" + self.PROJECT_FILE args += " --headless" #args += " --sys_tmp_dir=/tmp" # Batch export options args += " --output_format=hdf5" args += " --output_filename_format={dataset_dir}/{nickname}_prediction.h5" args += " --output_internal_path=volume/pred_volume" args += " --raw_data" # (Specifying the role name like this is optional for pixel classification, unless we are also using a mask...) args += " " + self.SAMPLE_DATA if ilastik_config.getboolean('ilastik', 'debug'): args += " --prediction_mask" # (Specifying the role name like this is optional for pixel classification) args += " " + self.SAMPLE_MASK sys.argv = ['ilastik.py'] # Clear the existing commandline args so it looks like we're starting fresh. sys.argv += args.split() # Start up the ilastik.py entry script as if we had launched it from the command line self.ilastik_startup.main() # Examine the output for basic attributes output_path = self.SAMPLE_DATA[:-4] + "_prediction.h5" with h5py.File(output_path, 'r') as f: assert "/volume/pred_volume" in f pred_shape = f["/volume/pred_volume"].shape # Assume channel is last axis assert pred_shape[:-1] == self.data.shape[:-1], "Prediction volume has wrong shape: {}".format( pred_shape ) assert pred_shape[-1] == 2, "Prediction volume has wrong shape: {}".format( pred_shape )
def getImageFileNamesToOpen(cls, parent_window, defaultDirectory): """ opens a QFileDialog for importing files """ extensions = ['nn'] filter_strs = ["*." + x for x in extensions] filters = ["{filt} ({filt})".format(filt=x) for x in filter_strs] filt_all_str = "Image files (" + ' '.join(filter_strs) + ')' fileNames = [] if ilastik_config.getboolean("ilastik", "debug"): # use Qt dialog in debug mode (more portable?) file_dialog = QFileDialog(parent_window, "Select Model") file_dialog.setOption(QFileDialog.DontUseNativeDialog, True) # do not display file types associated with a filter # the line for "Image files" is too long otherwise file_dialog.setNameFilters([filt_all_str] + filters) #file_dialog.setNameFilterDetailsVisible(False) # select multiple files file_dialog.setFileMode(QFileDialog.ExistingFiles) file_dialog.setDirectory(defaultDirectory) if file_dialog.exec_(): fileNames = file_dialog.selectedFiles() else: # otherwise, use native dialog of the present platform fileNames, _ = QFileDialog.getOpenFileNames(parent_window, "Select Model", defaultDirectory, filt_all_str) return fileNames
def getModelFileNameToOpen(cls, parent_window, defaultDirectory): """ opens a QFileDialog for importing files """ extensions = ["pytorch"] filter_strs = ["*." + x for x in extensions] filters = ["{filt} ({filt})".format(filt=x) for x in filter_strs] filt_all_str = "Neural nets (" + " ".join(filter_strs) + ")" fileName = None if ilastik_config.getboolean("ilastik", "debug"): # use Qt dialog in debug mode (more portable?) file_dialog = QFileDialog(parent_window, "Select Model") file_dialog.setOption(QFileDialog.DontUseNativeDialog, True) # do not display file types associated with a filter # the line for "Image files" is too long otherwise file_dialog.setNameFilters([filt_all_str] + filters) # file_dialog.setNameFilterDetailsVisible(False) file_dialog.setFileMode(QFileDialog.ExistingFile) file_dialog.setDirectory(defaultDirectory) if file_dialog.exec_(): fileName = file_dialog.selectedFiles()[0] else: # otherwise, use native dialog of the present platform fileName, _ = QFileDialog.getOpenFileName(parent_window, "Select Model", defaultDirectory, filt_all_str) return fileName
def getImageFileNamesToOpen(cls, parent_window, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ extensions = OpDataSelection.SupportedExtensions filter_strs = ["*." + x for x in extensions] filters = ["{filt} ({filt})".format(filt=x) for x in filter_strs] filt_all_str = "Image files (" + ' '.join(filter_strs) + ')' fileNames = [] if ilastik_config.getboolean("ilastik", "debug"): # use Qt dialog in debug mode (more portable?) file_dialog = QFileDialog(parent_window, "Select Images") file_dialog.setOption(QFileDialog.DontUseNativeDialog, True) # do not display file types associated with a filter # the line for "Image files" is too long otherwise file_dialog.setNameFilters([filt_all_str] + filters) #file_dialog.setNameFilterDetailsVisible(False) # select multiple files file_dialog.setFileMode(QFileDialog.ExistingFiles) file_dialog.setDirectory( defaultDirectory ) if file_dialog.exec_(): fileNames = file_dialog.selectedFiles() else: # otherwise, use native dialog of the present platform fileNames, _filter = QFileDialog.getOpenFileNames(parent_window, "Select Images", defaultDirectory, filt_all_str) return fileNames
def menus(self): if ilastik_config.getboolean('ilastik', 'debug'): m = QMenu("Special Stuff", self.volumeEditorWidget) m.addAction( "Export to Knime" ).triggered.connect(self.exportObjectInfo) mlist = [m] else: mlist = [] return mlist
def initAppletDrawerUi(self): super(ConservationTrackingGui, self).initAppletDrawerUi() self._allowedTimeoutInputRegEx = re.compile("^[0-9]*$") self._drawer.timeoutBox.textChanged.connect(self._onTimeoutBoxChanged) if not ilastik_config.getboolean("ilastik", "debug"): def checkboxAssertHandler(checkbox, assertEnabled=True): if checkbox.isChecked() == assertEnabled: checkbox.hide() else: checkbox.setEnabled(False) checkboxAssertHandler(self._drawer.trackletsBox, True) if self._drawer.classifierPriorBox.isChecked(): self._drawer.hardPriorBox.hide() self._drawer.classifierPriorBox.hide() self._drawer.sizeDepBox.hide() else: self._drawer.hardPriorBox.setEnabled(False) self._drawer.classifierPriorBox.setEnabled(False) self._drawer.sizeDepBox.setEnabled(False) checkboxAssertHandler(self._drawer.opticalBox, False) checkboxAssertHandler(self._drawer.mergerResolutionBox, True) self._drawer.maxDistBox.hide() # hide the maximal distance box self._drawer.label_2.hide() # hie the maximal distance label self._drawer.label_5.hide() # hide division threshold label self._drawer.divThreshBox.hide() self._drawer.label_25.hide() # hide avg. obj size label self._drawer.avgSizeBox.hide() self._drawer.label_24.hide() # hide motion model weight label self._drawer.motionModelWeightBox.hide() self.mergerLabels = [ self._drawer.merg1, self._drawer.merg2, self._drawer.merg3, self._drawer.merg4, self._drawer.merg5, self._drawer.merg6, self._drawer.merg7, ] for i in range(len(self.mergerLabels)): self._labelSetStyleSheet(self.mergerLabels[i], QColor(self.mergerColors[i + 1])) self._onMaxObjectsBoxChanged() self._drawer.maxObjectsBox.valueChanged.connect( self._onMaxObjectsBoxChanged) self._drawer.mergerResolutionBox.stateChanged.connect( self._onMaxObjectsBoxChanged) self._drawer.exportButton.hide()
def handleDirectoryButtonClicked(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog directoryName = QFileDialog.getExistingDirectory(self, "Base Directory", self.defaultDirectory, options=options) self.ui.directoryInput.setText(directoryName)
def _onLineageFileNameButton(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog fn = QFileDialog.getSaveFileName(self, 'Save Lineage Trees', os.getenv('HOME'), options=options) if fn is None: logger.info( "cancelled." ) return self._drawer.lineageFileNameEdit.setText(str(fn))
def menus(self): if ilastik_config.getboolean('ilastik', 'debug'): m = QMenu("Special Stuff", self.volumeEditorWidget) m.addAction("Export to Knime").triggered.connect( self.exportObjectInfo) mlist = [m] else: mlist = [] return mlist
def _update_debug_mode( parsed_args ): # Force debug mode if any of these flags are active. if parsed_args.debug \ or parsed_args.start_recording \ or parsed_args.playback_script \ or ilastik_config.getboolean('ilastik', 'debug'): # There are two places that debug mode can be checked. # Make sure both are set. ilastik_config.set('ilastik', 'debug', 'true') parsed_args.debug = True
def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(output_mode=default_config.OutputMode.BOTH) else: default_config.init(output_mode=default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info( "All console output is being redirected to: {}" .format( parsed_args.redirect_output ) )
def _onExportTifButtonPressed(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog directory = QFileDialog.getExistingDirectory(self, 'Select Directory',os.getenv('HOME'), options=options) if directory is None or len(str(directory)) == 0: print "cancelled." return print 'Saving results as tiffs...' label2color = self.mainOperator.label2color lshape = list(self.mainOperator.LabelImage.meta.shape) def _handle_progress(x): self.applet.progressSignal.emit(x) def _export(): num_files = float(len(label2color)) for t, label2color_at in enumerate(label2color): if len(label2color_at) == 0: continue print 'exporting tiffs for t = ' + str(t) roi = SubRegion(self.mainOperator.LabelImage, start=[t,] + 4*[0,], stop=[t+1,] + list(lshape[1:])) labelImage = self.mainOperator.LabelImage.get(roi).wait() relabeled = relabel(labelImage[0,...,0],label2color_at) for i in range(relabeled.shape[2]): out_im = relabeled[:,:,i] out_fn = str(directory) + '/vis_t' + str(t).zfill(4) + '_z' + str(i).zfill(4) + '.tif' vigra.impex.writeImage(np.asarray(out_im,dtype=np.uint32), out_fn) _handle_progress(t/num_files * 100) print 'Tiffs exported.' def _handle_finished(*args): self._drawer.exportTifButton.setEnabled(True) self.applet.progressSignal.emit(100) def _handle_failure( exc, exc_info ): import traceback, sys traceback.print_exception(*exc_info) sys.stderr.write("Exception raised during export. See traceback above.\n") self.applet.progressSignal.emit(100) self._drawer.exportTifButton.setEnabled(True) self._drawer.exportTifButton.setEnabled(False) self.applet.progressSignal.emit(0) req = Request( _export ) req.notify_failed( _handle_failure ) req.notify_finished( _handle_finished ) req.submit()
def main( parsed_args, workflow_cmdline_args=[] ): this_path = os.path.dirname(__file__) ilastik_dir = os.path.abspath(os.path.join(this_path, "..%s.." % os.path.sep)) # If necessary, redirect stdout BEFORE logging is initialized _redirect_output( parsed_args ) _init_logging( parsed_args ) # Initialize logging before anything else _init_configfile( parsed_args ) _clean_paths( parsed_args, ilastik_dir ) _update_debug_mode( parsed_args ) _init_threading_monkeypatch() _validate_arg_compatibility( parsed_args ) # Extra initialization functions. # Called during app startup. init_funcs = [] lazyflow_config_fn = _prepare_lazyflow_config( parsed_args ) if lazyflow_config_fn: init_funcs.append( lazyflow_config_fn ) load_fn = _prepare_auto_open_project( parsed_args ) if load_fn: init_funcs.append( load_fn ) create_fn = _prepare_auto_create_new_project( parsed_args ) if create_fn: init_funcs.append( create_fn ) _enable_faulthandler() _init_excepthooks( parsed_args ) eventcapture_mode, playback_args = _prepare_test_recording_and_playback( parsed_args ) if ilastik_config.getboolean("ilastik", "debug"): message = 'Starting ilastik in debug mode from "%s".' % ilastik_dir logger.info(message) print message # always print the startup message else: message = 'Starting ilastik from "%s".' % ilastik_dir logger.info(message) print message # always print the startup message # Headless launch if parsed_args.headless: from ilastik.shell.headless.headlessShell import HeadlessShell shell = HeadlessShell( workflow_cmdline_args ) for f in init_funcs: f(shell) return shell # Normal launch else: from ilastik.shell.gui.startShellGui import startShellGui sys.exit(startShellGui(workflow_cmdline_args, eventcapture_mode, playback_args, *init_funcs))
def _init_excepthooks( parsed_args ): # Initialize global exception handling behavior import ilastik.excepthooks if parsed_args.exit_on_failure: # Auto-exit on uncaught exceptions (useful for testing) ilastik.excepthooks.init_early_exit_excepthook() elif not ilastik_config.getboolean('ilastik', 'debug') and not parsed_args.headless: # Show most uncaught exceptions to the user (default behavior) ilastik.excepthooks.init_user_mode_excepthook() else: # Log all exceptions as errors ilastik.excepthooks.init_developer_mode_excepthook()
def _onExportTifButtonPressed(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog directory = encode_from_qstring(QFileDialog.getExistingDirectory(self, 'Select Directory',os.path.expanduser("~"), options=options)) if directory is None or len(str(directory)) == 0: logger.info( "cancelled." ) return logger.info( 'Saving results as tiffs...' ) label2color = self.mainOperator.label2color lshape = list(self.mainOperator.LabelImage.meta.shape) def _handle_progress(x): self.applet.progressSignal.emit(x) def _export(): num_files = float(len(label2color)) for t, label2color_at in enumerate(label2color): if len(label2color_at) == 0: continue logger.info( 'exporting tiffs for t = ' + str(t) ) roi = SubRegion(self.mainOperator.LabelImage, start=[t,] + 4*[0,], stop=[t+1,] + list(lshape[1:])) labelImage = self.mainOperator.LabelImage.get(roi).wait() relabeled = relabel(labelImage[0,...,0],label2color_at) for i in range(relabeled.shape[2]): out_im = relabeled[:,:,i] out_fn = str(directory) + '/vis_t' + str(t).zfill(4) + '_z' + str(i).zfill(4) + '.tif' vigra.impex.writeImage(np.asarray(out_im,dtype=np.uint32), out_fn) _handle_progress(t/num_files * 100) logger.info( 'Tiffs exported.' ) def _handle_finished(*args): self._drawer.exportTifButton.setEnabled(True) self.applet.progressSignal.emit(100) def _handle_failure( exc, exc_info ): msg = "Exception raised during export. See traceback above.\n" log_exception( logger, msg, exc_info ) self.applet.progressSignal.emit(100) self._drawer.exportTifButton.setEnabled(True) self._drawer.exportTifButton.setEnabled(False) self.applet.progressSignal.emit(0) req = Request( _export ) req.notify_failed( _handle_failure ) req.notify_finished( _handle_finished ) req.submit()
def _update_debug_mode(parsed_args): # Force debug mode if any of these flags are active. if ( parsed_args.debug or parsed_args.start_recording or parsed_args.playback_script or ilastik_config.getboolean("ilastik", "debug") ): # There are two places that debug mode can be checked. # Make sure both are set. ilastik_config.set("ilastik", "debug", "true") parsed_args.debug = True
def initAppletDrawerUi(self): """ Load the ui file for the applet drawer, which we own. """ localDir = os.path.split(__file__)[0] # (We don't pass self here because we keep the drawer ui in a separate object.) self.drawer = uic.loadUi(localDir + "/featureSelectionDrawer.ui") self.drawer.SelectFeaturesButton.clicked.connect(self.onFeatureButtonClicked) self.drawer.UsePrecomputedFeaturesButton.clicked.connect(self.onUsePrecomputedFeaturesButtonClicked) dbg = ilastik_config.getboolean("ilastik", "debug") if not dbg: self.drawer.UsePrecomputedFeaturesButton.setHidden(True)
def init(format_prefix="", output_mode=OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path=DEFAULT_LOGFILE_PATH): if logfile_path == "/dev/null": assert output_mode != OutputMode.LOGFILE, "Must enable a logging mode." output_mode = OutputMode.CONSOLE # Preserve pre-existing handlers original_root_handlers = list(logging.getLogger().handlers) # Start with the default default_config = get_default_config(format_prefix, output_mode, logfile_path) logging.config.dictConfig(default_config) # Preserve pre-existing handlers for handler in original_root_handlers: logging.getLogger().addHandler(handler) # Update from the user's customizations loggingHelpers.updateFromConfigFile() # Capture warnings from the warnings module logging.captureWarnings(True) # Warnings module warnings are shown only once warnings.filterwarnings("once") # Don't warn about pending deprecations (PyQt generates some of these) warnings.filterwarnings("ignore", category=PendingDeprecationWarning) # Don't warn about duplicate python bindings for opengm # (We import opengm twice, as 'opengm' 'opengm_with_cplex'.) warnings.filterwarnings("ignore", message='.*to-Python converter for .*opengm.*', category=RuntimeWarning) # Hide all other python converter warnings unless we're in debug mode. if not ilastik_config.getboolean("ilastik", "debug"): warnings.filterwarnings( "ignore", message= '.*to-Python converter for .*second conversion method ignored.*', category=RuntimeWarning) # Custom format for warnings def simple_warning_format(message, category, filename, lineno, line=None): filename = os.path.split(filename)[1] return filename + "(" + str( lineno) + "): " + category.__name__ + ": " + message[0] warnings.formatwarning = simple_warning_format
def getImageFileNamesToOpen(self, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ extensions = OpDataSelection.SupportedExtensions filt = "Image files (" + " ".join("*." + x for x in extensions) + ")" options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog fileNames = QFileDialog.getOpenFileNames(self, "Select Images", defaultDirectory, filt, options=options) # Convert from QtString to python str fileNames = [str(s) for s in fileNames] return fileNames
def initAppletDrawerUi(self): super(ConservationTrackingGui, self).initAppletDrawerUi() self._allowedTimeoutInputRegEx = re.compile('^[0-9]*$') self._drawer.timeoutBox.textChanged.connect(self._onTimeoutBoxChanged) if not ilastik_config.getboolean("ilastik", "debug"): def checkboxAssertHandler(checkbox, assertEnabled=True): if checkbox.isChecked() == assertEnabled: checkbox.hide() else: checkbox.setEnabled(False) checkboxAssertHandler(self._drawer.trackletsBox, True) if self._drawer.classifierPriorBox.isChecked(): self._drawer.hardPriorBox.hide() self._drawer.classifierPriorBox.hide() self._drawer.sizeDepBox.hide() else: self._drawer.hardPriorBox.setEnabled(False) self._drawer.classifierPriorBox.setEnabled(False) self._drawer.sizeDepBox.setEnabled(False) checkboxAssertHandler(self._drawer.opticalBox, False) checkboxAssertHandler(self._drawer.mergerResolutionBox, True) self._drawer.maxDistBox.hide() # hide the maximal distance box self._drawer.label_2.hide() # hie the maximal distance label self._drawer.label_5.hide() # hide division threshold label self._drawer.divThreshBox.hide() self._drawer.label_25.hide() # hide avg. obj size label self._drawer.avgSizeBox.hide() self._drawer.label_24.hide() # hide motion model weight label self._drawer.motionModelWeightBox.hide() self._drawer.maxNearestNeighborsSpinBox.hide() self._drawer.MaxNearestNeighbourLabel.hide() self.mergerLabels = [self._drawer.merg1, self._drawer.merg2, self._drawer.merg3, self._drawer.merg4, self._drawer.merg5, self._drawer.merg6, self._drawer.merg7] for i in range(len(self.mergerLabels)): self._labelSetStyleSheet(self.mergerLabels[i], self.mergerColors[i+1]) self._onMaxObjectsBoxChanged() self._drawer.maxObjectsBox.valueChanged.connect(self._onMaxObjectsBoxChanged) self._drawer.mergerResolutionBox.stateChanged.connect(self._onMaxObjectsBoxChanged)
def add_peer(self, name, address): host, port = address key = (host, name) if key not in self.peers: self.peers[key] = { "enabled": ilastik_config.getboolean("ipc raw tcp", "autoaccept"), "address": [host, port] } elif self.peers[key]["address"][1] != port: self.peers[key]["address"][1] = port else: return self.info.update_connections(self.peers)
def initAppletDrawerUi(self): """ Load the ui file for the applet drawer, which we own. """ localDir = os.path.split(__file__)[0] # (We don't pass self here because we keep the drawer ui in a separate object.) self.drawer = uic.loadUi(localDir + "/featureSelectionDrawer.ui") self.drawer.SelectFeaturesButton.clicked.connect( self.onFeatureButtonClicked) self.drawer.UsePrecomputedFeaturesButton.clicked.connect( self.onUsePrecomputedFeaturesButtonClicked) dbg = ilastik_config.getboolean("ilastik", "debug") if not dbg: self.drawer.UsePrecomputedFeaturesButton.setHidden(True)
def onUsePrecomputedFeaturesButtonClicked(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog filename = QFileDialog.getOpenFileName(self, 'Open Feature List', '.', options=options) filename = encode_from_qstring(filename) #sanity checks on the given file if not filename: return if not os.path.exists(filename): QMessageBox.critical(self, "Open Feature List", "File '%s' does not exist" % filename) return f = open(filename, 'r') with f: for line in f: line = line.strip() if len(line) == 0: continue if not os.path.exists(line): QMessageBox.critical( self, "Open Feature List", "File '%s', referenced in '%s', does not exist" % (line, filename)) return try: h = h5py.File(line, 'r') with h: assert len(h["data"].shape) == 3 except: QMessageBox.critical( self, "Open Feature List", "File '%s', referenced in '%s', could not be opened as an HDF5 file or does not contain a 3D dataset called 'data'" % (line, filename)) return self.topLevelOperatorView.FeatureListFilename.setValue(filename) self.topLevelOperatorView._setupOutputs() self.onFeaturesSelectionsChanged() # Notify the workflow that some applets may have changed state now. # (For example, the downstream pixel classification applet can # be used now that there are features selected) self.parentApplet.appletStateUpdateRequested.emit()
def add_peer(self, name, address): host, port = address key = (host, name) if key not in self.peers: self.peers[key] = { "enabled": ilastik_config.getboolean("ipc raw tcp", "autoaccept"), "address": [host, port], } elif self.peers[key]["address"][1] != port: self.peers[key]["address"][1] = port else: return self.info.update_connections(self.peers)
def menus( self ): menus = super( PixelClassificationGui, self ).menus() # For now classifier selection is only available in debug mode if ilastik_config.getboolean('ilastik', 'debug'): def handleClassifierAction(): dlg = ClassifierSelectionDlg(self.topLevelOperatorView, parent=self) dlg.exec_() advanced_menu = QMenu("Advanced", parent=self) classifier_action = advanced_menu.addAction("Classifier...") classifier_action.triggered.connect( handleClassifierAction ) menus += [advanced_menu] return menus
def _onExportButtonPressed(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog directory = QFileDialog.getExistingDirectory(self, 'Select Directory',os.getenv('HOME'), options=options) if directory is None: print "cancelled." return # determine from_time (it could has been changed in the GUI meanwhile) for t_from, label2color_at in enumerate(self.mainOperator.label2color): if len(label2color_at) == 0: continue else: break print "Saving first label image..." key = [] for idx, flag in enumerate(axisTagsToString(self.mainOperator.LabelImage.meta.axistags)): if flag is 't': key.append(slice(t_from,t_from+1)) elif flag is 'c': key.append(slice(0,1)) else: key.append(slice(0,self.mainOperator.LabelImage.meta.shape[idx])) roi = SubRegion(self.mainOperator.LabelImage, key) labelImage = self.mainOperator.LabelImage.get(roi).wait() labelImage = labelImage[0,...,0] write_events([], str(directory), t_from, labelImage) events = self.mainOperator.events print "Saving events..." print "Length of events " + str(len(events)) for i, events_at in enumerate(events): t = t_from + i key[0] = slice(t+1,t+2) roi = SubRegion(self.mainOperator.LabelImage, key) labelImage = self.mainOperator.LabelImage.get(roi).wait() labelImage = labelImage[0,...,0] if self.withMergers: write_events(events_at, str(directory), t+1, labelImage, self.mainOperator.mergers) else: write_events(events_at, str(directory), t+1, labelImage)
def populate(self): self.ui.treeWidget.setColumnCount(1) for pluginName, features in self.featureDict.iteritems(): if pluginName == "TestFeatures" and not ilastik_config.getboolean( "ilastik", "debug"): continue parent = QTreeWidgetItem(self.ui.treeWidget) parent.setText(0, pluginName) parent.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) # hack to ensure checkboxes visible parent.setCheckState(0, Qt.Checked) parent.setCheckState(0, Qt.Unchecked) parent.setExpanded(False) self.countChecked[pluginName] = 0 self.countAll[pluginName] = len(self.featureDict[pluginName]) advanced_names = [] simple_names = [] for name in sorted(features.keys()): parameters = features[name] if 'advanced' in parameters: advanced_names.append(name) else: simple_names.append(name) for name in simple_names + advanced_names: parameters = features[name] item = QTreeWidgetItem(parent) item.setText(0, name) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if 'tooltip' in parameters: item.setToolTip(0, parameters['tooltip']) # hack to ensure checkboxes visible item.setCheckState(0, Qt.Checked) item.setCheckState(0, Qt.Unchecked) if pluginName in self.selectedFeatures: if name in self.selectedFeatures[pluginName]: item.setCheckState(0, Qt.Checked) self.countChecked[pluginName] += 1 if self.countChecked[pluginName] == 0: parent.setCheckState(0, Qt.Unchecked) elif self.countChecked[pluginName] == self.countAll[pluginName]: parent.setCheckState(0, Qt.Checked) else: parent.setCheckState(0, Qt.PartiallyChecked) self.updateToolTip(parent) # facilitates switching of the CheckBox when clicking on the Text of a QTreeWidgetItem self.ui.treeWidget.setCurrentItem(None)
def onUsePrecomputedFeaturesButtonClicked(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog filenames, _filter = QFileDialog.getOpenFileNames(self, "Open Feature Files", ".", options=options) # Check if file exists if not filenames: return for filename in filenames: if not os.path.exists(filename): QMessageBox.critical(self, "Open Feature List", "File '%s' does not exist" % filename) return num_lanes = len(self.parentApplet.topLevelOperator.FeatureListFilename) if num_lanes != len(filenames): QMessageBox.critical( self, "Wrong number of feature files", "You must select all pre-computed feature files at once (shift-click).\n" "You selected {} file(s), but there are {} image(s) loaded". format(len(filenames), num_lanes), ) return for filename, slot in zip( filenames, self.parentApplet.topLevelOperator.FeatureListFilename): slot.setValue(filename) # Create a dummy SelectionMatrix, just so the operator knows it is configured # This is a little hacky. We should really make SelectionMatrix optional, # and then handle the choice correctly in setupOutputs, probably involving # the Output.meta.NOTREADY flag dummy_matrix = numpy.zeros((6, 7), dtype=bool) dummy_matrix[0, 0] = True self.parentApplet.topLevelOperator.SelectionMatrix.setValue(True) # Notify the workflow that some applets may have changed state now. # (For example, the downstream pixel classification applet can # be used now that there are features selected) self.parentApplet.appletStateUpdateRequested()
def _init_logging(parsed_args): from ilastik.ilastik_logging import default_config, startUpdateInterval, DEFAULT_LOGFILE_PATH logfile_path = parsed_args.logfile or DEFAULT_LOGFILE_PATH process_name = "" if parsed_args.process_name: process_name = parsed_args.process_name + " " if ilastik_config.getboolean("ilastik", "debug") or parsed_args.headless: default_config.init(process_name, default_config.OutputMode.BOTH, logfile_path) else: default_config.init(process_name, default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info("All console output is being redirected to: {}".format(parsed_args.redirect_output))
def menus(self): menus = super(PixelClassificationGui, self).menus() # For now classifier selection is only available in debug mode if ilastik_config.getboolean('ilastik', 'debug'): def handleClassifierAction(): dlg = ClassifierSelectionDlg(self.topLevelOperatorView, parent=self) dlg.exec_() advanced_menu = QMenu("Advanced", parent=self) classifier_action = advanced_menu.addAction("Classifier...") classifier_action.triggered.connect(handleClassifierAction) menus += [advanced_menu] return menus
def getImageFileNamesToOpen(self, defaultDirectory): """ Launch an "Open File" dialog to ask the user for one or more image files. """ extensions = OpDataSelection.SupportedExtensions filt = "Image files (" + ' '.join('*.' + x for x in extensions) + ')' options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog fileNames = QFileDialog.getOpenFileNames(self, "Select Images", defaultDirectory, filt, options=options) # Convert from QtString to python str fileNames = [str(s) for s in fileNames] return fileNames
def _init_logging( parsed_args ): from ilastik.ilastik_logging import default_config, startUpdateInterval, DEFAULT_LOGFILE_PATH logfile_path = parsed_args.logfile or DEFAULT_LOGFILE_PATH process_name = "" if parsed_args.process_name: process_name = parsed_args.process_name + " " if ilastik_config.getboolean('ilastik', 'debug') or parsed_args.headless: default_config.init(process_name, default_config.OutputMode.BOTH, logfile_path) else: default_config.init(process_name, default_config.OutputMode.LOGFILE_WITH_CONSOLE_ERRORS, logfile_path) startUpdateInterval(10) # 10 second periodic refresh if parsed_args.redirect_output: logger.info( "All console output is being redirected to: {}" .format( parsed_args.redirect_output ) )
def initAppletDrawerUi(self): self._drawer = self._loadUiFile() if not ilastik_config.getboolean("ilastik", "debug"): self._drawer.exportLabel.hide() self._drawer.exportTifButton.hide() self._drawer.TrackButton.pressed.connect(self._onTrackButtonPressed) self._drawer.exportButton.pressed.connect(self._onExportButtonPressed) self._drawer.exportTifButton.pressed.connect(self._onExportTifButtonPressed) self._drawer.from_time.valueChanged.connect(self._setRanges) self._drawer.from_x.valueChanged.connect(self._setRanges) self._drawer.from_y.valueChanged.connect(self._setRanges) self._drawer.from_z.valueChanged.connect(self._setRanges) self._drawer.to_time.valueChanged.connect(self._setRanges) self._drawer.to_x.valueChanged.connect(self._setRanges) self._drawer.to_y.valueChanged.connect(self._setRanges) self._drawer.to_z.valueChanged.connect(self._setRanges)
def onUsePrecomputedFeaturesButtonClicked(self): options = QFileDialog.Options() if ilastik_config.getboolean("ilastik", "debug"): options |= QFileDialog.DontUseNativeDialog filename = QFileDialog.getOpenFileName(self, 'Open Feature List', '.', options=options) #sanity checks on the given file if not filename: return if not os.path.exists(filename): QMessageBox.critical(self, "Open Feature List", "File '%s' does not exist" % filename) return f = open(filename, 'r') with f: for line in f: line = line.strip() if len(line) == 0: continue if not os.path.exists(line): QMessageBox.critical( self, "Open Feature List", "File '%s', referenced in '%s', does not exist" % (line, filename)) return try: h = h5py.File(line, 'r') with h: assert len(h["data"].shape) == 3 except: QMessageBox.critical( self, "Open Feature List", "File '%s', referenced in '%s', could not be opened as an HDF5 file or does not contain a 3D dataset called 'data'" % (line, filename)) return self.topLevelOperatorView.FeatureListFilename.setValue(filename) self.topLevelOperatorView._setupOutputs() self.onFeaturesSelectionsChanged()
def populate(self): self.ui.treeWidget.setColumnCount(1) for pluginName, features in self.featureDict.iteritems(): if pluginName == "TestFeatures" and not ilastik_config.getboolean( "ilastik", "debug"): continue parent = QTreeWidgetItem(self.ui.treeWidget) if pluginName == "Standard Object Features": parent.setText(0, pluginName) parent.setToolTip( 0, 'http://hci.iwr.uni-heidelberg.de/vigra/doc/vigra/group__FeatureAccumulators.html' ) else: parent.setText(0, pluginName) parent.setExpanded(True) advanced_names = [] simple_names = [] for name in sorted(features.keys()): parameters = features[name] if 'advanced' in parameters: advanced_names.append(name) else: simple_names.append(name) for name in simple_names + advanced_names: parameters = features[name] item = QTreeWidgetItem(parent) item.setText(0, name) item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) if 'tooltip' in parameters: item.setToolTip(0, parameters['tooltip']) # hack to ensure checkboxes visible item.setCheckState(0, Qt.Checked) item.setCheckState(0, Qt.Unchecked) if pluginName in self.selectedFeatures: if name in self.selectedFeatures[pluginName]: item.setCheckState(0, Qt.Checked)