This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* QuPath script to create concentric rings around an annotation. | |
*/ | |
// Number of rings to create | |
int nRings = 5 | |
// Define distance in µm, then convert (or just go straight to defining in pixels) | |
double distanceMicrons = 100 | |
double distancePixels = distanceMicrons / getCurrentServer().getPixelCalibration().getAveragedPixelSizeMicrons() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Script to convert all polyline annotations to polygons in QuPath. | |
* Written for QuPath v0.5 (may work in other versions). | |
*/ | |
def lineObjects = getAnnotationObjects().findAll {it.getROI().isLine()} | |
def polygonObjects = [] | |
def selectedObjects = getSelectedObjects() as List | |
for (lineObject in lineObjects) { | |
def line = lineObject.getROI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Groovy script to generate a batch script to launch QuPath while setting the PATH | |
* from a conda environment. | |
* | |
* This is useful to add GPU support with Deep Java Library (DJL) without needing to install | |
* CUDA system-wide. | |
* | |
* This script was written for QuPath v0.5. | |
* You should read the top part and change the variables to match what you need. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* QuPath v0.4.3 script to threshold probability outputs from a pixel classifier. | |
* | |
* By default, converting the pixel classifier output to probabilities will always | |
* apply a softmax operation and take the class with the highest probability. | |
* | |
* This script provides an alternative, whereby you can specify a probability threshold | |
* for one or more channels, and threshold to create objects from that. | |
* Using a higher threshold can then restrict the object creation of more confident predictions. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* QuPath script to export images corresponding to all the annotation bounding boxes in an image. | |
* Written for QuPath v0.4.3. | |
*/ | |
// Export at full resolution (or change this value) | |
double downsample = 1.0 | |
// Export to a subdirectory of the current project | |
def dir = buildPathInProject("export") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a convex or concave hull annotation from the selected objects. | |
* | |
* The calculations are performed using Java Topology Suite's 'ConcaveHullOfPolygons' class - | |
* see https://locationtech.github.io/jts/javadoc/org/locationtech/jts/algorithm/hull/ConcaveHullOfPolygons.html | |
* | |
* This was written for QuPath v0.4.3. | |
* If it's useful enough, a similar feature might be added to QuPath directly in the future. | |
* | |
* @author Pete Bankhead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a point annotation showing equally-spaced splits | |
* along a polyline or simple polygon (i.e. no holes or | |
* self-intersections). | |
* | |
* See https://forum.image.sc/t/divide-free-hand-lines-at-regular-interval/79845/4 | |
* | |
* Written for QuPath v0.4.3 using JTS. | |
* | |
* @author Pete Bankhead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create fixed-sized square annotations around the points of a selected | |
* point annotation. | |
* | |
* Written for QuPath v0.4 and v0.5. | |
* See https://forum.image.sc/t/is-it-possible-to-create-annotations-on-click/79270 | |
* | |
* Edited 12/2023 to support multiple selected point annotations (not just one). | |
* | |
* @author Pete Bankhead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Constrain all selected annotations so that they fall inside unselected annotations. | |
* | |
* This is intended for a case where | |
* - you have some annotations that define a region of interest (e.g. all tissue) | |
* - some other annotations that partially overlap the first annotations, but which *should* be inside | |
* | |
* If you select the second annotations and run this script, it should remove the parts that are outside the first | |
* annotations - effectively cleaning up the image. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a convex hull annotation surrounding all selected objects. | |
* | |
* Note that this | |
* - was written using QuPath v0.4.x (but probably works in some earlier releases) | |
* - doesn't work very well for ellipse objects, but should be ok with other shapes | |
* - assumes that you only have a 2D image (you'd need to change the 'image plane' part for z-stacks or timeseries) | |
* | |
* It was written for https://forum.image.sc/t/qupath-script-command-to-draw-polygon-annotation-from-points/76833 | |
* |
NewerOlder