def _onTrackButtonPressed(self): if not self.mainOperator.ObjectFeatures.ready(): self._criticalMessage("You have to compute object features first.") return withMergerResolution = self._drawer.mergerResolutionBox.isChecked() withTracklets = True numStages = 6 # creating traxel store # generating probabilities # insert energies # convexify costs # solver # compute lineages if withMergerResolution: numStages += 1 # merger resolution if withTracklets: numStages += 3 # initializing tracklet graph, finding tracklets, contracting edges in tracklet graph if WITH_HYTRA: self.progressWindow = TrackProgressDialog(parent=self, numStages=numStages) self.progressWindow.run() self.progressWindow.show() self.progressVisitor = GuiProgressVisitor( progressWindow=self.progressWindow) else: self.progressWindow = None self.progressVisitor = DefaultProgressVisitor() def _track(): self.applet.busy = True self.applet.appletStateUpdateRequested.emit() maxDist = self._drawer.maxDistBox.value() maxObj = self._drawer.maxObjectsBox.value() divThreshold = self._drawer.divThreshBox.value() from_t = self._drawer.from_time.value() to_t = self._drawer.to_time.value() from_x = self._drawer.from_x.value() to_x = self._drawer.to_x.value() from_y = self._drawer.from_y.value() to_y = self._drawer.to_y.value() from_z = self._drawer.from_z.value() to_z = self._drawer.to_z.value() from_size = self._drawer.from_size.value() to_size = self._drawer.to_size.value() self.time_range = range(from_t, to_t + 1) avgSize = [self._drawer.avgSizeBox.value()] cplex_timeout = None if len(str(self._drawer.timeoutBox.text())): cplex_timeout = int(self._drawer.timeoutBox.text()) withTracklets = True sizeDependent = self._drawer.sizeDepBox.isChecked() hardPrior = self._drawer.hardPriorBox.isChecked() classifierPrior = self._drawer.classifierPriorBox.isChecked() detWeight = self._drawer.detWeightBox.value() divWeight = self._drawer.divWeightBox.value() transWeight = self._drawer.transWeightBox.value() withDivisions = self._drawer.divisionsBox.isChecked() withOpticalCorrection = self._drawer.opticalBox.isChecked() withMergerResolution = self._drawer.mergerResolutionBox.isChecked() borderAwareWidth = self._drawer.bordWidthBox.value() withArmaCoordinates = True appearanceCost = self._drawer.appearanceBox.value() disappearanceCost = self._drawer.disappearanceBox.value() solverName = self._drawer.solverComboBox.currentText() ndim = 3 if (to_z - from_z == 0): ndim = 2 try: self.mainOperator.track( time_range=self.time_range, x_range=(from_x, to_x + 1), y_range=(from_y, to_y + 1), z_range=(from_z, to_z + 1), size_range=(from_size, to_size + 1), x_scale=self._drawer.x_scale.value(), y_scale=self._drawer.y_scale.value(), z_scale=self._drawer.z_scale.value(), maxDist=maxDist, maxObj=maxObj, divThreshold=divThreshold, avgSize=avgSize, withTracklets=withTracklets, sizeDependent=sizeDependent, detWeight=detWeight, divWeight=divWeight, transWeight=transWeight, withDivisions=withDivisions, withOpticalCorrection=withOpticalCorrection, withClassifierPrior=classifierPrior, ndim=ndim, withMergerResolution=withMergerResolution, borderAwareWidth=borderAwareWidth, withArmaCoordinates=withArmaCoordinates, cplex_timeout=cplex_timeout, appearance_cost=appearanceCost, disappearance_cost=disappearanceCost, #graph_building_parameter_changed = True, #trainingToHardConstraints = self._drawer.trainingToHardConstraints.isChecked(), max_nearest_neighbors=self._maxNearestNeighbors, solverName=solverName, progressWindow=self.progressWindow, progressVisitor=self.progressVisitor) except Exception: ex_type, ex, tb = sys.exc_info() traceback.print_tb(tb) self._criticalMessage("Exception(" + str(ex_type) + "): " + str(ex)) return def _handle_finished(*args): self.applet.busy = False self.applet.appletStateUpdateRequested.emit() self._drawer.TrackButton.setEnabled(True) self._drawer.exportButton.setEnabled(True) self._drawer.exportTifButton.setEnabled(True) self._setLayerVisible("Objects", False) def _handle_failure(exc, exc_info): self.applet.busy = False self.applet.appletStateUpdateRequested.emit() traceback.print_exception(*exc_info) sys.stderr.write( "Exception raised during tracking. See traceback above.\n") self._drawer.TrackButton.setEnabled(True) if self.progressWindow is not None: self.progressWindow.onTrackDone() req = Request(_track) req.notify_failed(_handle_failure) req.notify_finished(_handle_finished) req.submit()
def _onTrackButtonPressed(self): if not self.mainOperator.ObjectFeatures.ready(): self._criticalMessage("You have to compute object features first.") return withMergerResolution = self._drawer.mergerResolutionBox.isChecked() numStages = 8 # object features # detection probabilities # creating traxel store # generating probabilities # insert energies # convexify costs # solver # compute lineages if self._drawer.divisionsBox.isChecked(): # division probabilities numStages += 1 if withMergerResolution: numStages += 1 # merger resolution withTracklets = self._drawer.trackletsBox.isChecked() if withTracklets: numStages += 3 # initializing tracklet graph, finding tracklets, contracting edges in tracklet graph self.progressWindow = TrackProgressDialog(parent=self, numStages=numStages) self.progressWindow.run() self.progressWindow.show() self.progressVisitor = GuiProgressVisitor( progressWindow=self.progressWindow) def _track(): self.applet.busy = True self.applet.appletStateUpdateRequested() maxDist = self._drawer.maxDistBox.value() maxObj = self._drawer.maxObjectsBox.value() divThreshold = self._drawer.divThreshBox.value() from_t = self._drawer.from_time.value() to_t = self._drawer.to_time.value() from_x = self._drawer.from_x.value() to_x = self._drawer.to_x.value() from_y = self._drawer.from_y.value() to_y = self._drawer.to_y.value() from_z = self._drawer.from_z.value() to_z = self._drawer.to_z.value() from_size = self._drawer.from_size.value() to_size = self._drawer.to_size.value() self.time_range = list(range(from_t, to_t + 1)) avgSize = [self._drawer.avgSizeBox.value()] cplex_timeout = None if len(str(self._drawer.timeoutBox.text())): cplex_timeout = int(self._drawer.timeoutBox.text()) withTracklets = self._drawer.trackletsBox.isChecked() sizeDependent = self._drawer.sizeDepBox.isChecked() hardPrior = self._drawer.hardPriorBox.isChecked() classifierPrior = self._drawer.classifierPriorBox.isChecked() divWeight = self._drawer.divWeightBox.value() transWeight = self._drawer.transWeightBox.value() withDivisions = self._drawer.divisionsBox.isChecked() withOpticalCorrection = self._drawer.opticalBox.isChecked() withMergerResolution = self._drawer.mergerResolutionBox.isChecked() borderAwareWidth = self._drawer.bordWidthBox.value() withArmaCoordinates = True appearanceCost = self._drawer.appearanceBox.value() disappearanceCost = self._drawer.disappearanceBox.value() motionModelWeight = self._drawer.motionModelWeightBox.value() solver = self._drawer.solverComboBox.currentText() ndim = 3 if (to_z - from_z == 0): ndim = 2 try: self.mainOperator.track( time_range=self.time_range, x_range=(from_x, to_x + 1), y_range=(from_y, to_y + 1), z_range=(from_z, to_z + 1), size_range=(from_size, to_size + 1), x_scale=self._drawer.x_scale.value(), y_scale=self._drawer.y_scale.value(), z_scale=self._drawer.z_scale.value(), maxDist=maxDist, maxObj=maxObj, divThreshold=divThreshold, avgSize=avgSize, withTracklets=withTracklets, sizeDependent=sizeDependent, detWeight=10.0, divWeight=divWeight, transWeight=transWeight, withDivisions=withDivisions, withOpticalCorrection=withOpticalCorrection, withClassifierPrior=classifierPrior, ndim=ndim, withMergerResolution=withMergerResolution, borderAwareWidth=borderAwareWidth, withArmaCoordinates=withArmaCoordinates, cplex_timeout=cplex_timeout, appearance_cost=appearanceCost, disappearance_cost=disappearanceCost, motionModelWeight=motionModelWeight, force_build_hypotheses_graph=False, max_nearest_neighbors=self._drawer. maxNearestNeighborsSpinBox.value(), numFramesPerSplit=self._drawer.numFramesPerSplitSpinBox. value(), solverName=solver, progressWindow=self.progressWindow, progressVisitor=self.progressVisitor) except Exception as ex: self.progressWindow.onTrackDone() log_exception( logger, "Error during tracking. See above error traceback.") self._criticalMessage( "Error during tracking. See error log.\n\n" "Exception was:\n\n{})".format(ex)) return def _handle_finished(*args): self.applet.busy = False self.applet.appletStateUpdateRequested() self._drawer.TrackButton.setEnabled(True) self._drawer.exportButton.setEnabled(True) self._drawer.exportTifButton.setEnabled(True) self._setLayerVisible("Objects", False) # update showing the merger legend, # as it might be (no longer) needed if merger resolving # is disabled(enabled) self._setMergerLegend(self.mergerLabels, self._drawer.maxObjectsBox.value()) def _handle_failure(exc, exc_info): self.applet.busy = False self.applet.appletStateUpdateRequested() traceback.print_exception(*exc_info) sys.stderr.write( "Exception raised during tracking. See traceback above.\n") self._drawer.TrackButton.setEnabled(True) req = Request(_track) req.notify_failed(_handle_failure) req.notify_finished(_handle_finished) req.submit()
def _onRunStructuredLearningButtonPressed(self, withBatchProcessing=False): numStages = 4 # creating traxel store # generating probabilities # insert energies # structured learning if WITH_HYTRA: self.progressWindow = TrackProgressDialog(parent=self, numStages=numStages) self.progressWindow.run() self.progressWindow.show() self.progressVisitor = GuiProgressVisitor( progressWindow=self.progressWindow) else: self.progressWindow = None self.progressVisitor = DefaultProgressVisitor() def _learn(): self.applet.busy = True self.applet.appletStateUpdateRequested.emit() try: self.topLevelOperatorView._runStructuredLearning( (self._drawer.from_z.value(), self._drawer.to_z.value()), self._maxNumObj, self._maxNearestNeighbors, self._drawer.maxDistBox.value(), self._drawer.divThreshBox.value(), (self._drawer.x_scale.value(), self._drawer.y_scale.value(), self._drawer.z_scale.value()), (self._drawer.from_size.value(), self._drawer.to_size.value()), self._drawer.divisionsBox.isChecked(), self._drawer.bordWidthBox.value(), self._drawer.classifierPriorBox.isChecked(), withBatchProcessing, progressWindow=self.progressWindow, progressVisitor=self.progressVisitor) except Exception: ex_type, ex, tb = sys.exc_info() traceback.print_tb(tb) self._criticalMessage("Exception(" + str(ex_type) + "): " + str(ex)) return def _handle_finished(*args): self.applet.busy = False self.applet.appletStateUpdateRequested.emit() def _handle_failure(exc, exc_info): self.applet.busy = False self.applet.appletStateUpdateRequested.emit() traceback.print_exception(*exc_info) sys.stderr.write( "Exception raised during learning. See traceback above.\n") if self.progressWindow is not None: self.progressWindow.onTrackDone() req = Request(_learn) req.notify_failed(_handle_failure) req.notify_finished(_handle_finished) req.submit()