This reference shows all the methods available from within the script editor directly, which provide direct access to many of QuPath's functionality
== Fields ==
BRIGHTFIELD_H_DAB
BRIGHTFIELD_H_E
BRIGHTFIELD_OTHER
FLUORESCENCE
OTHER
These fields of class `ImageData.ImageType` help for checking or setting the image type currently open in QuPath.
```lang=java
// Set image type to Fluorescence if other
def currentImageType = getCurrentImageData().getImageType()
if(currentImageType != FLUORESCENCE)
setImageType(FLUORESCENCE)
```
== Methods ==
=== static void addObject(PathObject pathObject) ===
Adds a PathObject (Annotations or Detections) to the current Hierarchy
```lang=java
import qupath.lib.objects.PathAnnotationObject
import qupath.lib.roi.RectangleROI
// Make a rectangle and add it to the current hierarachy
rectangle = new PathAnnotationObject(new RectangleROI(0,0,1000,1000))
addObject(rectangle)
fireHierarchyUpdate()
```
=== static void addObjects(java.util.Collection<PathObject> pathObjects) ==
Add the specified collection of objects to the current PathObjectHierarchy.
Same as above but we can add many at once
static void addObjects(PathObject[] pathObjects)
Add the specified array of objects to the current PathObjectHierarchy.
static void classifyDetection(java.util.function.Predicate<PathObject> p, java.lang.String className)
static void classifySelected(java.lang.String pathClassName)
Set the classification of the selected objects in the current hierarchy.
static void classifySelected(PathObjectHierarchy hierarchy, java.lang.String pathClassName)
Set the classification of the selected objects.
static void clearAllObjects()
Remove all the objects in the current PathObjectHierarchy, and clear the selection.
static void clearAllObjects(java.lang.Class<? extends PathObject> cls)
Remove all the objects of a specified Java class.
static void clearAnnotations()
Remove all the annotation objects from the current PathObjectHierarchy.
static void clearDetections()
Remove all the detection objects from the current PathObjectHierarchy.
static void clearSelectedObjects()
Clear selected objects, but keep child (descendant) objects.
static void clearSelectedObjects(boolean keepChildren)
Delete the selected objects from the current hierarchy, optoonally keeping their child (descendant) objects.
static void clearTMAGrid()
Remove the TMA grid from the current PathObjectHierarchy.
static void createSelectAllObject(boolean setSelected)
static void deselectAll()
Clear the selection for the current hierarchy, so that no objects of any kind are selected.
static void deselectAll(PathObjectHierarchy hierarchy)
Clear the selection, so that no objects of any kind are selected.
static void fireHierarchyUpdate()
Trigger an update for the current hierarchy.
static void fireHierarchyUpdate(PathObjectHierarchy hierarchy)
Trigger an update for the specified hierarchy.
static PathObject[] getAllObjects()
Get an array of all objects in the current hierarchy.
static java.util.List<PathObject> getAnnotationObjects()
Get a list of the current annotation objects.
static PathObject[] getAnnotationObjectsAsArray()
Deprecated.
static PathClass getBasePathClass(PathObject pathObject)
Get a base class - which is either a valid PathClass which is *not* an intensity class, or else null.
static ImageData<?> getBatchImageData()
Set the ImageData to use for batch processing.
static java.util.List<PathObject> getCellObjects()
Get a list of the current cell objects.
static java.lang.Integer getColorRGB(int... v)
Create a new packed-int representation of an RGB color.
static PathObjectHierarchy getCurrentHierarchy()
Get the PathObjectHierarchy of the current ImageData.
static ImageData<?> getCurrentImageData()
Get the path to the current ImageData.
static java.lang.String getCurrentServerPath()
Get the path to the ImageServer of the current ImageData.
static PathClass getDerivedPathClass(PathClass baseClass, java.lang.String name)
Get a PathClass with the specified name, derived from another PathClass.
static PathClass getDerivedPathClass(PathClass baseClass, java.lang.String name, java.lang.Integer rgb)
Get a PathClass with the specified name, derived from another PathClass.
static java.util.List<PathObject> getDetectionObjects()
Get a list of the current detection objects.
static PathObject[] getDetectionObjectsAsArray()
Deprecated.
static PathClass getNonIntensityAncestorPathClass(PathObject pathObject)
Get the first ancestor class of pathObject.getPathClass() that is not an intensity class (i.e.
static java.util.List<PathObject> getObjects(java.util.function.Predicate<PathObject> predicate)
Get a list of all objects in the current hierarchy according to a specified predicate.
static java.util.List<PathObject> getObjects(PathObjectHierarchy hierarchy, java.util.function.Predicate<PathObject> predicate)
Get a list of all objects in the specified hierarchy according to a specified predicate.
static PathClass getPathClass(java.lang.String name)
Get a PathClass with the specified name.
static PathClass getPathClass(java.lang.String name, java.lang.Integer rgb)
Get a PathClass with the specified name and color.
static PathObject getSelectedObject()
Get the primary selected object within the current PathObjectHierarchy.
static java.util.Collection<PathObject> getSelectedObjects()
Get the selected objects within the current PathObjectHierarchy.
static ROI getSelectedROI()
Get the ROI for the primary selected object within the current PathObjectHierarchy.
static java.util.List<TMACoreObject> getTMACoreList()
Get the list of TMA core objects for the current hierarchy.
static boolean hasMeasurement(PathObject pathObject, java.lang.String measurementName)
Test whether a PathObject has a specified measurement in its measurement list.
static boolean isTMADearrayed()
Returns true if TMA cores are available.
static double measurement(PathObject pathObject, java.lang.String measurementName)
Extract the specified measurement from a PathObject.
static int nObjects()
Get a count of the total number of objects in the current hierarchy.
static java.util.function.Predicate<PathObject> parsePredicate(java.lang.String command)
Deprecated.
static void pathPrint(java.lang.String message)
static boolean relabelTMAGrid(java.lang.String labelsHorizontal, java.lang.String labelsVertical, boolean rowFirst)
static boolean relabelTMAGrid(PathObjectHierarchy hierarchy, java.lang.String labelsHorizontal, java.lang.String labelsVertical, boolean rowFirst)
Relabel a TMA grid.
static void removeMeasurements(java.lang.Class<? extends PathObject> cls, java.lang.String... measurementNames)
static void removeMeasurements(PathObjectHierarchy hierarchy, java.lang.Class<? extends PathObject> cls, java.lang.String... measurementNames)
static void removeObject(PathObject pathObject, boolean keepChildren)
Remove the specified object from the current PathObjectHierarchy, optionally keeping or removing descendant objects.
static void removeObjects(java.util.Collection<PathObject> pathObjects, boolean keepChildren)
Remove the specified collection of objects from the current PathObjectHierarchy, optionally keeping or removing descendant objects.
static void removeObjects(PathObject[] pathObjects, boolean keepChildren)
Remove the specified array of objects from the current PathObjectHierarchy, optionally keeping or removing descendant objects.
static void resetClassifications(java.lang.Class<? extends PathObject> cls)
Reset the PathClass for all objects of the specified type in the current hierarchy.
static void resetClassifications(PathObjectHierarchy hierarchy, java.lang.Class<? extends PathObject> cls)
Reset the PathClass for all objects of the specified type in the specified hierarchy.
static void resetDetectionClassifications()
Reset the PathClass for all detection objects in the current hierarchy.
static void resetIntensityClassifications()
Reset the intensity classifications for all detections in the current hierarchy.
static void resetIntensityClassifications(java.util.Collection<PathObject> pathObjects)
Reset the intensity classifications for all specified objects.
static void resetIntensityClassifications(PathObjectHierarchy hierarchy)
Reset the intensity classifications for all detections in the specified hierarchy.
static void resetSelection()
Clear the selected objects for the current PathObjectHierarchy.
static void resetTMAMetadata(boolean includeMeasurements)
static void resetTMAMetadata(PathObjectHierarchy hierarchy, boolean includeMeasurements)
static void runClassifier(java.lang.String path)
static void runClassifier(ImageData<?> imageData, PathObjectClassifier classifier)
static void runClassifier(PathObjectHierarchy hierarchy, PathObjectClassifier classifier)
static boolean runPlugin(java.lang.String className, java.lang.String args)
Run the specified plugin on the current ImageData.
static boolean runPlugin(java.lang.String className, ImageData<?> imageData, java.lang.String args)
Run the specified plugin on the specified ImageData.
static void selectAnnotations()
Select all annotation objects in the current hierarchy.
static void selectAnnotations(PathObjectHierarchy hierarchy)
Select all annotation objects in the specified hierarchy.
static void selectCells()
Select all cell objects in the current hierarchy.
static void selectCells(PathObjectHierarchy hierarchy)
Select all cell objects in the specified hierarchy.
static void selectDetections()
Select all detection objects in the current hierarchy.
static void selectDetections(PathObjectHierarchy hierarchy)
Select all detection objects in the specified hierarchy.
static void selectObjects(java.util.function.Predicate<PathObject> predicate)
Set selected objects to contain (only) all objects in the current hierarchy according to a specified predicate.
static void selectObjects(PathObjectHierarchy hierarchy, java.util.function.Predicate<PathObject> predicate)
Set selected objects to contain (only) all objects in the specified hierarchy according to a specified predicate.
static void selectObjectsByClass(java.lang.Class<? extends PathObject> cls)
Set objects that are a subclass of a specified class.
static void selectObjectsByClass(PathObjectHierarchy hierarchy, java.lang.Class<? extends PathObject> cls)
Set objects that are a subclass of a specified class.
static void selectObjectsByMeasurement(java.lang.String command)
Deprecated.
static void selectObjectsByMeasurement(ImageData<?> imageData, java.lang.String command)
Deprecated.
static void selectTMACores()
Select all TMA core objects in the current hierarchy, excluding missing cores.
static void selectTMACores(boolean includeMissing)
Select all TMA core objects in the current hierarchy, optionally including missing cores.
static void selectTMACores(PathObjectHierarchy hierarchy)
Select all TMA core objects in the specified hierarchy, excluding missing cores.
static void selectTMACores(PathObjectHierarchy hierarchy, boolean includeMissing)
Select all TMA core objects in the specified hierarchy, optionally including missing cores.
static ImageData<?> setBatchImageData(ImageData<?> imageData)
Set the ImageData to use for batch processing.
static void setCellIntensityClassifications(java.lang.String measurementName, double... thresholds)
static void setCellIntensityClassifications(PathObjectHierarchy hierarchy, java.lang.String measurementName, double... thresholds)
static boolean setColorDeconvolutionStains(java.lang.String arg)
static boolean setImageType(java.lang.String typeName)
static boolean setImageType(ImageData.ImageType type)
static PathClass setIntensityClassification(PathObject pathObject, java.lang.String measurementName, double... thresholds)
Assign cell classifications as positive or negative based upon a specified measurement, using up to 3 intensity bins.
static void setIntensityClassifications(java.lang.Class<? extends PathObject> cls, java.lang.String measurementName, double... thresholds)
static void setIntensityClassifications(java.util.Collection<PathObject> pathObjects, java.lang.String measurementName, double... thresholds)
static void setIntensityClassifications(PathObjectHierarchy hierarchy, java.lang.Class<? extends PathObject> cls, java.lang.String measurementName, double... thresholds)
static void setIntensityClassificationsForSelected(PathObjectHierarchy hierarchy, java.lang.String measurementName, double... thresholds)
Set intensity classifications for all selected (detection) objects.
static boolean setSelectedObject(PathObject pathObject)