use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.
the class ImageDetailsPane method promptToSetPixelSize.
static boolean promptToSetPixelSize(ImageData<BufferedImage> imageData, boolean requestZSpacing) {
var server = imageData.getServer();
var hierarchy = imageData.getHierarchy();
var selected = hierarchy.getSelectionModel().getSelectedObject();
var roi = selected == null ? null : selected.getROI();
PixelCalibration cal = server.getPixelCalibration();
double pixelWidthMicrons = cal.getPixelWidthMicrons();
double pixelHeightMicrons = cal.getPixelHeightMicrons();
double zSpacingMicrons = cal.getZSpacingMicrons();
// Use line or area ROI if possible
if (!requestZSpacing && roi != null && !roi.isEmpty() && (roi.isArea() || roi.isLine())) {
boolean setPixelHeight = true;
boolean setPixelWidth = true;
String message;
String units = GeneralTools.micrometerSymbol();
double pixelWidth = cal.getPixelWidthMicrons();
double pixelHeight = cal.getPixelHeightMicrons();
if (!Double.isFinite(pixelWidth))
pixelWidth = 1;
if (!Double.isFinite(pixelHeight))
pixelHeight = 1;
Double defaultValue = null;
if (roi.isLine()) {
setPixelHeight = roi.getBoundsHeight() != 0;
setPixelWidth = roi.getBoundsWidth() != 0;
message = "Enter selected line length";
defaultValue = roi.getScaledLength(pixelWidth, pixelHeight);
} else {
message = "Enter selected ROI area";
units = units + "^2";
defaultValue = roi.getScaledArea(pixelWidth, pixelHeight);
}
// }
if (Double.isNaN(defaultValue))
defaultValue = 1.0;
var params = new ParameterList().addDoubleParameter("inputValue", message, defaultValue, units, "Enter calibrated value in " + units + " for the selected ROI to calculate the pixel size").addBooleanParameter("squarePixels", "Assume square pixels", true, "Set the pixel width to match the pixel height");
params.setHiddenParameters(setPixelHeight && setPixelWidth, "squarePixels");
if (!Dialogs.showParameterDialog("Set pixel size", params))
return false;
Double result = params.getDoubleParameterValue("inputValue");
setPixelHeight = setPixelHeight || params.getBooleanParameterValue("squarePixels");
setPixelWidth = setPixelWidth || params.getBooleanParameterValue("squarePixels");
// Double result = Dialogs.showInputDialog("Set pixel size", message, defaultValue);
// if (result == null)
// return false;
double sizeMicrons;
if (roi.isLine())
sizeMicrons = result.doubleValue() / roi.getLength();
else
sizeMicrons = Math.sqrt(result.doubleValue() / roi.getArea());
if (setPixelHeight)
pixelHeightMicrons = sizeMicrons;
if (setPixelWidth)
pixelWidthMicrons = sizeMicrons;
} else {
// Prompt for all required values
ParameterList params = new ParameterList().addDoubleParameter("pixelWidth", "Pixel width", pixelWidthMicrons, GeneralTools.micrometerSymbol(), "Enter the pixel width").addDoubleParameter("pixelHeight", "Pixel height", pixelHeightMicrons, GeneralTools.micrometerSymbol(), "Entry the pixel height").addDoubleParameter("zSpacing", "Z-spacing", zSpacingMicrons, GeneralTools.micrometerSymbol(), "Enter the spacing between slices of a z-stack");
params.setHiddenParameters(server.nZSlices() == 1, "zSpacing");
if (!Dialogs.showParameterDialog("Set pixel size", params))
return false;
if (server.nZSlices() != 1) {
zSpacingMicrons = params.getDoubleParameterValue("zSpacing");
}
pixelWidthMicrons = params.getDoubleParameterValue("pixelWidth");
pixelHeightMicrons = params.getDoubleParameterValue("pixelHeight");
}
if ((pixelWidthMicrons <= 0 || pixelHeightMicrons <= 0) || (server.nZSlices() > 1 && zSpacingMicrons <= 0)) {
if (!Dialogs.showConfirmDialog("Set pixel size", "You entered values <= 0, do you really want to remove this pixel calibration information?")) {
return false;
}
zSpacingMicrons = server.nZSlices() > 1 && zSpacingMicrons > 0 ? zSpacingMicrons : Double.NaN;
if (pixelWidthMicrons <= 0 || pixelHeightMicrons <= 0) {
pixelWidthMicrons = Double.NaN;
pixelHeightMicrons = Double.NaN;
}
}
if (QP.setPixelSizeMicrons(imageData, pixelWidthMicrons, pixelHeightMicrons, zSpacingMicrons)) {
// Log for scripts
WorkflowStep step;
if (server.nZSlices() == 1) {
var map = Map.of("pixelWidthMicrons", pixelWidthMicrons, "pixelHeightMicrons", pixelHeightMicrons);
String script = String.format("setPixelSizeMicrons(%f, %f)", pixelWidthMicrons, pixelHeightMicrons);
step = new DefaultScriptableWorkflowStep("Set pixel size " + GeneralTools.micrometerSymbol(), map, script);
} else {
var map = Map.of("pixelWidthMicrons", pixelWidthMicrons, "pixelHeightMicrons", pixelHeightMicrons, "zSpacingMicrons", zSpacingMicrons);
String script = String.format("setPixelSizeMicrons(%f, %f, %f)", pixelWidthMicrons, pixelHeightMicrons, zSpacingMicrons);
step = new DefaultScriptableWorkflowStep("Set pixel size " + GeneralTools.micrometerSymbol(), map, script);
}
imageData.getHistoryWorkflow().addStep(step);
return true;
} else
return false;
}
use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.
the class ParameterPanelFX method demoParameterPanel.
static void demoParameterPanel() {
new JFXPanel();
if (!Platform.isFxApplicationThread()) {
Platform.runLater(() -> demoParameterPanel());
return;
}
Stage frame = new Stage();
frame.setTitle("Testing parameter panel");
int k = 0;
final ParameterList params = new ParameterList().addTitleParameter("Parameter list").addEmptyParameter("Here is a list of parameters that I am testing out").addIntParameter(Integer.toString(k++), "Enter an int", 5, "px", "Unbounded int").addDoubleParameter(Integer.toString(k++), "Enter a double", 5.2, "microns", "Unbounded double").addDoubleParameter(Integer.toString(k++), "Enter a double in range", 5.2, null, 1, 10, "Bounded double").addIntParameter(Integer.toString(k++), "Enter an int in range", 5, null, 1, 10, "Bounded int").addStringParameter(Integer.toString(k++), "Enter a string", "Default here").addChoiceParameter(Integer.toString(k++), "Choose a choice", "Two", Arrays.asList("One", "Two", "Three"), "Simple choice").addChoiceParameter(Integer.toString(k++), "Choose a number choice", Integer.valueOf(2), Arrays.asList(1, 2, 3), "Numeric choice").addBooleanParameter(Integer.toString(k++), "Check me out", true);
BorderPane borderPane = new BorderPane();
ParameterPanelFX panel = new ParameterPanelFX(params);
final TextArea textArea = new TextArea();
for (Parameter<?> p : params.getParameters().values()) {
textArea.setText(textArea.getText() + (p + "\n"));
}
panel.addParameterChangeListener(new ParameterChangeListener() {
@Override
public void parameterChanged(ParameterList params, String key, boolean isAdjusting) {
textArea.setText("");
for (Parameter<?> p : params.getParameters().values()) textArea.setText(textArea.getText() + (p + "\n"));
}
});
borderPane.setCenter(panel.getPane());
borderPane.setBottom(textArea);
frame.setScene(new Scene(borderPane));
frame.show();
}
use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.
the class ViewTrackerAnalysisCommand method run.
@Override
public void run() {
if (dialog == null) {
dialog = new Stage();
dialog.sizeToScene();
dialog.initOwner(qupath.getStage());
dialog.setTitle("Recording analysis");
currentFrame.set(tracker.getFrame(0));
int nCols = nCols(tracker);
for (int i = 0; i < nCols; i++) {
final int col = i;
final String columnName = getColumnName(tracker, col);
TableColumn<ViewRecordingFrame, Object> column = new TableColumn<>(columnName);
column.setCellValueFactory(new Callback<CellDataFeatures<ViewRecordingFrame, Object>, ObservableValue<Object>>() {
@Override
public ObservableValue<Object> call(CellDataFeatures<ViewRecordingFrame, Object> frame) {
return new SimpleObjectProperty<>(getColumnValue(frame.getValue(), columnName));
}
});
table.getColumns().add(column);
}
table.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
table.getSelectionModel().selectedItemProperty().addListener((v, o, frame) -> {
if (frame != null)
currentFrame.set(frame);
});
refreshTracker();
playback.getCurrentFrame().addListener((v, o, frame) -> currentFrame.set(frame));
currentFrame.addListener((v, o, frame) -> {
if (frame == null)
return;
// Set viewer for frame
ViewTrackerPlayback.setViewerForFrame(viewer, frame);
// Set slide overview for frame
slideOverview.setVisibleShape(frame);
zSlider.setValue(frame.getZ());
tSlider.setValue(frame.getT());
timeSlider.setValue(frame.getTimestamp());
slideOverview.paintCanvas(o.getZ() != frame.getZ() || o.getT() != frame.getT(), false);
});
mainPane = new SplitPane();
mainPane.setDividerPositions(1.0);
BorderPane tablePane = new BorderPane();
tablePane.setCenter(table);
// ----------------------------------------------------------------------//
// ----------------- SLIDE OVERVIEW (TOP LEFT)------------------//
// ----------------------------------------------------------------------//
int z = server.getMetadata().getSizeZ();
int t = server.getMetadata().getSizeT();
tSlider = new Slider(0, t - 1, 0);
tSlider.setBlockIncrement(1);
tSlider.setValue(viewer.getTPosition());
tSlider.valueProperty().addListener((v, o, n) -> {
tSlider.setValue(n.intValue());
viewer.setTPosition(n.intValue());
slideOverview.paintCanvas();
});
zSlider = new Slider(0, z - 1, 0);
zSlider.setBlockIncrement(1);
zSlider.setMinorTickCount(0);
zSlider.setMajorTickUnit(1);
zSlider.setShowTickMarks(true);
zSlider.setValue(viewer.getZPosition());
zSlider.valueProperty().addListener((v, o, n) -> {
zSlider.setValue(n.intValue());
viewer.setZPosition(n.intValue());
slideOverview.paintCanvas();
});
zSlider.setOrientation(Orientation.VERTICAL);
var timeSliderLength = tracker.getLastTime() - tracker.getStartTime();
timeSlider = new Slider(0L, timeSliderLength, 0L);
timeSlider.setMinWidth(250.0);
if (timeSliderLength > 0) {
timeSlider.setMajorTickUnit(timeSliderLength / 4);
timeSlider.setMinorTickCount(0);
timeSlider.setShowTickMarks(true);
}
timeSlider.valueProperty().addListener((v, o, n) -> {
var frame = tracker.getFrameForTime(n.longValue());
currentFrame.set(frame);
if (table.getSelectionModel().getSelectedItem() != frame)
table.getSelectionModel().select(frame);
});
timeSlider.setOnMouseClicked(e -> {
playback.doStopPlayback();
});
long startTime = tracker.getStartTime();
long endTime = tracker.getLastTime();
Label timepointLabel = new Label();
timepointLabel.textProperty().bind(Bindings.createStringBinding(() -> "t=" + GeneralTools.formatNumber(tSlider.getValue(), 2), tSlider.valueProperty()));
Label zSliceLabel = new Label();
zSliceLabel.textProperty().bind(Bindings.createStringBinding(() -> "z=" + GeneralTools.formatNumber(zSlider.getValue(), 2), zSlider.valueProperty()));
Label timeLabelLeft = new Label();
timeLabelLeft.textProperty().bind(Bindings.createStringBinding(() -> ViewTrackerTools.getPrettyTimestamp(startTime, (long) timeSlider.getValue() + startTime), timeSlider.valueProperty()));
Label timeLabelRight = new Label();
timeLabelRight.textProperty().bind(Bindings.createStringBinding(() -> "-" + ViewTrackerTools.getPrettyTimestamp((long) timeSlider.getValue() + startTime, endTime), timeSlider.valueProperty()));
if (t == 1) {
tSlider.setVisible(false);
timepointLabel.setVisible(false);
}
if (z == 1) {
zSlider.setVisible(false);
zSliceLabel.setVisible(false);
}
Button btnPlay = new Button();
btnPlay.setGraphic(iconPlay);
btnPlay.setOnAction(e -> {
if (!playback.isPlaying()) {
// If it's not playing already, start playing
playback.setFirstFrame(currentFrame.get());
// Set the right slide overview image plane and visible shape for current frame
slideOverview.paintCanvas();
playback.doStartPlayback();
} else {
// If already playing, pause the playback where it currently is
playback.doStopPlayback();
}
});
Button btnStop = new Button();
btnStop.setGraphic(iconStop);
btnStop.setOnAction(e -> {
playback.doStopPlayback();
timeSlider.setValue(tracker.getFrame(0).getTimestamp());
});
// If we have a total of 0 or 1 frame in recording, disable playback
btnPlay.disableProperty().bind(new SimpleBooleanProperty(tracker.nFrames() <= 1));
btnStop.disableProperty().bind(new SimpleBooleanProperty(tracker.nFrames() <= 1));
playback.playingProperty().addListener((v, o, n) -> {
if (n) {
btnPlay.setGraphic(iconPause);
// btnPlay.setText("Pause");
zSlider.setDisable(true);
tSlider.setDisable(true);
} else {
btnPlay.setGraphic(iconPlay);
// btnPlay.setText("Play");
zSlider.setDisable(false);
tSlider.setDisable(false);
}
});
// --------------------------------------------------------------//
// ----------- DATA VISUALIZATION PANE ---------------//
// --------------------------------------------------------------//
visualizationCheckBox = new CheckBox("Enable data overlay");
// Label normalizedByLabel = new Label("Normalized by");
// Bound below in the Binding section
progressIndicator = new ProgressIndicator();
progressIndicator.setPrefSize(15, 15);
// ToggleGroup toggleGroup = new ToggleGroup();
// timeNormalizedRadio = new RadioButton("Time");
// timeNormalizedRadio.setSelected(true);
// timeNormalizedRadio.setToggleGroup(toggleGroup);
//
// downsampleNormalizedRadio = new RadioButton("Downsample");
// downsampleNormalizedRadio.setToggleGroup(toggleGroup);
// Create a color mapper ComboBox
colorMaps = FXCollections.observableArrayList(ColorMaps.getColorMaps().values());
ComboBox<ColorMap> colorMapCombo = new ComboBox<>(colorMaps);
colorMapCombo.setMinWidth(350);
colorMapCanvas = new ColorMapCanvas(10, colorMaps.get(0));
colorMapCombo.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> colorMapCanvas.setColorMap(n));
if (colorMapCombo.getSelectionModel().isEmpty() && !colorMapCombo.getItems().isEmpty())
colorMapCombo.getSelectionModel().selectFirst();
colorMapCombo.setTooltip(new Tooltip("Select color map"));
// ------------------ TIME DISPLAYED RANGESLIDER ------------------//
Label timeDisplayedLeftLabel = new Label();
Label timeDisplayedRightLabel = new Label();
timeDisplayedSlider = new RangeSlider(0, timeSliderLength, 0, timeSliderLength);
timeDisplayedSlider.setMinWidth(250.0);
// Prompt input from user (min time)
timeDisplayedLeftLabel.setOnMouseClicked(e -> {
if (e.getButton().equals(MouseButton.PRIMARY) && e.getClickCount() == 2) {
GridPane gp = new GridPane();
TextField tf = new TextField();
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
try {
tf.setTextFormatter(new TextFormatter<>(new DateTimeStringConverter(format), format.parse("00:00:00")));
} catch (ParseException ex) {
logger.error("Error parsing the input time: ", ex.getLocalizedMessage());
}
gp.addRow(0, new Label("Enter time"), tf);
var response = Dialogs.showConfirmDialog("Set min time", gp);
if (response) {
long time = TimeUnit.HOURS.toMillis(Integer.parseInt(tf.getText(0, 2))) + TimeUnit.MINUTES.toMillis(Integer.parseInt(tf.getText(3, 5))) + TimeUnit.SECONDS.toMillis(Integer.parseInt(tf.getText(6, 8)));
timeDisplayedSlider.setLowValue(time);
updateOverlays();
}
}
});
// Prompt input from user (max time)
timeDisplayedRightLabel.setOnMouseClicked(e -> {
if (e.getButton().equals(MouseButton.PRIMARY) && e.getClickCount() == 2) {
GridPane gp = new GridPane();
TextField tf = new TextField();
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
try {
tf.setTextFormatter(new TextFormatter<>(new DateTimeStringConverter(format), format.parse(ViewTrackerTools.getPrettyTimestamp((long) timeDisplayedSlider.getHighValue()))));
} catch (ParseException ex) {
logger.error("Error parsing the input time: ", ex.getLocalizedMessage());
}
gp.addRow(0, new Label("Enter time"), tf);
var response = Dialogs.showConfirmDialog("Set max time", gp);
if (response) {
long time = ViewTrackerTools.getTimestampFromPrettyString(tf.getText());
timeDisplayedSlider.setHighValue(time);
updateOverlays();
}
}
});
timeDisplayedLeftLabel.textProperty().bind(Bindings.createStringBinding(() -> ViewTrackerTools.getPrettyTimestamp(startTime, (long) timeDisplayedSlider.getLowValue() + startTime), timeDisplayedSlider.lowValueProperty()));
timeDisplayedRightLabel.textProperty().bind(Bindings.createStringBinding(() -> ViewTrackerTools.getPrettyTimestamp(startTime, (long) timeDisplayedSlider.getHighValue() + startTime), timeDisplayedSlider.highValueProperty()));
// ------------------ DOWNSAMPLE RANGESLIDER ------------------//
List<Double> allFramesDownsamples = tracker.getAllFrames().stream().map(e -> e.getDownsampleFactor()).collect(Collectors.toList());
var minDownsample = allFramesDownsamples.stream().min(Comparator.naturalOrder()).get();
var maxDownsample = allFramesDownsamples.stream().max(Comparator.naturalOrder()).get();
downsampleSlider = new RangeSlider(minDownsample, maxDownsample, minDownsample, maxDownsample);
Label downsampleLeftLabel = new Label();
Label downsampleRightLabel = new Label();
// Prompt input from user (min downsample)
downsampleLeftLabel.setOnMouseClicked(e -> {
if (e.getButton().equals(MouseButton.PRIMARY) && e.getClickCount() == 2) {
ParameterList params = new ParameterList();
params.addDoubleParameter("downsampleFilterLow", "Enter downsample", downsampleSlider.getLowValue());
if (!Dialogs.showParameterDialog("Set min downsample", params))
return;
double downFactor = params.getDoubleParameterValue("downsampleFilterLow");
downsampleSlider.setLowValue(downFactor);
updateOverlays();
}
});
// Prompt input from user (max downsample)
downsampleRightLabel.setOnMouseClicked(e -> {
if (e.getButton().equals(MouseButton.PRIMARY) && e.getClickCount() == 2) {
ParameterList params = new ParameterList();
params.addDoubleParameter("downsampleFilterHigh", "Enter downsample", downsampleSlider.getHighValue());
if (!Dialogs.showParameterDialog("Set max downsample", params))
return;
double downFactor = params.getDoubleParameterValue("downsampleFilterHigh");
downsampleSlider.setHighValue(downFactor);
updateOverlays();
}
});
downsampleLeftLabel.textProperty().bind(Bindings.createStringBinding(() -> GeneralTools.formatNumber(downsampleSlider.getLowValue(), 2), downsampleSlider.lowValueProperty()));
downsampleRightLabel.textProperty().bind(Bindings.createStringBinding(() -> GeneralTools.formatNumber(downsampleSlider.getHighValue(), 2), downsampleSlider.highValueProperty()));
// TODO: if using keys to change sliders, nothing will trigger the overlay update
dataMaps = new ViewTrackerDataMaps(server, tracker);
timeDisplayedSlider.setOnMouseReleased(v -> updateOverlays());
downsampleSlider.setOnMouseReleased(v -> updateOverlays());
colorMapCanvas.colorMapProperty().addListener((v, o, n) -> updateOverlays());
progressIndicator.visibleProperty().bind(dataMaps.generatingOverlayProperty());
visualizationCheckBox.selectedProperty().addListener((v, o, n) -> {
if (n)
updateOverlays();
else {
viewer.getCustomOverlayLayers().clear();
slideOverview.setOverlay(null);
}
});
// timeNormalizedRadio.selectedProperty().addListener((v, o, n) -> updateOverlays());
// --------------------------------------------------------------//
// ---------- PUTTING EVERYTHING TOGETHER ---------//
// --------------------------------------------------------------//
GridPane mainLeftPane = new GridPane();
GridPane slideOverviewPane = new GridPane();
GridPane dataVisualizationPane = new GridPane();
mainLeftPane.setPadding(new Insets(5.0, 5.0, 5.0, 15.0));
slideOverviewPane.setPadding(new Insets(5.0, 5.0, 5.0, 5.0));
dataVisualizationPane.setPadding(new Insets(5.0, 5.0, 15.0, 5.0));
mainLeftPane.addRow(0, slideOverviewPane);
mainLeftPane.addRow(1, dataVisualizationPane);
GridPane canvasPane = new GridPane();
GridPane timelinePane = new GridPane();
GridPane playbackPane = new GridPane();
// GridPane normalizedByPane = new GridPane();
GridPane rangeSlidersPane = new GridPane();
GridPane downsamplePane = new GridPane();
Separator sep = new Separator();
slideOverviewPane.setHgap(10);
slideOverviewPane.setVgap(10);
dataVisualizationPane.setHgap(10);
dataVisualizationPane.setVgap(10);
playbackPane.setHgap(10.0);
// normalizedByPane.setHgap(10.0);
rangeSlidersPane.setHgap(10.0);
rangeSlidersPane.setVgap(10.0);
downsamplePane.setHgap(10.0);
// Some 'invisible' elements might shift the canvas to the right, so make sure this doesn't happen
if (zSlider.isVisible()) {
canvasPane.addRow(0, new HBox(), timepointLabel, tSlider);
canvasPane.addRow(1, zSliceLabel, zSlider, slideOverview.getCanvas());
zSlider.setTooltip(new Tooltip("Slide to change the visible z-slice"));
} else {
canvasPane.addRow(0, timepointLabel, tSlider, new HBox());
canvasPane.addRow(1, new HBox(), slideOverview.getCanvas());
}
if (tSlider.isVisible())
tSlider.setTooltip(new Tooltip("Slide to change the visible timepoint"));
// normalizedByPane.addRow(0, timeNormalizedRadio, downsampleNormalizedRadio, progressIndicator);
// normalizedByPane.addRow(0, progressIndicator);
timelinePane.addRow(0, timeLabelLeft, timeSlider, timeLabelRight);
playbackPane.addRow(0, btnPlay, btnStop);
timelinePane.setAlignment(Pos.CENTER);
playbackPane.setAlignment(Pos.CENTER);
canvasPane.setAlignment(Pos.CENTER);
btnPlay.setTooltip(new Tooltip("Play the recording"));
btnStop.setTooltip(new Tooltip("Rewind the recording"));
int row = 0;
PaneTools.addGridRow(slideOverviewPane, row++, 0, null, new HBox(), canvasPane);
PaneTools.addGridRow(slideOverviewPane, row++, 0, null, timeLabelLeft, timeSlider, timeLabelRight);
PaneTools.addGridRow(slideOverviewPane, row++, 0, "Playback options", new HBox(), playbackPane);
PaneTools.addGridRow(slideOverviewPane, row++, 0, null, sep, sep, sep, sep);
row = 0;
PaneTools.addGridRow(dataVisualizationPane, row++, 0, "Show the amount of time spent in each region of the image", visualizationCheckBox, progressIndicator);
PaneTools.addGridRow(dataVisualizationPane, row++, 0, "The data will only take into account the values recorded in-between this range", new Label("Time range"), timeDisplayedLeftLabel, timeDisplayedSlider, timeDisplayedRightLabel);
PaneTools.addGridRow(dataVisualizationPane, row++, 0, "The data will only take into account the values recorded in-between this range", new Label("Downsample range"), downsampleLeftLabel, downsampleSlider, downsampleRightLabel);
PaneTools.addGridRow(dataVisualizationPane, row++, 0, "Color map", new Label("Color map"), colorMapCombo, colorMapCombo, colorMapCombo);
PaneTools.addGridRow(dataVisualizationPane, row++, 0, null, colorMapCanvas, colorMapCanvas, colorMapCanvas, colorMapCanvas);
for (Node child : dataVisualizationPane.getChildren()) {
if (child == visualizationCheckBox)
continue;
if (child == downsampleSlider)
child.disableProperty().bind(visualizationCheckBox.selectedProperty().not().or(new SimpleBooleanProperty(minDownsample == maxDownsample)));
else
// else if (child == downsampleNormalizedRadio)
// child.disableProperty().bind(visualizationCheckBox.selectedProperty().not().or(new SimpleBooleanProperty(minDownsample == maxDownsample)));
child.disableProperty().bind(visualizationCheckBox.selectedProperty().not());
}
ColumnConstraints col1 = new ColumnConstraints();
ColumnConstraints col2 = new ColumnConstraints();
ColumnConstraints col3 = new ColumnConstraints();
ColumnConstraints col4 = new ColumnConstraints();
col2.setHgrow(Priority.ALWAYS);
slideOverviewPane.getColumnConstraints().addAll(col1, col2, col3, col4);
// --------------------- BOTTOM BUTTON PANE---------------------//
Button btnExpand = new Button("Show frames");
Button btnOpen = new Button("Open directory");
btnOpen.setDisable(tracker.getFile() == null);
List<Button> buttons = new ArrayList<>();
btnOpen.setOnAction(e -> GuiTools.browseDirectory(tracker.getFile()));
btnExpand.setOnAction(e -> {
if (btnExpand.getText().equals("Show frames")) {
dialog.setWidth(initialWidth + 700);
dialog.setResizable(true);
dialog.setMinWidth(initialWidth + 50);
dialog.setMinHeight(initialHeight);
mainLeftPane.setMinWidth(initialWidth);
mainLeftPane.setMaxWidth(initialWidth);
mainPane.getItems().add(tablePane);
mainPane.setDividerPositions(0.0);
btnExpand.setText("Hide frames");
} else {
mainPane.getItems().remove(tablePane);
btnExpand.setText("Show frames");
dialog.setWidth(initialWidth + 30);
dialog.setHeight(initialHeight);
dialog.setResizable(false);
}
});
buttons.add(btnOpen);
buttons.add(btnExpand);
GridPane panelButtons = PaneTools.createColumnGridControls(buttons.toArray(new ButtonBase[0]));
PaneTools.addGridRow(mainLeftPane, row++, 0, null, panelButtons, panelButtons, panelButtons);
mainPane.getItems().add(mainLeftPane);
dialog.setScene(new Scene(mainPane));
}
viewer.imageDataProperty().addListener((v, o, n) -> dialog.hide());
dialog.setOnHiding(e -> {
viewer.getCustomOverlayLayers().clear();
playback.doStopPlayback();
isOpenedProperty.set(false);
});
dialog.setResizable(false);
dialog.show();
initialWidth = dialog.getWidth();
initialHeight = dialog.getHeight();
}
use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.
the class DetectCytokeratinCV method getDefaultParameterList.
@Override
public ParameterList getDefaultParameterList(final ImageData<BufferedImage> imageData) {
String stain2Name = imageData.getColorDeconvolutionStains() == null ? "DAB" : imageData.getColorDeconvolutionStains().getStain(2).getName();
String stain2Prompt = stain2Name + " threshold";
ParameterList params = new ParameterList().addIntParameter("downsampleFactor", "Downsample factor", 4, "", 1, 32, "Amount to downsample image prior to detection - higher values lead to smaller images (and faster but less accurate processing)").addDoubleParameter("gaussianSigmaMicrons", "Gaussian sigma", 5, GeneralTools.micrometerSymbol(), "Gaussian filter size - higher values give a smoother (less-detailed) result").addDoubleParameter("thresholdTissue", "Tissue threshold", 0.1, "OD units", "Threshold to use for tissue detection (used to create stroma annotation) - if zero, no stroma annotation is created").addDoubleParameter("thresholdDAB", stain2Prompt, 0.25, "OD units", "Threshold to use for cytokeratin detection (used to create tumor annotation) - if zero, no tumor annotation is created").addDoubleParameter("separationDistanceMicrons", "Separation distance", 0.5, GeneralTools.micrometerSymbol(), "Approximate space to create between tumour & stroma classes when they occur side-by-side");
// params.addBooleanParameter("splitShape", "Split by shape", true);
return params;
}
use of qupath.lib.plugins.parameters.ParameterList in project qupath by qupath.
the class TileClassificationsToAnnotationsPlugin method addRunnableTasks.
@Override
protected void addRunnableTasks(final ImageData<T> imageData, final PathObject parentObject, List<Runnable> tasks) {
ParameterList params = getParameterList(imageData);
if (params.getBooleanParameterValue("clearAnnotations")) {
PathObjectHierarchy hierarchy = imageData.getHierarchy();
Collection<PathObject> annotations = PathObjectTools.getDescendantObjects(parentObject, null, PathAnnotationObject.class);
hierarchy.removeObjects(annotations, true);
}
tasks.add(new ClassificationToAnnotationRunnable(params, imageData, parentObject));
}
Aggregations