Class MeasurementExporter

java.lang.Object
qupath.lib.gui.tools.MeasurementExporter

public class MeasurementExporter extends Object
Helper class for exporting the measurements of one or more entries in a project.
  • Field Details

    • DECIMAL_PLACES_DEFAULT

      public static final int DECIMAL_PLACES_DEFAULT
      Constant representing that the number of decimal places to use when exporting measurements can be chosen automatically.
      See Also:
  • Constructor Details

    • MeasurementExporter

      public MeasurementExporter()
  • Method Details

    • decimalPlaces

      public MeasurementExporter decimalPlaces(int decimalPlaces)
      Specify how many decimal places to use for numeric output. Default value is DECIMAL_PLACES_DEFAULT, which will adapt the number of decimal places based on the magnitude of the number being export.
      Parameters:
      decimalPlaces - the number of decimal places to use
      Returns:
      this export
    • exportType

      public MeasurementExporter exportType(Class<? extends PathObject> type)
      Specify what type of object should be exported. Default: image (root object).
      Parameters:
      type - the type of object to export
      Returns:
      this exporter
      See Also:
    • annotations

      public MeasurementExporter annotations()
      Specify that annotation measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • allDetections

      public MeasurementExporter allDetections()
      Specify that detection measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • image

      public MeasurementExporter image()
      Specify that whole-image measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • cells

      public MeasurementExporter cells()
      Specify that cell measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • tiles

      public MeasurementExporter tiles()
      Specify that tile measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • tmaCores

      public MeasurementExporter tmaCores()
      Specify that TMA core measurements (only) should be export. This will override any other object type that might previously have been set.
      Returns:
      this exporter
      Since:
      v0.6.0
    • includeOnlyColumns

      public MeasurementExporter includeOnlyColumns(String... includeOnlyColumns)
      Specify the columns that will be included in the export. The column names are case-sensitive.
      Parameters:
      includeOnlyColumns - the columns to include; this takes precedence over excludeColumns(String...).
      Returns:
      this exporter
      See Also:
      • excludeColumns
    • excludeColumns

      public MeasurementExporter excludeColumns(String... excludeColumns)
      Specify the columns that will be excluded during the export. The column names are case-sensitive.
      Parameters:
      excludeColumns - the columns to exclude
      Returns:
      this exporter
      See Also:
      • includeOnlyColumns
    • separator

      public MeasurementExporter separator(String sep)
      Specify the separator used between measurement values. To avoid unexpected behavior, it is recommended to use either tab (\t), comma (,) or semicolon (;).
      Parameters:
      sep - the column separator to use
      Returns:
      this exporter
    • imageList

      public MeasurementExporter imageList(List<ProjectImageEntry<BufferedImage>> imageList)
      Specify the list of images (ProjectImageEntry) to export.
      Parameters:
      imageList - the images to export
      Returns:
      this exporter
    • progressMonitor

      public MeasurementExporter progressMonitor(DoubleConsumer monitor)
      Set a progress monitor to be notified during export. This is a consumer that takes a value between 0.0 (at the start) and 1.0 (export complete).
      Parameters:
      monitor - the optional progress monitor
      Returns:
      this exporter
    • filter

      public MeasurementExporter filter(Predicate<PathObject> filter)
      Filter the PathObjects before export (objects returning true for the predicate will be included). This can be used as a secondary filter after the object type, e.g. to select annotations with a specific names, or detections with specific classifications.
      Parameters:
      filter - a filter to use to select objects for export
      Returns:
      this exporter
      Since:
      v0.3.2
    • getImageList

      public List<ProjectImageEntry<BufferedImage>> getImageList()
      Returns the list of images (ProjectImageEntry).
      Returns:
      imageList
    • getExcludeColumns

      public List<String> getExcludeColumns()
      Returns the list of columns to exclude from export.
      Returns:
      list of column names
    • getIncludeColumns

      public List<String> getIncludeColumns()
      Returns the list of columns to include in the export.
      Returns:
      list of column names
    • getSeparator

      public String getSeparator()
      Returns the separator used in between measurements.
      Returns:
      separator
    • getType

      public Class<? extends PathObject> getType()
      Returns the type of path objects used in the export.
      Returns:
      path object
    • exportMeasurements

      public void exportMeasurements(File file) throws IOException, InterruptedException
      Exports the measurements of one or more entries in the project. This function first opens all the images in the project to store all the column names and values of the measurements. Then, it loops through the maps containing the values to write them to the given output file.
      Parameters:
      file - the file where the data should be written
      Throws:
      IOException - if the export files
      InterruptedException
    • exportMeasurements

      public void exportMeasurements(OutputStream stream) throws IOException, InterruptedException
      Exports the measurements of one or more entries in the project. This function first opens all the images in the project to store all the column names and values of the measurements. Then, it loops through the maps containing the values to write them to the given output stream.
      Parameters:
      stream - the output stream to write to
      Throws:
      IOException - if the export fails
      InterruptedException