Skip to content

Keep floating-point level_downsamples in WSIPatcher._prepare - #256

Open
chenyangsu wants to merge 1 commit into
mahmoodlab:mainfrom
chenyangsu:fix/wsipatcher-float-level-downsample
Open

chenyangsu wants to merge 1 commit into
mahmoodlab:mainfrom
chenyangsu:fix/wsipatcher-float-level-downsample

Conversation

@chenyangsu

Copy link
Copy Markdown

On pyramidal slides whose level dimensions round up (for example (10001, 10001) -> (5001, 5001)), OpenSlide and OMEZarrWSI report floating-point level_downsamples slightly under an integer such as 1.9998. WSIPatcher._prepare() casts self.wsi.level_downsamples[level] with int(...), truncating 1.9998 to 1 and computing patch_size_level = 512 instead of 256 at 20x from a 40x slide (2x FOV per side).

Keeping level_downsample as a float matches WSI.get_best_level_and_custom_downsample and the reader implementations, with a unit test in tests/test_patcher_level_downsample.py. Happy to move the test into tests/test_patcher_scan_order.py if you prefer.

Testing: python -m unittest tests/test_patcher_level_downsample.py tests/test_patcher_scan_order.py tests/test_wsi_core_behaviors.py tests/test_dump_patches.py tests/test_empty_coords_pipeline.py (24 passed; 2 new failed on main).

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