Repository navigation
Results with known axes open in Fiji as hyperstacks (WithAxes, result_axes_v1) - #165
Merged
Merged
Conversation
…_axes_v1) A corrected time-lapse came back to Fiji as one long stack (T x Z slices), because the worker wrote every result as plain TIFF pages. Now an image/labels result whose axes are known, declared with Axes or returned with the new WithAxes(array, axes), is written as an ImageJ hyperstack when its axes are in ImageJ order (a subsequence of T Z C Y X ending in Y X) and its pixel type is one ImageJ stores (uint8, uint16, int16, float32). The array is never reordered: tifffile reads back the same array, so napari, notebooks and the case runner see what they saw before. Unknown axes (the CZYX default guess for 4D) and any other order are written as before. WithAxes axes are checked (letters, one per dimension, the same as a declared Axes). Feature result_axes_v1, version 0.3.0a4. Checked with Fiji's own reader: TZYX opens as slices x frames, ZCYX as channels x slices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6VXx7mT1FYsKmB1184
Independent review found that ImageJ cannot record a T, Z or C of size 1, so tifffile read a single-slice or single-time-point result back without that dimension, also for a tool that only declares Axes(...): (3, 1, Y, X) TZYX came back as (3, Y, X). Such results, and results of 4 GiB or more (an ImageJ TIFF is never a BigTIFF), are now written as before. Tests: size-1 dimensions (fail without the fix), labels, booleans, declared Axes alone, the size limit; the pixel-type fallback now uses a type portable_dtype keeps (big-endian uint16). The round-trip matrix gets the tool echo_image_with_axes and 44 cases (11 shapes, size-1 ones included, x 4 dtypes) that check the array read back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6VXx7mT1FYsKmB1184
Found by the independent re-review: the test pins the exact list of feature ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6VXx7mT1FYsKmB1184
The test pins the exact list of ids (run records have none of their own); result_axes_v1 is about result files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6VXx7mT1FYsKmB1184
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.
Problem. A tool's 4D result, such as Fast4DRegPy's corrected time-lapse, opened in Fiji as one long stack (T × Z slices). The worker wrote every result as plain TIFF pages, and Fiji doesn't know what each dimension is.
Change
WithAxes(array, axes): a tool whose output axes depend on its input can return them at run time, e.g.return WithAxes(corrected, "TZYX"). They're checked: letters from T C Z Y X S, one per dimension, and the same as a declaredAxesif there is one.When a result is written as an ImageJ hyperstack. All of these must hold:
AxesorWithAxes);Fiji's own reader then shows time points, slices and channels. The array is never reordered, so
tifffile.imreadreturns the same array, and napari, notebooks and the case runner see what they saw before.Everything else is written as before, including 4D results without known axes (the
CZYXdefault is a guess and must not decide how Fiji shows a time-lapse).Feature
result_axes_v1, version0.3.0a4; PROTOCOL, AUTHORING, CAPABILITIES and HOST_FEATURES updated. No change to the napari, Fiji or QuPath plugins.Independent review. A separate agent reviewed the first commit and found a real bug: ImageJ can't record a T, Z or C of size 1, so a single-slice or single-time-point result (even with only a declared
Axes) came back without that dimension. The second commit fixes it (size-1 dimensions and ≥ 4 GiB results are written as before). It also replaces a test that couldn't fail, and adds round-trip matrix cases asdocs/TESTING.mdasks.Tests
tests/test_result_axes.py, 17 tests: hyperstack metadata and identical read-back for TYX, TZYX, ZCYX, CYX and TZCYX in each pixel type; size-1 dimensions (6 sub-cases fail without the fix); labels; booleans; declaredAxesonly; the size limit; and the refusals.echo_image_with_axes, 44 cases (11 shapes, size-1 ones included, × 4 dtypes) across worker, CLI, snippet and notebook.Checked in Fiji (
IJ.openImage, Fiji 2.18):TZYX4 × 6 opens as a hyperstack with 6 slices × 4 frames,ZCYXas 3 channels × 6 slices,TYXas 5 frames,CYXas 3 channels. A 4D result without axes still opens as 24 slices.Host check. Fast4DRegPy's tools return their results with
WithAxes, falling back to plain arrays on older Tools (separate PR in Fast4DRegPy). Its napari and Fiji UI audits run against this branch. There's no Playground tool:WithAxesis a return wrapper, not a declared type, and it's covered by the matrix tool above and the Fast4DRegPy audit.Release. After merge, the maintainer creates
v0.3.0-alpha.4; a template PR then movesLC_TOOLS_PIN.Generated by Claude Code