Last active
December 1, 2025 10:52
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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