Package qupath.lib.gui.commands
Class Commands
java.lang.Object
qupath.lib.gui.commands.Commands
Helper class implementing simple 'single-method' commands for easy inclusion in the GUI.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseProject(QuPathGUI qupath) Close the current project open in theQuPathGUI.static booleancombineSelectedAnnotations(ImageData<?> imageData, RoiTools.CombineOp op) Combine the selected annotations for the specified hierarchy.static voidconvertDetectionsToPoints(ImageData<?> imageData, boolean preferNucleus) Convert detection objects to point annotations based upon their ROI centroids.static voidcopyAnnotationsToClipboard(ImageData<BufferedImage> imageData) Attempt to annotation objects to the system clipboard, if availablestatic voidCopy the selected objects and add them to the plane currently active in the viewer.static voidcopySelectedObjectsToClipboard(ImageData<BufferedImage> imageData) Attempt to copy selected objects to the system clipboard, if availablestatic voidCreate a full image annotation for the image in the specified viewer.static StagecreateLicensesWindow(QuPathGUI qupath) Create a window summarizing license information for QuPath and its third party dependencies.static StagecreateMeasurementMapDialog(QuPathGUI qupath) Create a dialog for displaying measurement maps.static StagecreateMemoryMonitorDialog(QuPathGUI qupath) Create a dialog to monitor memory usage.static StageCreate a stage to display object descriptions.static StagecreatePreferencesDialog(QuPathGUI qupath) Show a dialog to adjust QuPath preferences.static voidcreateRotateImageDialog(QuPathGUI qupath) Create a dialog for rotating the image in the current viewer (for display only).static StagecreateShowSystemInfoDialog(QuPathGUI qupath) Create a window summarizing key system information relevant for QuPath.static org.controlsfx.control.action.ActioncreateSingleStageAction(Supplier<Stage> supplier) Create a command that generates a persistent single dialog on demand.static org.controlsfx.control.action.ActioncreateSingleStageAction(Supplier<Stage> supplier, String name) Create a named command that generates a persistent single dialog on demand.static StageCreate a stage to prompt the user to specify an annotation to add.static StagecreateWorkflowDisplayDialog(QuPathGUI qupath) Create a dialog to show the workflow history for the current image data.static org.controlsfx.control.action.ActioncreateZoomCommand(QuPathGUI qupath, int zoomAmount) Create a zoom in/out command action.static voiddetectionCentroidDistances2D(ImageData<?> imageData) Compute the distance between the centroids of all detections, for all available classifications.static voiddistanceToAnnotations2D(ImageData<?> imageData, boolean signedDistances) Compute the distance between all detections and the closest annotation, for all annotation classifications.static voidduplicateSelectedAnnotations(ImageData<?> imageData) Duplicate the selected annotations.static voideditSelectedAnnotation(QuPathGUI qupath) Prompt to edit the selected annotation by translation and rotation.static voidinsertSelectedObjectsInHierarchy(ImageData<?> imageData) Insert the selected objects in the hierarchy, resolving positions accordingly.static voidlaunchTMADataViewer(QuPathGUI qupath) Open new window with the TMA data viewer.static voidmakeInverseAnnotation(ImageData<?> imageData) Make an inverse annotation for the selected objects, storing the command in the history workflow.static voidmergeSelectedAnnotations(ImageData<?> imageData) Merge the currently-selected annotations for an image, replacing them with a single new annotation.static voidpasteFromClipboard(QuPathGUI qupath, boolean addToCurrentPlane) Attempt to paste objects from the system clipboard to the current image, if available; otherwise, check for text on the clipboard and paste it into a new script editor tabstatic voidpromptToAddShapeFeatures(QuPathGUI qupath) Prompt to add shape features for selected objects.static booleanpromptToCreateProject(QuPathGUI qupath) Prompt the user to select an empty directory, and use this to create a new project and set it as active.static voidpromptToDeleteObjects(ImageData<?> imageData, Class<? extends PathObject> cls) Prompt to delete objects of a specified type, or all objects.static booleanpromptToEditClass(PathClass pathClass) Prompt to edit the name/color of a class.static voidpromptToEstimateStainVectors(ImageData<BufferedImage> imageData) Prompt to estimate stain vectors for the specified image, using any current region of interest.static voidpromptToExportImageRegion(QuPathViewer viewer, boolean renderedImage) Prompt to export the current image region selected in the viewer.static booleanpromptToOpenProject(QuPathGUI qupath) Prompt the user to open an existing project and set it as active.static booleanReset QuPath's preferences, after confirming with the user.static voidpromptToResolveHierarchy(ImageData<?> imageData) Resolve parent-child relationships within the object hierarchy.static booleanpromptToSaveImageData(QuPathGUI qupath, ImageData<BufferedImage> imageData, boolean overwriteExisting) Prompt to save the specifiedImageData.static voidpromptToSelectObjectsByClassification(QuPathGUI qupath, ImageData<?> imageData) Prompt to select objects according to their classifications.static voidpromptToSetGridLineSpacing(OverlayOptions options) Prompt to input the spacing for the grid lines optionally displayed on viewers.static voidpromptToSimplifySelectedAnnotations(ImageData<?> imageData, double altitudeThreshold) Show a prompt to selected annotations in a hierarchy.static voidrefreshObjectIDs(ImageData<?> imageData, boolean duplicatesOnly) Refresh object IDs to ensure uniqueness.static voidreloadImageData(QuPathGUI qupath, ImageData<BufferedImage> imageData) Reload the specified image data from a previously saved version,if available.static voidremoveOnImageBounds(ImageData<?> imageData) Delete all objects touching the image boundary.static FilerequestUserDirectory(boolean promptIfMissing) Request the current user directory, optionally prompting the user to request a directory if none is available.static voidresetClassifications(ImageData<?> imageData, Class<? extends PathObject> cls) Select objects that are instances of a specified class, logging an appropriate method in the workflow.static voidresetSelection(ImageData<?> imageData) Reset the selection for an image.static booleanresetTMAMetadata(ImageData<?> imageData) Reset TMA metadata, if available.static voidrunGeoJsonObjectExport(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a dialog to export object(s) to a GeoJSON file.static voidrunObjectImport(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a dialog to import object(s) from a file.static booleansaveSnapshot(QuPathGUI qupath, GuiTools.SnapshotType type) Save an image snapshot, prompting the user to select the output file.static voidsaveSnapshotWithDelay(QuPathGUI qupath, GuiTools.SnapshotType type, long delayMillis) Save an image snapshot after a specified delay, prompting the user to select the output file.static voidselectAllObjects(ImageData<?> imageData) Select all objects (excluding the root object) in the imageData.static voidselectObjectsByClass(ImageData<?> imageData, Class<? extends PathObject> cls) Select objects that are instances of a specified class, logging an appropriate method in the workflow.static booleanselectObjectsByClassification(ImageData<?> imageData, PathClass... pathClasses) Select objects by classification, logging the step (if performed) in the history workflow.static voidSelect all the objects on the current plane of the viewer.static voidsetViewerDownsample(QuPathViewer viewer, double downsample) Set the downsample factor for the specified viewer.static voidshowAnnotationGridView(QuPathGUI qupath) Show a grid view for annotation objects.static voidshowAnnotationMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all annotation objects.static voidshowCellMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all cell objects.static voidshowChannelViewer(QuPathViewer viewer) Show a channel viewer window associated with a specific viewer.static voidshowDetectionMeasurementManager(QuPathGUI qupath, ImageData<?> imageData) Show a simple dialog for viewing (and optionally removing) detection measurements.static voidshowDetectionMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all detection objects.static voidshowInstalledExtensions(QuPathGUI qupath) Show a dialog displaying the extensions installed for a specified QuPath instance.static voidshowMiniViewer(QuPathViewer viewer) Show a mini viewer window associated with a specific viewer.static voidshowScriptEditor(QuPathGUI qupath) Show the script editor, or bring the window to the front if it is already open.static voidshowScriptInterpreter(QuPathGUI qupath) Show a script interpreter window for a Qupath instance.static voidshowTMACoreGridView(QuPathGUI qupath) Show a grid view for TMA core objects.static voidshowTMAMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all TMA core objects.static voidshowViewTracker(QuPathGUI qupath) Show a dialog to track the viewed region of an image.static voidshowWorkflowScript(QuPathGUI qupath, ImageData<?> imageData) Show the QuPath script editor with a script corresponding to the command history of a specified image.
-
Constructor Details
-
Commands
public Commands()
-
-
Method Details
-
insertSelectedObjectsInHierarchy
Insert the selected objects in the hierarchy, resolving positions accordingly.This causes smaller 'completely-contained' annotations to be positioned below larger containing annotations, and detections to be assigned to other annotations based on centroid location.
- Parameters:
imageData- the image data containing the hierarchy
-
promptToResolveHierarchy
Resolve parent-child relationships within the object hierarchy. This means that objects will be arranged hierarchically, rather than as a flat list.- Parameters:
imageData- the image data to process
-
createFullImageAnnotation
Create a full image annotation for the image in the specified viewer. The z and t positions of the viewer will be used.- Parameters:
viewer- the viewer containing the image to be processed
-
editSelectedAnnotation
Prompt to edit the selected annotation by translation and rotation.Note that this method may change in future versions to be tied to a specified image data, rather than a specific QuPath instance.
- Parameters:
qupath- the QuPath instance for which the object should be edited
-
showAnnotationGridView
Show a grid view for annotation objects.- Parameters:
qupath- the QuPath instance
-
showTMACoreGridView
Show a grid view for TMA core objects.- Parameters:
qupath- the QuPath instance
-
showDetectionMeasurementTable
public static void showDetectionMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all detection objects.- Parameters:
qupath- the QuPath instanceimageData- the image data for which to show measurements
-
showCellMeasurementTable
Show a measurement table for all cell objects.- Parameters:
qupath- the QuPath instanceimageData- the image data for which to show measurements
-
showAnnotationMeasurementTable
public static void showAnnotationMeasurementTable(QuPathGUI qupath, ImageData<BufferedImage> imageData) Show a measurement table for all annotation objects.- Parameters:
qupath- the QuPath instanceimageData- the image data for which to show measurements
-
showTMAMeasurementTable
Show a measurement table for all TMA core objects.- Parameters:
qupath- the QuPath instanceimageData- the image data for which to show measurements
-
promptToEstimateStainVectors
Prompt to estimate stain vectors for the specified image, using any current region of interest.- Parameters:
imageData- the image data for which stain vectors should be estimated
-
promptToExportImageRegion
Prompt to export the current image region selected in the viewer.- Parameters:
viewer- the viewer containing the image to exportrenderedImage- if true, export the rendered (RGB) image rather than original pixel values
-
showInstalledExtensions
Show a dialog displaying the extensions installed for a specified QuPath instance.- Parameters:
qupath- the QuPath instance
-
showDetectionMeasurementManager
Show a simple dialog for viewing (and optionally removing) detection measurements.- Parameters:
qupath- the qupath GUIimageData- the image data
-
resetTMAMetadata
Reset TMA metadata, if available.- Parameters:
imageData- the image data- Returns:
- true if changes were made, false otherwise
-
createSingleStageAction
public static org.controlsfx.control.action.Action createSingleStageAction(Supplier<Stage> supplier) Create a command that generates a persistent single dialog on demand. A reference to the dialog can be retained, so that if the command is called again either the original dialog is shown and/or brought to the front.- Parameters:
supplier- supplier function to generate the dialog on demand- Returns:
- the action
-
createSingleStageAction
public static org.controlsfx.control.action.Action createSingleStageAction(Supplier<Stage> supplier, String name) Create a named command that generates a persistent single dialog on demand. A reference to the dialog can be retained, so that if the command is called again either the original dialog is shown and/or brought to the front.- Parameters:
supplier- supplier function to generate the dialog on demandname- the command name (for the Action)- Returns:
- the action
-
createMeasurementMapDialog
Create a dialog for displaying measurement maps.- Parameters:
qupath- theQuPathGUIinstance to which the maps refer- Returns:
- a measurement map dialog
-
showScriptInterpreter
Show a script interpreter window for a Qupath instance.- Parameters:
qupath- the QuPath instance
-
createLicensesWindow
Create a window summarizing license information for QuPath and its third party dependencies.- Parameters:
qupath- the current QuPath instance- Returns:
- a window to display license information
-
createShowSystemInfoDialog
Create a window summarizing key system information relevant for QuPath.- Parameters:
qupath- the current QuPath instance- Returns:
- a window to display license information
-
createPreferencesDialog
Show a dialog to adjust QuPath preferences.- Parameters:
qupath- the QuPath instance- Returns:
- window to use to display preferences
-
createRotateImageDialog
Create a dialog for rotating the image in the current viewer (for display only).- Parameters:
qupath- theQuPathGUIinstance
-
createZoomCommand
public static org.controlsfx.control.action.Action createZoomCommand(QuPathGUI qupath, int zoomAmount) Create a zoom in/out command action.- Parameters:
qupath- QuPath instancezoomAmount- relative amount to zoom in (positive) or out (negative). Suggested value is +/-10.- Returns:
- an action
-
createSpecifyAnnotationDialog
Create a stage to prompt the user to specify an annotation to add.- Parameters:
qupath- the qupath GUI- Returns:
- a stage
-
createObjectDescriptionsDialog
Create a stage to display object descriptions.- Parameters:
qupath- the qupath GUI- Returns:
- a stage
-
promptToSaveImageData
public static boolean promptToSaveImageData(QuPathGUI qupath, ImageData<BufferedImage> imageData, boolean overwriteExisting) Prompt to save the specifiedImageData.- Parameters:
qupath- the QuPath GUIimageData- the image dataoverwriteExisting- whether to overwrite existing image data- Returns:
- whether the save succeeded
-
saveSnapshotWithDelay
public static void saveSnapshotWithDelay(QuPathGUI qupath, GuiTools.SnapshotType type, long delayMillis) Save an image snapshot after a specified delay, prompting the user to select the output file.
The delay is used to work around the fact that making a snapshot immediately can sometimes result in undesirable UI elements still being visible, e.g. the menu item used to trigger the snapshot.
See https://github.com/qupath/qupath/issues/1854- Parameters:
qupath- theQuPathGUIinstance to snapshottype- the snapshot typedelayMillis- the delay in milliseconds
-
saveSnapshot
Save an image snapshot, prompting the user to select the output file.- Parameters:
qupath- theQuPathGUIinstance to snapshottype- the snapshot type- Returns:
- true if a snapshot was saved, false otherwise
-
mergeSelectedAnnotations
Merge the currently-selected annotations for an image, replacing them with a single new annotation.- Parameters:
imageData- the image data
-
duplicateSelectedAnnotations
Duplicate the selected annotations.- Parameters:
imageData- the image data
-
copySelectedAnnotationsToCurrentPlane
Copy the selected objects and add them to the plane currently active in the viewer.- Parameters:
viewer- the viewer that determines the current image and plane- Implementation Note
- this command is scriptable, but will store the plane in the script (since there is not necessarily a 'current plane' when running a script without a viewer)
-
makeInverseAnnotation
Make an inverse annotation for the selected objects, storing the command in the history workflow.- Parameters:
imageData- the image data- See Also:
-
showViewTracker
Show a dialog to track the viewed region of an image.- Parameters:
qupath- the QuPath GUI
-
combineSelectedAnnotations
Combine the selected annotations for the specified hierarchy.- Parameters:
imageData- the image data to processop- theRoiTools.CombineOpoperation to apply- Returns:
- true if changes were made, false otherwise
-
promptToSelectObjectsByClassification
Prompt to select objects according to their classifications.- Parameters:
qupath- the QuPath GUIimageData- the image data
-
promptToEditClass
Prompt to edit the name/color of a class.- Parameters:
pathClass- the path class- Returns:
- whether the edit succeeds.
-
selectObjectsByClassification
public static boolean selectObjectsByClassification(ImageData<?> imageData, PathClass... pathClasses) Select objects by classification, logging the step (if performed) in the history workflow.- Parameters:
imageData- theImageDatacontaining objects to be selectedpathClasses- classifications that will result in an object being selected- Returns:
- true if a selection command was run, false otherwise (e.g. if no pathClasses were specified)
-
promptToDeleteObjects
Prompt to delete objects of a specified type, or all objects.- Parameters:
imageData- the image datacls- the type of object (if null, all)
-
removeOnImageBounds
Delete all objects touching the image boundary.- Parameters:
imageData- the image data
-
promptToResetPreferences
public static boolean promptToResetPreferences()Reset QuPath's preferences, after confirming with the user. QuPath needs to be restarted for this to take effect.- Returns:
- true if the preferences were reset, false otherwise
-
setViewerDownsample
Set the downsample factor for the specified viewer.- Parameters:
viewer- the QuPath viewerdownsample- the new downsample
-
closeProject
Close the current project open in theQuPathGUI.- Parameters:
qupath- The QuPath GUI
-
promptToCreateProject
Prompt the user to select an empty directory, and use this to create a new project and set it as active.- Parameters:
qupath- theQuPathGUIinstance for which the project should be created.- Returns:
- true if a project was created, false otherwise (e.g. the user cancelled).
-
promptToOpenProject
Prompt the user to open an existing project and set it as active.- Parameters:
qupath- theQuPathGUIinstance for which the project should be opened.- Returns:
- true if a project was opened, false otherwise (e.g. the user cancelled).
-
launchTMADataViewer
Open new window with the TMA data viewer.- Parameters:
qupath- currentQuPathGUIinstance (may be null).
-
distanceToAnnotations2D
Compute the distance between all detections and the closest annotation, for all annotation classifications.- Parameters:
imageData- the image data to processsignedDistances- if true, use signed distances
-
detectionCentroidDistances2D
Compute the distance between the centroids of all detections, for all available classifications.- Parameters:
imageData- the image data to process
-
promptToSetGridLineSpacing
Prompt to input the spacing for the grid lines optionally displayed on viewers.- Parameters:
options- theOverlayOptionsthat manage the grid lines.
-
requestUserDirectory
Request the current user directory, optionally prompting the user to request a directory if none is available.- Parameters:
promptIfMissing- whether to prompt the user if the directory is not set yet- Returns:
- the user directory, or null if none exists and the user did not create one
-
reloadImageData
Reload the specified image data from a previously saved version,if available.- Parameters:
qupath- the QuPath GUIimageData- the image data
-
promptToAddShapeFeatures
Prompt to add shape features for selected objects.- Parameters:
qupath- current QuPath instance
-
convertDetectionsToPoints
Convert detection objects to point annotations based upon their ROI centroids.- Parameters:
imageData- the image data to processpreferNucleus- if true, use a nucleus ROI for cell objects (if available
-
promptToSimplifySelectedAnnotations
public static void promptToSimplifySelectedAnnotations(ImageData<?> imageData, double altitudeThreshold) Show a prompt to selected annotations in a hierarchy.- Parameters:
imageData- the current image dataaltitudeThreshold- default altitude value for simplification
-
selectObjectsOnCurrentPlane
Select all the objects on the current plane of the viewer.- Parameters:
viewer- the QuPath GUI
-
selectAllObjects
Select all objects (excluding the root object) in the imageData.- Parameters:
imageData- the image data
-
selectObjectsByClass
Select objects that are instances of a specified class, logging an appropriate method in the workflow.- Parameters:
imageData- the image datacls- the type of object
-
resetSelection
Reset the selection for an image.- Parameters:
imageData- the image data
-
resetClassifications
Select objects that are instances of a specified class, logging an appropriate method in the workflow.- Parameters:
imageData- the image datacls- the type of object
-
createWorkflowDisplayDialog
Create a dialog to show the workflow history for the current image data.- Parameters:
qupath- the QuPath instance- Returns:
- a workflow display dialog
-
showWorkflowScript
Show the QuPath script editor with a script corresponding to the command history of a specified image.- Parameters:
qupath- the QuPath GUIimageData- the image data
-
showScriptEditor
Show the script editor, or bring the window to the front if it is already open.- Parameters:
qupath- the QuPath GUI
-
createMemoryMonitorDialog
Create a dialog to monitor memory usage.- Parameters:
qupath- the QuPath GUI- Returns:
- the dialog stage
-
showMiniViewer
Show a mini viewer window associated with a specific viewer.- Parameters:
viewer- the viewer with which to associate this window
-
showChannelViewer
Show a channel viewer window associated with a specific viewer.- Parameters:
viewer- the viewer with which to associate this window
-
refreshObjectIDs
Refresh object IDs to ensure uniqueness.- Parameters:
imageData- the image dataduplicatesOnly- only refresh IDs that are duplicates of other IDs
-
runObjectImport
Show a dialog to import object(s) from a file.- Parameters:
qupath- the qupath GUIimageData- the image data
-
copySelectedObjectsToClipboard
Attempt to copy selected objects to the system clipboard, if available- Parameters:
imageData- the image data
-
copyAnnotationsToClipboard
Attempt to annotation objects to the system clipboard, if available- Parameters:
imageData- the image data
-
pasteFromClipboard
Attempt to paste objects from the system clipboard to the current image, if available; otherwise, check for text on the clipboard and paste it into a new script editor tab- Parameters:
qupath- the qupath GUIaddToCurrentPlane- if true, add the objects to the plane currently visible in the viewer (and don't show any text if objects can't be found)
-
runGeoJsonObjectExport
Show a dialog to export object(s) to a GeoJSON file.- Parameters:
qupath- the QuPath GUIimageData- the image data
-