fix: read Imaris .ims via direct HDF5 (multi-channel)#19
Merged
Conversation
Real .ims files broke conversion with an IndexError / broadcast error: the imaris-ims-file-reader array interface squeezes singleton dims and pads slices to chunk boundaries, which da.from_array can't handle, and its file handle closes on GC (stale h5py reads under threads). Read the underlying HDF5 Data datasets directly instead: open our own h5py handle (kept alive by the dataset refs in the dask graph), stack the per-(timepoint, channel) 3-D arrays, and crop the Imaris chunk padding to the true extent the reader reports. dask's default read lock makes the threaded h5py reads safe. Verified on a real 5-D (1,3,115,37716,27277) 3-channel file: opens as czyx with correct µm calibration and converts without error. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Real
.imsfiles failed to convert (IndexError/ broadcast error). Theimaris-ims-file-readerarray interface squeezes singleton dims, pads slices to chunk boundaries, and closes its file handle on GC — all of which breakda.from_array.Fix: read the underlying HDF5
Datadatasets directly — open our ownh5py.File(kept alive via the dataset refs in the dask graph), stack the per-(timepoint, channel) 3-D arrays, crop the Imaris chunk padding to the true extent. dask's default read lock makes the threaded h5py reads safe.Verified on a real 5-D (1, 3, 115, 37716, 27277) 3-channel file: opens as
czyxwith correct µm calibration (z=0.35, y=x=0.108) and converts a crop without error. Suite green (29 passed), ruff clean.🤖 Generated with Claude Code