Skip to content

Commit

Permalink
Zarr file axis order
Browse files Browse the repository at this point in the history
Ensure reading non-editable zarr files the c axis, if present, has a
stride of 1.  PR #1625 changed this.
  • Loading branch information
manthey committed Oct 25, 2024
1 parent b5b56ae commit 76472a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ([#1702](../../pull/1702))

## 1.30.1

### Improvements
Expand Down
14 changes: 10 additions & 4 deletions sources/zarr/large_image_source_zarr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down

0 comments on commit 76472a4

Please sign in to comment.