Hi All,
I am working on a project trying to use tissue segmentation, then the positive cell detection tools to classify areas of a tumor as either positive or negative for a specific IHC. Unfortunately, the computing power I have is unable to manage the vast number of annotations created and crashes before I am able to export the images and annotations.
My solution to this problem was to break the images in the project down into smaller 512x512 tiles and complete the pre-trained positive cell detections and then to export these smaller patches to be stitched back together when necessary.
The aim of the project is to create cell centroid data with X&Y coordinates to perform spatial analysis of clone sizes.
Unfortunately, I have attempted to use the guides below.
The current script I am running is this
/**
* 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 = 1.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(downsample) // Define export resolution
.imageExtension('.jpg') // Define file extension for original pixels (often .tif, .jpg, '.png' or '.ome.tif')
.tileSize(512) // Define size of each tile, in pixels
.annotatedTilesOnly(false) // 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!'
Which executes and produces the files I need. However, the tiles include a large number of empty tiles.
My question is how do I edit this script to only create tiles of the annotated area produced by the tissue detection tool?
I thought using selectAnnotations() would work and have tried it in several places through the script to no avail.
Sorry for the long post.
I thought this was the solution but it did not work.
/**
* 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 = 1.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
selectAnnotations()
new TileExporter(imageData)
.downsample(downsample) // Define export resolution
.imageExtension('.jpg') // Define file extension for original pixels (often .tif, .jpg, '.png' or '.ome.tif')
.tileSize(512) // Define size of each tile, in pixels
.annotatedTilesOnly(false) // 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!'