OIR: resolve pixel block paths through the Location mapping - #4470
Open
PEEKPerformer wants to merge 1 commit into
Open
PEEKPerformer wants to merge 1 commit into
PEEKPerformer wants to merge 1 commit into
Conversation
When an .oir file is opened through a mapped location, e.g. as an
entry in a zip file opened by ZipReader, initFile labels each pixel
block with a CWD-absolutized path that does not exist on disk.
Metadata parsing succeeds because the stream is opened from currentId,
which resolves through the Location mapping, but every subsequent
openBytes call reopens block.file directly and throws
FileNotFoundException.
Keep the mapped ID as the pixel block label when currentId is mapped,
so that copyPixelBlock reopens blocks through the same mapping. For
unmapped files the label is unchanged.
To reproduce with any .oir file:
zip sample.zip sample.oir
bfconvert sample.zip out.ome.tiff
Before this change the conversion fails with FileNotFoundException;
after it, output pixels are identical to converting the .oir directly.
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.
Opening an
.oirfile through a mapped location, for example as an entry in a zip file opened by the existingZipReader, initializes fine and reports correct metadata, but every pixel read then fails withFileNotFoundException.initFilelabels each pixel block withcurrent.getAbsolutePath(), which resolves a mapped ID against the working directory and produces a path that does not exist. The metadata pass succeeds because its stream is opened fromcurrentId, which resolves through theLocationmapping;copyPixelBlocklater reopensblock.filedirectly and misses the mapping.The fix keeps the mapped ID as the pixel block label when
currentIdis mapped, so pixel blocks reopen through the same mapping. For unmapped files the label is exactly the same string as before.To reproduce with any
.oirfile, no special data needed:Tested with the public file
Olympus-OIR/imagesc-105684/1202-interval_10sec_sequence_frame.oirfrom downloads.openmicroscopy.org:showinf -nopix sample.zipworks,bfconvert sample.zipthrowsFileNotFoundExceptionfromOIRReader.copyPixelBlock..oirdirectly (verified with numpy over both OME-TIFFs, 8 timepoints x 2 channels x 512x512 uint16).showinfoutput and-omexml-onlyoutput for the same file are identical between a build without and with this change, after normalizing run-specific timestamps and UUIDs.Location.mapFilewith aByteArrayHandle, the ReadWriteInMemory pattern) previously failed the same way for.oirand now works; the first plane read back from memory is byte-identical to the converted output.ant testpasses.One related limitation is intentionally out of scope: multi-file
.oirdatasets discover their companion parts via directory listing, which cannot see mapped entries, so a zip containing a multi-part acquisition would still only read the main file. Self-contained.oirfiles, whichisSingleFiledefines as anything under 1 GB, work with this change, and the zip-wrapped files that motivated it are all in that category.Context: this came out of the zip-wrapped
.poir/.mpoirdiscussion in #4465. A.poirreader that delegates toOIRReaderthrough mapped locations, which is howZipReadercomposes readers today, needs this fix whether the reader lives in core or externally. It is also useful on its own, since it makes zipped and in-memory.oirwork with the readers that already exist.