Class OMEZarrWriter.Builder

java.lang.Object
qupath.lib.images.writers.ome.zarr.OMEZarrWriter.Builder
Enclosing class:
OMEZarrWriter

public static class OMEZarrWriter.Builder extends Object
Builder to create an instance of a OMEZarrWriter.
  • Constructor Details

    • Builder

      public Builder(ImageServer<BufferedImage> server)
      Create the builder.
      Parameters:
      server - the image to write
  • Method Details

    • compression

      public OMEZarrWriter.Builder compression(com.bc.zarr.Compressor compressor)
      Set the compressor to use when writing tiles. By default, the blocs compression is used.
      Parameters:
      compressor - the compressor to use when writing tiles
      Returns:
      this builder
    • parallelize

      public OMEZarrWriter.Builder parallelize(int numberOfThreads)
      Tiles will be written from a pool of thread. This function specifies the number of threads to use. By default, 12 threads are used.
      Parameters:
      numberOfThreads - the number of threads to use when writing tiles
      Returns:
      this builder
    • downsamples

      public OMEZarrWriter.Builder downsamples(double... downsamples)
      Enable the creation of a pyramidal image with the provided downsamples. The levels corresponding to the provided downsamples will be automatically generated.

      If this function is not called (or if it is called with no parameters), the downsamples of the provided image server will be used instead.

      Parameters:
      downsamples - the downsamples of the pyramid to generate
      Returns:
      this builder
    • setMaxNumberOfChunksOnEachSpatialDimension

      public OMEZarrWriter.Builder setMaxNumberOfChunksOnEachSpatialDimension(int maxNumberOfChunks)
      In Zarr files, data is stored in chunks. This parameter defines the maximum number of chunks on the x,y, and z dimensions. By default, this value is set to -1.

      Use a negative value to not define any maximum number of chunks.

      Parameters:
      maxNumberOfChunks - the maximum number of chunks on the x,y, and z dimensions
      Returns:
      this builder
    • tileSize

      public OMEZarrWriter.Builder tileSize(int tileSize)
      In Zarr files, data is stored in chunks. This parameter defines the size of chunks on the x and y dimensions. By default, these values are set to -1.

      Use a negative value to use the tile width/height of the provided image server.

      The provided tile width/height may not be used if this implies creating more chunks than the value given in setMaxNumberOfChunksOnEachSpatialDimension(int).

      Parameters:
      tileSize - the width/height each chunk should have
      Returns:
      this builder
    • tileSize

      public OMEZarrWriter.Builder tileSize(int tileWidth, int tileHeight)
      In Zarr files, data is stored in chunks. This parameter defines the size of chunks on the x and y dimensions. By default, these values are set to -1.

      Use a negative value to use the tile width/height of the provided image server.

      The provided tile width/height may not be used if this implies creating more chunks than the value given in setMaxNumberOfChunksOnEachSpatialDimension(int).

      Parameters:
      tileWidth - the width each chunk should have
      tileHeight - the height each chunk should have
      Returns:
      this builder
    • region

      public OMEZarrWriter.Builder region(ImageRegion boundingBox)
      Define a region (on the x-axis and y-axis) of the input image to consider.
      Parameters:
      boundingBox - the region to consider. Only the x, y, width, and height of this region are taken into account. Can be null to use the entire image
      Returns:
      this builder
    • zSlices

      public OMEZarrWriter.Builder zSlices(int zStart, int zEnd)
      Define the z-slices of the input image to consider.
      Parameters:
      zStart - the 0-based inclusive index of the first z-slice to consider
      zEnd - the 0-based exclusive index of the last z-slice to consider
      Returns:
      this builder
    • timePoints

      public OMEZarrWriter.Builder timePoints(int tStart, int tEnd)
      Define the timepoints of the input image to consider.
      Parameters:
      tStart - the 0-based inclusive index of the first timepoint to consider
      tEnd - the 0-based exclusive index of the last timepoint to consider
      Returns:
      this builder
    • onTileWritten

      public OMEZarrWriter.Builder onTileWritten(Consumer<TileRequest> onTileWritten)
      Set a function that will be called each time a TileRequest is successfully or unsuccessfully written.

      This function may be called from any thread.

      Parameters:
      onTileWritten - a function that will be called each time a TileRequest is successfully or unsuccessfully written
      Returns:
      this builder
    • build

      public OMEZarrWriter build(String path) throws IOException
      Create a new instance of OMEZarrWriter. This will also create an empty image on the provided path.
      Parameters:
      path - the path where to write the image. It must end with ".ome.zarr" and shouldn't already exist
      Returns:
      the new OMEZarrWriter
      Throws:
      IOException - when the empty image cannot be created. This can happen if the provided path is incorrect or if the user doesn't have enough permissions
      IllegalArgumentException - when the provided path doesn't end with ".ome.zarr" or a file/directory already exists at this location