Skip to content

Refactor Bio-Formats reading code#2134

Merged
petebankhead merged 22 commits into
qupath:mainfrom
petebankhead:reading
May 13, 2026
Merged

Refactor Bio-Formats reading code#2134
petebankhead merged 22 commits into
qupath:mainfrom
petebankhead:reading

Conversation

@petebankhead

Copy link
Copy Markdown
Member

Major refactoring of the code used to read images using Bio-Formats.

The main goal was to split up large methods into smaller methods and classes to improve maintainability and help track down bugs.

The most problematic bug occurred whenever adjusting thresholds interactively on (usually highly-multiplexed) images: thread interrupts could cause exceptions at inopportune moments. This can still occur, but the updated code should be able to recover (whereas the previous code could repeatedly throw exceptions until QuPath was restarted).

One major change was the introduction to SynchronizedImageReader so there is far less exposure of classes from Bio-Formats itself. It is still possible to grab an OMEPyramidStore and modify it unwisely, but it's not possible/much harder to get the IFormatReader itself.

Along the way, some improvements (hopefully) were made to ROI reading, but I lack good data to check this with.

Otherwise, I've tried to preserve compatibility with recent QuPath releases - but more testing will be needed to ensure this has been successful.

Attempt to recover from more tile request failures.

Original issue could be replicated by opening a highly-multiplexed image (using Bio-Formats) and creating a thresholder. Adjusting the threshold and/or smoothing would result in many tile requests in quick succession, with interrupts to pending requests.

This caused 2 issues:
- ClosedChannelExceptions, which broke the Bio-Formats reader (which was cached for reuse, so this was a big problem)
- Exceptions could become stored in AbstractTileableImageServer, so were returned even when the situation had been 'fixed'.

This PR improves things by making sure the Bio-Formats reader is open and has the correct ID, and by 'forgetting' failed tiles more readily.
Trying to split it up into more manageable pieces...
A step towards protecting access to all IFormatReader instances.
@petebankhead petebankhead added this to the v0.8.0 milestone May 11, 2026
Failed tests remain a mystery (working locally)
Still trying to figure out what's going wrong
@petebankhead petebankhead merged commit 8a06742 into qupath:main May 13, 2026
5 of 6 checks passed
@petebankhead petebankhead deleted the reading branch May 13, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant