Search in sources :

Example 1 with DensityMapType

use of qupath.lib.analysis.heatmaps.DensityMaps.DensityMapType in project qupath by qupath.

the class DensityMapDialog method buildAllObjectsPane.

private Pane buildAllObjectsPane(ObservableDensityMapBuilder params) {
    ComboBox<DensityMapObjects> comboObjectType = new ComboBox<>();
    comboObjectType.getItems().setAll(DensityMapObjects.values());
    comboObjectType.getSelectionModel().select(DensityMapObjects.DETECTIONS);
    params.allObjectTypes.bind(comboObjectType.getSelectionModel().selectedItemProperty());
    ComboBox<PathClass> comboAllObjects = new ComboBox<>(createObservablePathClassList(DensityMapUI.ANY_CLASS));
    comboAllObjects.setButtonCell(GuiTools.createCustomListCell(p -> classificationText(p)));
    comboAllObjects.setCellFactory(c -> GuiTools.createCustomListCell(p -> classificationText(p)));
    params.allObjectClass.bind(comboAllObjects.getSelectionModel().selectedItemProperty());
    comboAllObjects.getSelectionModel().selectFirst();
    ComboBox<PathClass> comboPrimary = new ComboBox<>(createObservablePathClassList(DensityMapUI.ANY_CLASS, DensityMapUI.ANY_POSITIVE_CLASS));
    comboPrimary.setButtonCell(GuiTools.createCustomListCell(p -> classificationText(p)));
    comboPrimary.setCellFactory(c -> GuiTools.createCustomListCell(p -> classificationText(p)));
    params.densityObjectClass.bind(comboPrimary.getSelectionModel().selectedItemProperty());
    comboPrimary.getSelectionModel().selectFirst();
    ComboBox<DensityMapType> comboDensityType = new ComboBox<>();
    comboDensityType.getItems().setAll(DensityMapType.values());
    comboDensityType.getSelectionModel().select(DensityMapType.SUM);
    params.densityType.bind(comboDensityType.getSelectionModel().selectedItemProperty());
    var pane = createGridPane();
    int row = 0;
    var labelObjects = createTitleLabel("Choose all objects to include");
    PaneTools.addGridRow(pane, row++, 0, null, labelObjects, labelObjects, labelObjects);
    PaneTools.addGridRow(pane, row++, 0, "Select objects used to generate the density map.\n" + "Use 'All detections' to include all detection objects (including cells and tiles).\n" + "Use 'All cells' to include cell objects only.\n" + "Use 'Point annotations' to use annotated points rather than detections.", new Label("Object type"), comboObjectType, comboObjectType);
    PaneTools.addGridRow(pane, row++, 0, "Select object classifications to include.\n" + "Use this to filter out detections that should not contribute to the density map at all.\n" + "For example, this can be used to selectively consider tumor cells and ignore everything else.\n" + "If used in combination with 'Secondary class' and 'Density type: Objects %', the 'Secondary class' defines the numerator and the 'Main class' defines the denominator.", new Label("Main class"), comboAllObjects, comboAllObjects);
    var labelDensities = createTitleLabel("Define density map");
    PaneTools.addGridRow(pane, row++, 0, null, labelDensities);
    PaneTools.addGridRow(pane, row++, 0, "Calculate the density of objects containing a specified classification.\n" + "If used in combination with 'Main class' and 'Density type: Objects %', the 'Secondary class' defines the numerator and the 'Main class' defines the denominator.\n" + "For example, choose 'Main class: Tumor', 'Secondary class: Positive' and 'Density type: Objects %' to define density as the proportion of tumor cells that are positive.", new Label("Secondary class"), comboPrimary, comboPrimary);
    PaneTools.addGridRow(pane, row++, 0, "Select method of normalizing densities.\n" + "Choose whether to show raw counts, or normalize densities by area or the number of objects locally.\n" + "This can be used to distinguish between the total number of objects in an area with a given classification, " + "and the proportion of objects within the area with that classification.\n" + "Gaussian weighting gives a smoother result, but it can be harder to interpret.", new Label("Density type"), comboDensityType, comboDensityType);
    var sliderRadius = new Slider(0, 1000, params.radius.get());
    sliderRadius.valueProperty().bindBidirectional(params.radius);
    initializeSliderSnapping(sliderRadius, 50, 1, 0.1);
    var tfRadius = createTextField();
    boolean expandSliderLimits = true;
    GuiTools.bindSliderAndTextField(sliderRadius, tfRadius, expandSliderLimits, 2);
    GuiTools.installRangePrompt(sliderRadius);
    PaneTools.addGridRow(pane, row++, 0, "Select smoothing radius used to calculate densities.\n" + "This is defined in calibrated pixel units (e.g. " + GeneralTools.micrometerSymbol() + " if available).", new Label("Density radius"), sliderRadius, tfRadius);
    PaneTools.setToExpandGridPaneWidth(comboObjectType, comboPrimary, comboAllObjects, comboDensityType, sliderRadius);
    return pane;
}
Also used : Change(javafx.collections.ListChangeListener.Change) ImageServer(qupath.lib.images.servers.ImageServer) LoggerFactory(org.slf4j.LoggerFactory) PixelClassificationOverlay(qupath.lib.gui.viewer.overlays.PixelClassificationOverlay) MinMax(qupath.process.gui.commands.density.DensityMapUI.MinMax) Future(java.util.concurrent.Future) ComboBox(javafx.scene.control.ComboBox) ColorModelRenderer(qupath.lib.gui.images.stores.ColorModelRenderer) PathObjectHierarchyEvent(qupath.lib.objects.hierarchy.events.PathObjectHierarchyEvent) Gson(com.google.gson.Gson) Map(java.util.Map) QuPathGUI(qupath.lib.gui.QuPathGUI) Pane(javafx.scene.layout.Pane) Shape(java.awt.Shape) TextField(javafx.scene.control.TextField) BufferedImage(java.awt.image.BufferedImage) ColorMap(qupath.lib.color.ColorMaps.ColorMap) DensityMapBuilder(qupath.lib.analysis.heatmaps.DensityMaps.DensityMapBuilder) Set(java.util.Set) Spinner(javafx.scene.control.Spinner) QuPathViewerListener(qupath.lib.gui.viewer.QuPathViewerListener) Executors(java.util.concurrent.Executors) PathObject(qupath.lib.objects.PathObject) Objects(java.util.Objects) Platform(javafx.application.Platform) QuPathViewer(qupath.lib.gui.viewer.QuPathViewer) List(java.util.List) BooleanProperty(javafx.beans.property.BooleanProperty) ColorModels(qupath.lib.analysis.heatmaps.ColorModels) ToggleButton(javafx.scene.control.ToggleButton) GuiTools(qupath.lib.gui.tools.GuiTools) DensityMaps(qupath.lib.analysis.heatmaps.DensityMaps) PathObjectPredicates(qupath.lib.objects.PathObjectPredicates) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) ColorModelBuilder(qupath.lib.analysis.heatmaps.ColorModels.ColorModelBuilder) ThreadTools(qupath.lib.common.ThreadTools) ObservableList(javafx.collections.ObservableList) ColorMaps(qupath.lib.color.ColorMaps) Scene(javafx.scene.Scene) ObjectExpression(javafx.beans.binding.ObjectExpression) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) GsonTools(qupath.lib.io.GsonTools) FXCollections(javafx.collections.FXCollections) DensityMapObjects(qupath.process.gui.commands.density.DensityMapUI.DensityMapObjects) HashMap(java.util.HashMap) DoubleProperty(javafx.beans.property.DoubleProperty) PathClassFactory(qupath.lib.objects.classes.PathClassFactory) ImageRenderer(qupath.lib.gui.images.stores.ImageRenderer) Bindings(javafx.beans.binding.Bindings) HashSet(java.util.HashSet) Insets(javafx.geometry.Insets) Slider(javafx.scene.control.Slider) DensityMapType(qupath.lib.analysis.heatmaps.DensityMaps.DensityMapType) ImageInterpolation(qupath.lib.gui.viewer.ImageInterpolation) LinkedHashSet(java.util.LinkedHashSet) ExecutorService(java.util.concurrent.ExecutorService) GridPane(javafx.scene.layout.GridPane) ImageData(qupath.lib.images.ImageData) ObjectProperty(javafx.beans.property.ObjectProperty) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) TitledPane(javafx.scene.control.TitledPane) GeneralTools(qupath.lib.common.GeneralTools) PathClass(qupath.lib.objects.classes.PathClass) IOException(java.io.IOException) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ColorModel(java.awt.image.ColorModel) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ObservableValue(javafx.beans.value.ObservableValue) PathObjectPredicate(qupath.lib.objects.PathObjectPredicates.PathObjectPredicate) PathObjectHierarchyListener(qupath.lib.objects.hierarchy.events.PathObjectHierarchyListener) Collections(java.util.Collections) PaneTools(qupath.lib.gui.tools.PaneTools) Slider(javafx.scene.control.Slider) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) PathClass(qupath.lib.objects.classes.PathClass) DensityMapType(qupath.lib.analysis.heatmaps.DensityMaps.DensityMapType) DensityMapObjects(qupath.process.gui.commands.density.DensityMapUI.DensityMapObjects)

Aggregations

Gson (com.google.gson.Gson)1 Shape (java.awt.Shape)1 BufferedImage (java.awt.image.BufferedImage)1 ColorModel (java.awt.image.ColorModel)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 Platform (javafx.application.Platform)1 Bindings (javafx.beans.binding.Bindings)1 ObjectExpression (javafx.beans.binding.ObjectExpression)1 BooleanProperty (javafx.beans.property.BooleanProperty)1