Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to get czi data with imperfect metadata #119

Open
osthomas opened this issue Jun 15, 2024 · 0 comments
Open

Failure to get czi data with imperfect metadata #119

osthomas opened this issue Jun 15, 2024 · 0 comments

Comments

@osthomas
Copy link

System and Software

  • aicspylibczi Version: 3.1.2
  • Python Version: 3.12.3
  • Operating System: linux

Description

I have several images with apparently partially imperfect metadata:

image

I can open the image using Fiji and it displays correctly in all Z planes.

With aicsimageio, however, there is a mismatch between the dask and numpy representations of the image data. Computations on the array raise an error.

I also tried to read the image with bioio and bioio-czi and got the same error.

>>> aics = AICSImage(fpath)
>>> aics.shape

(1, 1, 76, 1024, 1024)
>>> aics_dask = aics.get_image_dask_data()
>>> aics_dask.shape
(1, 1, 76, 1024, 1024)
>>> aics_np = aics.get_image_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../lib/python3.12/site-packages/aicsimageio/aics_image.py", line 724, in get_image_data
    return self.data
           ^^^^^^^^^
  File ".../lib/python3.12/site-packages/aicsimageio/aics_image.py", line 542, in data
    return self.xarray_data.data
           ^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/aicsimageio/aics_image.py", line 501, in xarray_data
    self.reader.xarray_data
  File ".../lib/python3.12/site-packages/aicsimageio/readers/reader.py", line 372, in xarray_data
    self._xarray_data = self._read_immediate()
                        ^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/aicsimageio/readers/czi_reader.py", line 732, in _read_immediate
    return xr.DataArray(
           ^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/xarray/core/dataarray.py", line 456, in __init__
    coords, dims = _infer_coords_and_dims(data.shape, coords, dims)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../lib/python3.12/site-packages/xarray/core/dataarray.py", line 195, in _infer_coords_and_dims
    _check_coords_dims(shape, new_coords, dims_tuple)
  File ".../lib/python3.12/site-packages/xarray/core/dataarray.py", line 129, in _check_coords_dims
    raise ValueError(
ValueError: conflicting sizes for dimension 'Z': length 69 on the data but length 76 on coordinate 'Z'

czifile also reads the image:

>>> import czifile
>>> czifile.CziFile(fpath).asarray().shape
(1, 1, 1, 1, 76, 1024, 1024, 1)

I have simple regular Z stacks, so in my application I can safely disregard the lost metadata. Maybe this is not so simple in more complicated setups? In any case, I think aicsimageio should either perform error recovery and read it anyway, or error out earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant