girder / large_image

Python modules to work with large multiresolution images.
http://girder.github.io/large_image/
Apache License 2.0
196 stars 43 forks source link

Zarr axis order #1703

Open manthey opened 1 month ago

manthey commented 1 month ago

Prior to PR #1625, we always preferred to have the C axis have a stride of 1 if it was present. This changed with writing axes, but I don't think we want this for the general reading case. There are some users who expect the channel to be the inner mode frame axis.

This specifically is here: https://github.com/girder/large_image/blob/master/sources/zarr/large_image_source_zarr/__init__.py#L449-L452

We could make it conditional on whether we are editing or not, since while using the image as a sink reading back in a different axis order could be surprising. Specifically, we could do something like

        # If we aren't in editable mode, prefer the channel axis to have a
        # stride of 1, then the z axis, then the t axis, then sorted by the
        # axis name.
        axisOrder = ((-'tzc'.index(k) if k in 'tzc' else 1, k)
                     for k in self._axes if k not in 'xys')
        # In editable mode, prefer the order that the axes are being written.
        if self._editable:
            axisOrder = ((-self._axes.get(k, 'tzc'.index(k) if k in 'tzc' else -1), k)
                         for k in self._axes if k not in 'xys')
        for _, k in sorted(axisOrder):
            ...

Note that this will cause testFrameValues test in test_sink.py to fail.