Repository navigation
Read the H&E pixel size from store attributes in SpatialDataset - #27
Merged
Merged
Conversation
`SpatialDataset.get_native` derived the pixel size from the relative scale of the shape-space and pixel-space transformations. For H&E-only stores both are identity, so it returned 1.0 um/px and the 112 px crop covered ~25 um instead of 112 um. It now reads `spatialdata_io_reader` from the store attrs: `source_mpp` for xenium stores, `source_he_mpp` for H&E stores. A store with neither the attributes nor a micron-scaled `nucleus_boundaries` raises instead of assuming 1.0 um/px, and `native_mpp` can be passed to override. The batch inference scripts now log the pixel size and the micron span of the crop for every slide. Predictions on H&E-only stores change and must be regenerated; xenium stores are unchanged. Tested: `hatch test` (44 passed, 4 skipped) with new field-of-view tests for xenium, H&E-only and attribute-less layouts; `prek` hooks on the changed files all pass. Ran `run_inference_flash.py` end to end on four ~220-cell subsets (xenium, xenium protein, LMUP TMA, H&E-only) on an H100 node: pixel sizes 0.2737, 0.2740, 0.2624 and 0.2210 um/px, every crop 112 um, 0 failures. `tests/__init__.py` lets mypy resolve the relative `.conftest` import.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
+ Coverage 47.63% 48.20% +0.56%
==========================================
Files 10 10
Lines 1016 1029 +13
==========================================
+ Hits 484 496 +12
- Misses 532 533 +1
🚀 New features to boost your workflow:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
SpatialDataset.get_nativenow takes the H&E pixel size from the store'sspatialdata_io_readerattributes (source_mppforxenium,source_he_mppforhe) instead of the transformations.native_mppcan also be passed explicitly. A store with neither the attributes nor a micron-scalednucleus_boundariesnow raises instead of assuming 1.0 um/px. The batch inference scripts log the pixel size and the micron span of the crop per slide.Why
H&E-only stores have identity transformations, so the old code returned 1.0 um/px and the 112 px crop covered ~25 um instead of 112 um. Predictions on H&E-only stores change and need regenerating; xenium stores are unchanged.
Tested
hatch test: 44 passed, 4 skipped, including new field-of-view tests for xenium, H&E-only and attribute-less layouts.prekhooks on the changed files: all pass (tests/__init__.pyis added so mypy resolves the relative.conftestimport).run_inference_flash.pyend to end on four ~220-cell subsets (xenium, xenium protein, LMUP TMA, H&E-only) on an H100 node: 0.2737, 0.2740, 0.2624 and 0.2210 um/px, every crop 112 um, 0 failures.