Pete’s script for exporting tiles with names and coordinates works well in 0.2.2 when substituting the TileExporter line (see working script below). I’m wondering if anyone has a working script that similarly can import binary masks.
Thats it, a script that imports masks and creates annotations in the corresponding location in qupath after e.g. deep learning prosessing of the exported tiles with corresponding names (e.g. “…-mask.png”) exported with the above script (file name example: “Image15202 [x=0,y=0,w=11129,h=11129].tif”). Much back and forth in a previous discussion about this (Importing binary masks in QuPath), and seems like Pete’s working on it, but also seems like some of you have been successful in doing this already. I would be very greatful if you posted a working script for Qupath 0.2.2 (or for Qupath 0.1.2 with a corresponding export script).
Working export script (need corresponding import script for masks):
/** * Script to export image tiles (can be customized in various ways). */ import qupath.lib.images.writers.TileExporter // 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 = 0.6 // 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(downsample) // Define export resolution .imageExtension('.tif') // Define file extension for original pixels (often .tif, .jpg, '.png' or '.ome.tif') .tileSize(508) // 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!'