⚡ Improve Metadata Handling for WSI Readers#1001
⚡ Improve Metadata Handling for WSI Readers#1001shaneahmed wants to merge 15 commits intodevelopfrom
Conversation
- Try OpenSlide Reader for tiff files first - Fallback to calculating objective power from mpp
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
OpenSlideWSIReader for tiff Files FirstThere was a problem hiding this comment.
Pull request overview
This PR standardizes metadata inference (objective power and MPP) across WSI readers by introducing a shared inference helper and updating multiple reader implementations and tests. It also adjusts reader-selection priority so TIFF inputs are attempted via OpenSlide first.
Changes:
- Add a centralized
WSIReader._estimate_mpp_objective_power()and use it across multiple readers. - Update reader selection to try OpenSlide first for
.tif/.tiff. - Update remote samples and expand tests for DICOM/TIFF metadata inference and warning behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
tiatoolbox/wsicore/wsireader.py |
Adds OpenSlide-first selection for TIFF and introduces centralized MPP/objective-power inference used across readers. |
tiatoolbox/utils/misc.py |
Broadens typing for objective_power2mpp to accept np.ndarray. |
tiatoolbox/data/remote_samples.yaml |
Updates DICOM sample filename and adds a second DICOM sample entry for new metadata tests. |
tests/test_wsireader.py |
Adds/updates DICOM metadata assertions and adds a new test for objective-power presence/inference. |
tests/test_tiffreader.py |
Updates OME-TIFF metadata tests and adds a warning-logging test for missing metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
measty
left a comment
There was a problem hiding this comment.
This introduces a regression on that ome.tiff you sent me a while ago to check multi-channel reader on (20240625_144804_1_08TcnB_Kidney_panel_June_RP_52top51bottom.ome.tiff).
In develop, pyramid is seen:
Whereas opening the same slide in this PR:
No pyramid is seen so it is slow and uses loads of memory, and the slide doesn't display right (seems to be black & white?)
@measty This commit 4c0ba9a resolves this issue. I have tested the WSI Registration notebook and the mIF images, both work fine now. However, it fails on MONKEY challenge image. |
- Update wsireader mpp checks




Summary
This PR standardises and improves metadata inference across all WSI readers by introducing a unified mechanism for estimating missing objective power and MPP. It updates all major reader implementations (TIFF, DICOM, OpenSlide, JP2, NGFF, fsspec), fixes reader‑selection ordering, and adds extensive tests to validate inference behaviour and warnings. New sample data is included to support expanded DICOM metadata coverage.
🔑 Key Changes
1. Centralised Metadata Inference
WSIReader._estimate_mpp_objective_power()as the shared method for inferring missing objective power and MPP.2. Unified Metadata Handling Across Readers
All major WSI readers now use the central inference method:
TIFFWSIReaderDICOMWSIReaderOpenSlideWSIReaderJP2WSIReaderNGFFWSIReaderFsspecJsonWSIReaderThis ensures consistent behaviour when metadata is missing or partially defined.
3. Improved Reader Selection Logic
try_openslide()and updates selection priority so TIFF files are first attempted via OpenSlide.4. Expanded and Strengthened Test Coverage
New and updated tests now cover:
dicom-2sample with known objective/MPP valuesAssertions have been updated to reflect the new inference logic.
5. Updated Remote Sample Data
CMU-1.dicom.zipwithCMU-1-Small-Region.dicom.zip.dicom-2sample (JP2K-33003-1.zip) to support metadata‑specific tests.6. Cleanup and Minor Fixes
TransformedWSIReader.objective_power2mpp.This PR resolves Jupyter Notebook 10 – WSI Reading (#998) and KongNet Notebook for MONKEY dataset (#987).