Skip to content

Read the H&E pixel size from store attributes in SpatialDataset - #27

Merged
rushin682 merged 1 commit into
mainfrom
worktree-fix-native-mpp-from-attrs
Oct 8, 2026
Merged

rushin682 merged 1 commit into
mainfrom
worktree-fix-native-mpp-from-attrs

Conversation

@rushin682

Copy link
Copy Markdown
Collaborator

What

SpatialDataset.get_native now takes the H&E pixel size from the store's spatialdata_io_reader attributes (source_mpp for xenium, source_he_mpp for he) instead of the transformations. native_mpp can also be passed explicitly. A store with neither the attributes nor a micron-scaled nucleus_boundaries now 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.
  • prek hooks on the changed files: all pass (tests/__init__.py is added so mypy resolves the relative .conftest import).
  • run_inference_flash.py end 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.

`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.
@rushin682
rushin682 requested a review from manuel-tran as a code owner October 8, 2026 09:54
@rushin682
rushin682 merged commit e96e260 into main Oct 8, 2026
7 checks passed
@rushin682
rushin682 deleted the worktree-fix-native-mpp-from-attrs branch October 8, 2026 09:57
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.20%. Comparing base (7720be5) to head (a312202).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/phoenix/datasets/zarr_dataset.py 94.11% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
src/phoenix/datasets/zarr_dataset.py 96.38% <94.11%> (-0.76%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants