Skip to content

Instantly share code, notes, and snippets.

@petebankhead
Last active December 1, 2025 10:52
Show Gist options
  • Select an option

  • Save petebankhead/cafad14973000ab382b18fd4420590b3 to your computer and use it in GitHub Desktop.

Select an option

Save petebankhead/cafad14973000ab382b18fd4420590b3 to your computer and use it in GitHub Desktop.
Quick QuPath script to try to read all tiles in an image, so that failing tiles can be identified
/**
* Quick script to try to read all tiles in an image, so that failing tiles can be identified.
* (Not very thoroughly tested)
*/
var server = getCurrentServer()
var tiles = server.getTileRequestManager().getAllTileRequests()
boolean doParallel = false // Set to true if speed is very important (but may complicate interpretation if tiles are slow to read & you've lots of processors)
var failed = []
if (doParallel) {
failed = tiles.parallelStream().filter(t -> !checkRead(server, t)).toList()
} else {
for (var tile : tiles) {
if (!checkRead(server, tile))
failed.add(tile)
}
}
println "${failed.size()} failed tile(s)"
failed.each {
println it
}
def checkRead(server, tile) {
try {
var img = server.readRegion(tile.getRegionRequest())
return img != null
} catch (Exception e) {
getLogger().error(e.getMessage(), e)
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment