I am trying to export tiles from a ROI (annotation) using QuPath. I have drawn a ROI, set a class and tried to modify the script below in order to export images in .tif format from this ROI. However when I run the code it is still exporting from the entire image, not just my selected region. I found an old thread on GitHub (https://github.com/qupath/qupath/issues/62) that discusses this issue, but when applying the suggested changes it doesn’t seem to work on the newest version of QuPath (v 0.2.0).
I think I am missing some additional information, but as I am new to writing and interpreting script I am not sure where to start. Any advice would be appreciated!
// SCRIPT TO EXPORT IMAGE TILES (CAN BE CUSTOMIZED IN VARIOUS WAYS)./ // Get the current image (supports 'Run for project') def imageData = getCurrentImageData() // Define output path (here, relative to project) def name = GeneralTools.getNameWithoutExtension(imageData.getServer().getMetadata().getName()) def pathOutput = buildFilePath(PROJECT_BASE_DIR, 'tiles', name) mkdirs(pathOutput) // Define output resolution in calibrated units (e.g. µm if available) double requestedPixelSize = 5.0 // Convert output resolution to a downsample factor double pixelSize = imageData.getServer().getPixelCalibration().getAveragedPixelSize() double downsample = requestedPixelSize / pixelSize // Create an exporter that requests corresponding tiles from the original & labelled image servers new TileExporter(imageData) .downsample(1) // Define export resolution .imageExtension('.tif') // Define file extension for original pixels (often .tif, .jpg, '.png' or '.ome.tif') .tileSize(2064, 1600) // Define size of each tile, in pixels .annotatedTilesOnly(true) // If true, only export tiles if there is a (classified) annotation present .overlap(64) // Define overlap, in pixel units at the export resolution .writeTiles(pathOutput) // Write tiles to the specified directory print 'Done!'