Search in sources :

Example 1 with ParameterList

use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.

the class CellCountsCV method getDefaultParameterList.

@Override
public ParameterList getDefaultParameterList(final ImageData<BufferedImage> imageData) {
    ParameterList params = new ParameterList().addTitleParameter("Detection image").addChoiceParameter("stainChannel", "Cell detection channel", HEMATOXYLIN, STAIN_CHANNELS, "Choose channel that will be thresholded to detect the cells").addDoubleParameter("magnification", "Requested magnification", Double.NaN, null, "Magnification at which the detection should be run").addDoubleParameter("gaussianSigmaPixels", "Gaussian sigma", 1, "px", "Smoothing filter used to reduce spurious peaks").addDoubleParameter("gaussianSigmaMicrons", "Gaussian sigma", 1.5, GeneralTools.micrometerSymbol(), "Smoothing filter used to reduce spurious peaks").addDoubleParameter("backgroundRadiusPixels", "Background radius", 20, "px", "Filter size to estimate background; should be > the largest nucleus radius").addDoubleParameter("backgroundRadiusMicrons", "Background radius", 15, GeneralTools.micrometerSymbol(), "Filter size to estimate background; should be > the largest nucleus radius").addBooleanParameter("doDoG", "Use Difference of Gaussians", true, "Apply Difference of Gaussians filter prior to detection - this tends to detect more nuclei, but may detect too many").addTitleParameter("Thresholding").addDoubleParameter("threshold", "Cell detection threshold", 0.1, null, "Hematoxylin intensity threshold").addDoubleParameter("thresholdDAB", "DAB threshold", 0.2, null, "DAB OD threshold for positive percentage counts").addBooleanParameter("ensureMainStain", "Hematoxylin predominant", false, "Accept detection only if haematoxylin value is higher than that of the second deconvolved stain").addTitleParameter("Display").addDoubleParameter("detectionDiameter", "Detection object diameter", 25, "pixels", "Adjust the size of detection object that is created around each peak (note, this does not influence which cells are detected");
    // Magnification is deprecated!
    params.setHiddenParameters(true, "magnification");
    boolean isHDAB = imageData.isBrightfield() && imageData.getColorDeconvolutionStains().isH_DAB();
    params.setHiddenParameters(!isHDAB, "stainChannel");
    params.setHiddenParameters(isHDAB, "ensureMainStain");
    params.setHiddenParameters(!isHDAB, "thresholdDAB");
    boolean hasMicrons = imageData != null && imageData.getServer() != null && imageData.getServer().getPixelCalibration().hasPixelSizeMicrons();
    params.getParameters().get("gaussianSigmaPixels").setHidden(hasMicrons);
    params.getParameters().get("gaussianSigmaMicrons").setHidden(!hasMicrons);
    params.getParameters().get("backgroundRadiusPixels").setHidden(hasMicrons);
    params.getParameters().get("backgroundRadiusMicrons").setHidden(!hasMicrons);
    return params;
}
Also used : ParameterList(qupath.lib.plugins.parameters.ParameterList)

Example 2 with ParameterList

use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.

the class WatershedNucleiCV method getDefaultParameterList.

@Override
public ParameterList getDefaultParameterList(final ImageData<BufferedImage> imageData) {
    ParameterList params = new ParameterList();
    params.addDoubleParameter("preferredMicrons", "Preferred pixel size", 0.5, GeneralTools.micrometerSymbol(), "Preferred image resolution for detection (higher values mean lower resolution)");
    if (imageData.getServer().getPixelCalibration().hasPixelSizeMicrons()) {
        String um = GeneralTools.micrometerSymbol();
        params.addDoubleParameter("medianRadius", "Median radius", 1, um, "Median filter radius").addDoubleParameter("gaussianSigma", "Gaussian sigma", 1.5, um, "Gaussian filter sigma").addDoubleParameter("openingRadius", "Opening radius", 8, um, "Morphological opening filter radius").addDoubleParameter("threshold", "Threshold", 0.1, null, 0, 1.0, "Intensity threshold").addDoubleParameter("minArea", "Minimum area", 25, um + "^2", "Minimum area threshold");
    } else {
        params.setHiddenParameters(true, "preferredMicrons");
        params.addDoubleParameter("medianRadius", "Median radius", 1, "px", "Median filter radius").addDoubleParameter("gaussianSigma", "Gaussian sigma", 2, "px", "Gaussian filter sigma").addDoubleParameter("openingRadius", "Opening radius", 20, "px", "Morphological opening filter radius").addDoubleParameter("threshold", "Threshold", 0.1, null, 0, 1.0, "Intensity threshold").addDoubleParameter("minArea", "Minimum area", 100, "px^2", "Minimum area threshold");
    }
    params.addBooleanParameter("splitShape", "Split by shape", true);
    return params;
}
Also used : ParameterList(qupath.lib.plugins.parameters.ParameterList)

Example 3 with ParameterList

use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.

the class OpenCvClassifier method getDescription.

// @Override
// public int classifyPathObjects(Collection<PathObject> pathObjects) {
// 
// 
// int counter = 0;
// Mat samples = new Mat(1, measurements.size(), CvType.CV_32FC1);
// 
// for (PathObject pathObject : pathObjects) {
// MeasurementList measurementList = pathObject.getMeasurementList();
// int idx = 0;
// for (String m : measurements) {
// double value = measurementList.getMeasurementValue(m);
// samples.put(0, idx, value);
// idx++;
// }
// 
// float prediction = trees.predict(samples);
// 
// //			if (computeProbabilities) {
// //				double prediction = svm.svm_predict_probability(model, nodes, probabilities);
// //				int index = (int)prediction;
// //				pathObject.setPathClass(pathClasses.get(index), probabilities[index]);
// //			} else {
// //				double prediction = svm.svm_predict(model, nodes);
// pathObject.setPathClass(pathClasses.get((int)prediction));
// //			}
// counter++;
// }
// 
// return counter;
// }
@Override
public String getDescription() {
    if (classifier == null)
        return "No classifier set!";
    StringBuilder sb = new StringBuilder();
    String mainString = getName() + (!isValid() ? " (not trained)" : "");
    ;
    sb.append("Classifier:\t").append(mainString).append("\n\n");
    sb.append("Classes:\t[");
    Iterator<PathClass> iterClasses = getPathClasses().iterator();
    while (iterClasses.hasNext()) {
        sb.append(iterClasses.next());
        if (iterClasses.hasNext())
            sb.append(", ");
        else
            sb.append("]\n\n");
    }
    sb.append("Normalization:\t").append(normalization).append("\n\n");
    if (this instanceof Parameterizable) {
        ParameterList params = ((Parameterizable) this).getParameterList();
        String paramString = ParameterList.getParameterListJSON(params, "\n  ");
        sb.append("Main parameters:\n  ").append(paramString);
        sb.append("\n\n");
    }
    List<String> measurements = getRequiredMeasurements();
    sb.append("Required measurements (").append(measurements.size()).append("):\n");
    Iterator<String> iter = getRequiredMeasurements().iterator();
    while (iter.hasNext()) {
        sb.append("    ");
        sb.append(iter.next());
        sb.append("\n");
    }
    return sb.toString();
// return getName() + (!isValid() ? " (not trained)" : "");
}
Also used : PathClass(qupath.lib.objects.classes.PathClass) Parameterizable(qupath.lib.plugins.parameters.Parameterizable) ParameterList(qupath.lib.plugins.parameters.ParameterList)

Example 4 with ParameterList

use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.

the class RTreesClassifier method createClassifier.

@Override
protected RTrees createClassifier() {
    RTrees trees = RTrees.create();
    ParameterList params = getParameterList();
    if (params != null) {
        int maxDepth = params.getIntParameterValue("maxDepth");
        int minSamples = params.getIntParameterValue("minSamples");
        boolean use1SE = params.getBooleanParameterValue("use1SE");
        trees.setMaxDepth(maxDepth == 0 ? Integer.MAX_VALUE : maxDepth);
        trees.setMinSampleCount(minSamples);
        trees.setUse1SERule(use1SE);
        // setUseSurrogates should help with missing data... but it appears not actually to be implemented
        // System.out.println("DEFAULT SURROGATES: " + trees.getUseSurrogates());
        // trees.setUseSurrogates(true);
        // Set termination criteria
        int termCritMaxTrees = params.getIntParameterValue("termCritMaxTrees");
        double termCritEPS = params.getDoubleParameterValue("termCritEPS");
        termCriteria = createTerminationCriteria(termCritMaxTrees, termCritEPS);
        if (termCriteria != null)
            trees.setTermCriteria(termCriteria);
        else
            termCriteria = trees.getTermCriteria();
        logger.info("RTrees classifier termination criteria: {}", termCriteria);
    }
    return trees;
}
Also used : RTrees(org.bytedeco.opencv.opencv_ml.RTrees) ParameterList(qupath.lib.plugins.parameters.ParameterList)

Example 5 with ParameterList

use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.

the class DelaunayClusteringPlugin method getDefaultParameterList.

@Override
public ParameterList getDefaultParameterList(ImageData<T> imageData) {
    ParameterList params = new ParameterList().addDoubleParameter("distanceThreshold", "Distance threshold", 0, "pixels", "Distance threshold - edges longer than this will be omitted").addDoubleParameter("distanceThresholdMicrons", "Distance threshold", 0, GeneralTools.micrometerSymbol(), "Distance threshold - edges longer than this will be omitted").addBooleanParameter("limitByClass", "Limit edges to same class", false, "Prevent edges linking objects with different base classifications").addBooleanParameter("addClusterMeasurements", "Add cluster measurements", false, "Add measurements derived from clustering connected objects");
    ImageServer<?> server = imageData.getServer();
    boolean hasMicrons = server != null && server.getPixelCalibration().hasPixelSizeMicrons();
    params.setHiddenParameters(hasMicrons, "distanceThreshold");
    params.setHiddenParameters(!hasMicrons, "distanceThresholdMicrons");
    return params;
}
Also used : ParameterList(qupath.lib.plugins.parameters.ParameterList)

Aggregations

ParameterList (qupath.lib.plugins.parameters.ParameterList)53 BufferedImage (java.awt.image.BufferedImage)15 ArrayList (java.util.ArrayList)13 IOException (java.io.IOException)11 List (java.util.List)9 Collectors (java.util.stream.Collectors)8 BorderPane (javafx.scene.layout.BorderPane)8 PathObject (qupath.lib.objects.PathObject)8 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 GeneralTools (qupath.lib.common.GeneralTools)7 Dialogs (qupath.lib.gui.dialogs.Dialogs)7 ImageServer (qupath.lib.images.servers.ImageServer)7 Insets (javafx.geometry.Insets)6 Tooltip (javafx.scene.control.Tooltip)6 Collection (java.util.Collection)5 Map (java.util.Map)5 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)5 ContextMenu (javafx.scene.control.ContextMenu)5 Label (javafx.scene.control.Label)5