use of qupath.lib.plugins.workflow.RunSavedClassifierWorkflowStep in project qupath by qupath.
the class PathClassifierPane method runClassifier.
void runClassifier() {
QuPathViewer viewer = viewerValue.getValue();
if (viewer == null)
return;
ImageData<BufferedImage> imageData = viewer.getImageData();
if (classifier == null || imageData == null || !classifier.isValid())
return;
Collection<PathObject> pathObjects = imageData.getHierarchy().getDetectionObjects();
var availableFeatures = PathClassifierTools.getAvailableFeatures(pathObjects);
var requiredFeatures = classifier.getRequiredMeasurements();
String missingFeatures = requiredFeatures.stream().filter(p -> !availableFeatures.contains(p)).collect(Collectors.joining("\n\t"));
if (!missingFeatures.isEmpty())
logger.warn("Detection objects are missing the following feature(s):\n\t" + missingFeatures + "\nWill proceed with classification anyway..");
// SwingUtilities.getRoot(viewer).setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
PathClassifierTools.runClassifier(imageData.getHierarchy(), classifier);
// Log the classifier
if (pathClassifier != null) {
imageData.getHistoryWorkflow().addStep(new RunSavedClassifierWorkflowStep(pathClassifier));
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// SwingUtilities.getRoot(viewer).setCursor(cursor);
// Update displayed list - names may have changed - and classifier summary
updateClassifierSummary();
}
}
use of qupath.lib.plugins.workflow.RunSavedClassifierWorkflowStep in project qupath by qupath.
the class QP method runClassifier.
/**
* Run a detection object classifier for the current image data, reading the classifier from a specified path
* @param path
*/
@Deprecated
public static void runClassifier(final String path) {
ImageData<?> imageData = getCurrentImageData();
if (imageData == null)
return;
PathObjectClassifier classifier = PathClassifierTools.loadClassifier(new File(path));
if (classifier == null) {
logger.error("Could not load classifier from {}", path);
return;
}
runClassifier(imageData, classifier);
// Log the step
imageData.getHistoryWorkflow().addStep(new RunSavedClassifierWorkflowStep(path));
}
Aggregations