girder / large_image

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

Zarr sink channels and samples issue #1554

Closed manthey closed 2 months ago

manthey commented 2 months ago

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.