girder/large_image

Zarr sink channels and samples issue

Closed this issue · 0 comments

This code:

import large_image, numpy as np

s = large_image.new()
for c in range(5):
    s.addTile(np.random.random((4, 4, 3)), c=c)

s.channelNames = ['a', 'b', 'c', 'd', 'e']
s.write('example.zip')
t = large_image.open('example.zip')
assert len(t.metadata['channels'] ) == 5

fails. The channel names aren't written because of the code on https://github.com/girder/large_image/blob/master/sources/zarr/large_image_source_zarr/__init__.py#L677
which should probably be channel_axis = self._axes.get('c', self._axes.get('s')), and then https://github.com/girder/large_image/blob/master/sources/zarr/large_image_source_zarr/__init__.py#L708 should check that channel_axis is not None rather than not falsy. However, these changes then causes the code in https://github.com/girder/large_image/blob/master/sources/zarr/large_image_source_zarr/__init__.py#L712-L720 to be incorrect as bands (samples) and channels are conflated.