Class ImageJScriptRunner.Builder

java.lang.Object
qupath.imagej.gui.scripts.ImageJScriptRunner.Builder
Enclosing class:
ImageJScriptRunner

public static class ImageJScriptRunner.Builder extends Object
  • Method Details

    • macroText

      public ImageJScriptRunner.Builder macroText(String macroText)
      Specify the exact text for an ImageJ macro. This is equivalent to text(String) and also setting the scripting language to specify that we have an ImageJ macro.
      Parameters:
      macroText -
      Returns:
      this builder
      See Also:
    • groovyText

      public ImageJScriptRunner.Builder groovyText(String groovy)
      Specify the exact text for an ImageJ macro. This is equivalent to text(String) and also setting the scripting language to specify that we have a Groovy script.
      Parameters:
      groovy -
      Returns:
      this builder
      See Also:
    • text

      public ImageJScriptRunner.Builder text(String script)
      Specify the exact text for the script or macro.
      Parameters:
      script -
      Returns:
      this builder
      See Also:
    • file

      public ImageJScriptRunner.Builder file(String path) throws IOException
      Specify the path to a file containing the script or macro. The file extension will be used to determine the scripting language (the default is to assume an ImageJ macro).
      Parameters:
      path -
      Returns:
      this builder
      Throws:
      IOException - if the script cannot be read
      See Also:
    • scriptFile

      public ImageJScriptRunner.Builder scriptFile(File file) throws IOException
      Specify a file containing the script or macro. The file extension will be used to determine the scripting language (the default is to assume an ImageJ macro).
      Parameters:
      file -
      Returns:
      this builder
      Throws:
      IOException - if the script cannot be read
      See Also:
    • scriptFile

      public ImageJScriptRunner.Builder scriptFile(Path path) throws IOException
      Specify a path to the script or macro. The file extension will be used to determine the scripting language (the default is to assume an ImageJ macro).
      Parameters:
      path -
      Returns:
      this builder
      Throws:
      IOException - if the script cannot be read
      See Also:
    • scriptEngine

      public ImageJScriptRunner.Builder scriptEngine(String scriptEngine)
      Specify the name of any script engine to use. By default, the script is assumed to be an ImageJ macro. This parameter can be used to run a script written with another JSR 223-supported scripting language.
      Parameters:
      scriptEngine -
      Returns:
      this builder
    • setImageJRoi

      public ImageJScriptRunner.Builder setImageJRoi()
      Set the ROI for the QuPath object being set as a Roi on the ImagePlus.
      Returns:
      this builder
    • setImageJRoi

      public ImageJScriptRunner.Builder setImageJRoi(boolean doSet)
      Optionally set the ROI for the QuPath object being set as a Roi on the ImagePlus.
      Parameters:
      doSet -
      Returns:
      this builder
    • setImageJOverlay

      public ImageJScriptRunner.Builder setImageJOverlay()
      Add any QuPath objects within the field of view to an ImageJ overlay.
      Returns:
      this builder
    • setImageJOverlay

      public ImageJScriptRunner.Builder setImageJOverlay(boolean doSet)
      Optionally add any QuPath objects within the field of view to an ImageJ overlay.
      Parameters:
      doSet -
      Returns:
      this builder
    • closeOpenImages

      public ImageJScriptRunner.Builder closeOpenImages(boolean doClose)
      Request that any images left open after the macro are closed.
      Parameters:
      doClose -
      Returns:
      this builder
    • roiToDetection

      public ImageJScriptRunner.Builder roiToDetection()
      Convert any active Roi at the end of the script to a QuPath detection object.
      Returns:
      this builder
    • roiToAnnotation

      public ImageJScriptRunner.Builder roiToAnnotation()
      Convert any active Roi at the end of the script to a QuPath annotation object.
      Returns:
      this builder
    • roiToTile

      public ImageJScriptRunner.Builder roiToTile()
      Convert any active Roi at the end of the script to a QuPath tile object.
      Returns:
      this builder
    • roiToObject

      Convert any active Roi at the end of the script to the specified QuPath object type.
      Returns:
      this builder
    • overlayToAnnotations

      public ImageJScriptRunner.Builder overlayToAnnotations()
      Convert Rois on the overlay of the current image at the end of the script to QuPath annotation objects.
      Returns:
      this builder
    • overlayToDetections

      public ImageJScriptRunner.Builder overlayToDetections()
      Convert Rois on the overlay of the current image at the end of the script to QuPath detection objects.
      Returns:
      this builder
    • overlayToTiles

      public ImageJScriptRunner.Builder overlayToTiles()
      Convert Rois on the overlay of the current image at the end of the script to QuPath tile objects.
      Returns:
      this builder
    • overlayToObjects

      Convert Rois on the overlay of the current image at the end of the script to the specified QuPath object type.
      Returns:
      this builder
    • clearChildObjects

      public ImageJScriptRunner.Builder clearChildObjects()
      Request that the child objects are removed from any objects that are passed to the script runner. This is usually desirable when adding new objects, to avoid duplicate objects being created by accident if the script is run multiple times.
      Returns:
      this builder
    • clearChildObjects

      public ImageJScriptRunner.Builder clearChildObjects(boolean doClear)
      Optionally request that the child objects are removed from any objects that are passed to the script runner. This is usually desirable when adding new objects, to avoid duplicate objects being created by accident if the script is run multiple times.
      Parameters:
      doClear -
      Returns:
      this builder
    • addToWorkflow

      public ImageJScriptRunner.Builder addToWorkflow()
      Request that the script is stored in the workflow history when it is run for an ImageData. This is useful to enable the script to be run in the future from a 'regular' Groovy script in QuPath.
      Returns:
      this builder
    • addToWorkflow

      public ImageJScriptRunner.Builder addToWorkflow(boolean doAdd)
      Optionally request that the script is stored in the workflow history when it is run for an ImageData. This is useful to enable the script to be run in the future from a 'regular' Groovy script in QuPath.
      Parameters:
      doAdd -
      Returns:
      this builder
    • applyToObjects

      Specify the objects that the script should be applied to.
      Parameters:
      objectType -
      Returns:
      this builder
    • fixedDownsample

      public ImageJScriptRunner.Builder fixedDownsample(double downsample)
      Use a fixed downsample value when passing images to ImageJ.
      Parameters:
      downsample -
      Returns:
      this builder
    • maxDimension

      public ImageJScriptRunner.Builder maxDimension(int maxDim)
      Resize images to have a width and height ≤ a specified value when passing images to ImageJ.
      Parameters:
      maxDim -
      Returns:
      this builder
    • pixelSizeMicrons

      public ImageJScriptRunner.Builder pixelSizeMicrons(double pixelSizeMicrons)
      Resize images to have a target pixel value in µm when passing images to ImageJ.
      Parameters:
      pixelSizeMicrons -
      Returns:
      this builder
    • pixelSize

      public ImageJScriptRunner.Builder pixelSize(PixelCalibration targetCalibration)
      Resize images to have a target pixel value when passing images to ImageJ.
      Parameters:
      targetCalibration -
      Returns:
      this builder
    • downsample

      public ImageJScriptRunner.Builder downsample(DownsampleCalculator downsample)
      Specify how images should be downsampled when passing them to ImageJ.
      Parameters:
      downsample -
      Returns:
      this builder
    • padding

      public ImageJScriptRunner.Builder padding(int padding)
      Specify how much padding to add around the ROI.
      Parameters:
      padding - number of pixels of padding to add (should be ≥ 0)
      Returns:
      this builder
    • nThreads

      public ImageJScriptRunner.Builder nThreads(int nThreads)
      Specify the number of parallel threads to use. This value is only used if a TaskRunner has not be provided.
      Parameters:
      nThreads -
      Returns:
      this builder
      See Also:
    • taskRunner

      public ImageJScriptRunner.Builder taskRunner(TaskRunner taskRunner)
      Provide an optional task runner. This can be used to show a progress dialog or log output.
      Parameters:
      taskRunner -
      Returns:
      this builder
      See Also:
    • channelIndices

      public ImageJScriptRunner.Builder channelIndices(int... inds)
      Optionally specify a subset of image channels to pass to ImageJ.
      Parameters:
      inds - channel indices (zero-based)
      Returns:
      this builder
    • channelNames

      public ImageJScriptRunner.Builder channelNames(String... names)
      Optionally specify a subset of image channels to pass to ImageJ, based on channel names.
      Parameters:
      names - channel names
      Returns:
      this builder
    • channels

      Optionally specify channels to pass to ImageJ.
      Parameters:
      channel - the first channel to use
      channels - any additional channels
      Returns:
      this builder
    • channels

      Optionally specify channels to pass to ImageJ.
      Parameters:
      channels - the channels to use
      Returns:
      this builder
    • build

      public ImageJScriptRunner build()
      Build a new ImageJScriptRunner with the parameters specified in this builder.
      Returns: