diff --git a/CHANGELOG.md b/CHANGELOG.md index 749b4f036..b817bd8b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ - Better handle images with signed pixel data ([#1695](../../pull/1695)) - Reduce loading geojs when switching views in Girder ([#1699](../../pull/1699)) +### Changes + +- Ensure reading non-editable zarr files the c axis, if present, has a stride of 1 ([#1703](../../pull/1703)) + ## 1.30.1 ### Improvements diff --git a/sources/zarr/large_image_source_zarr/__init__.py b/sources/zarr/large_image_source_zarr/__init__.py index dad83351c..638cef80a 100644 --- a/sources/zarr/large_image_source_zarr/__init__.py +++ b/sources/zarr/large_image_source_zarr/__init__.py @@ -446,10 +446,16 @@ def _validateZarr(self): stride = 1 self._strides = {} self._axisCounts = {} - for _, k in sorted( - (-self._axes.get(k, 'tzc'.index(k) if k in 'tzc' else -1), k) - for k in self._axes if k not in 'xys' - ): + # 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): self._strides[k] = stride self._axisCounts[k] = baseArray.shape[self._axes[k]] stride *= baseArray.shape[self._axes[k]] diff --git a/test/test_source_zarr.py b/test/test_source_zarr.py new file mode 100644 index 000000000..030041e3a --- /dev/null +++ b/test/test_source_zarr.py @@ -0,0 +1,9 @@ +import large_image_source_zarr + +from .datastore import datastore + + +def testZarrAxisOrder(): + imagePath = datastore.fetch('synthetic_multiaxis.zarr.db') + source = large_image_source_zarr.open(imagePath) + assert source.metadata['IndexStride']['IndexC'] == 1