fix(itkwasm): fall back to the image size when the buffered region is empty - #1577
Merged
thewtex merged 2 commits intoAug 5, 2026
Merged
Conversation
… empty InsightSoftwareConsortium#1545 switched the reshape source from size to bufferedRegion.size, which information-only outputs need since they carry a logical size but no allocated buffer. Not every producer fills the buffered region though. Readers in itkwasm-image-io 1.6.1 return it empty, so the reshape target became an empty tuple and every read failed: from itkwasm_image_io import imread imread("cthead1.png") # ValueError: cannot reshape array of size 65536 into shape () The change landed on 30 June but only surfaced when 1.0b199 shipped, since nothing was published in between. Two producers use two conventions, and one line has to serve both: information-only size=[10,34,34] bufferedRegion=[0,0,0] -> region file reader size=[256,256] bufferedRegion=[] -> size `or` covers both without giving up either: [0,0,0] is a non-empty list and still wins, [] falls back.
vboussot
force-pushed
the
fix/buffered-region-fallback
branch
from
August 5, 2026 19:36
15359cb to
ea12da1
Compare
to_py() checked `is not None`, so a buffered region that is present but
carries an empty size still produced an empty reshape target. That is what
the emscripten readers return, and it fails the same way as the native
runtime:
itkwasm_image_io_emscripten/read_image_async.py
ValueError: cannot reshape array of size 10000 into shape ()
Fall back to the largest possible region when the buffered size is missing or
empty, matching pipeline.py.
vboussot
force-pushed
the
fix/buffered-region-fallback
branch
from
August 5, 2026 19:37
ea12da1 to
7f8054e
Compare
Collaborator
Author
|
@thewtex The remaining red check is main's red, not this PR's: itkwasm-python (ubuntu-24.04, 12, compare-images) runs the downstream packages' Pyodide tests against itkwasm 1.0b199 from PyPI. The same single job fails on main's latest Python Wasm run. It will turn green once this lands and itkwasm is republished; every job that exercises the branch's code passes. |
thewtex
approved these changes
Aug 5, 2026
thewtex
merged commit Aug 5, 2026
4912b84
into
InsightSoftwareConsortium:main
30 of 66 checks passed
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.
Summary
Context
#1545 switched the reshape source from
sizetobufferedRegion.size, whichinformation-only outputs need since they carry a logical size but no allocated
buffer.
Not every producer fills the buffered region though. Readers in
itkwasm-image-io1.6.1 return it empty, so the reshape target became anempty tuple and every read fails:
The change landed on 30 June but only surfaced when 1.0b199 shipped, since
nothing was published in between.
Two producers use two conventions, and one line has to serve both:
sizebufferedRegion[10,34,34][0,0,0][256,256][]orcovers both without giving up either:[0,0,0]is a non-empty list andstill wins,
[]falls back.Validation
test_pipeline_image_without_buffered_regionmirrors the information-onlytest from #1545 for the empty case. It fails without this change and passes
with it, and the information-only test keeps passing either way.
Core Python suite: 35 passed, 4 skipped, excluding the Pyodide and JS package
config tests.
Downstream, ngff-zarr went from 23 CI failures to 811 passed against a patched
1.0b199, and reading a file then downsampling it through
itkwasm-downsample-cucimworks end to end on a GPU.Also worth a look
pyodide.pyhas a fallback but testsis not None, so it would miss thiscase, which is a buffered region that is present with an empty size. Same
latent issue, same fix. I have not exercised that path.