AllenCellModeling / napari-aicsimageio

Multiple file format reading directly into napari using pure Python
GNU General Public License v3.0
34 stars 10 forks source link

Different .czi image metadata for conda vs pip install #79

Open K-Meech opened 11 months ago

K-Meech commented 11 months ago

Description

I'm loading a czi image with napari-aicsimageio - 'Plate1-Blue-A-12-Scene-3-P3-F2-03.czi' from the OME sample data

If I've installed via conda like so:

conda create -n napari-env-aicsimagio -c conda-forge python=3.9 napari pyqt napari-aicsimageio

Then drag and drop the image on napari, it errors with failed with error: aicspylibczi is required for this reader. Install with pip install 'aicspylibczi>=3.0.5' 'fsspec>=2022.7.1'. It does still open the image though, and:

If I then install the dependencies via pip, as the error stated:

pip install aicspylibczi fsspec

Then open the image again, some of the metadata is changed e.g.:

Not sure if this is a bug - but why the large difference? + why are some of the useful things picked up before like the channel names / microscope model not picked up after installing aicspylibczi?

Thanks for your help!

Environment

Windows installation

psobolewskiPhD commented 11 months ago

So you have everything installed from conda-forge and aicspylibczi does not appear to have a binary there. Hence the initial message. However, conda-forge does have the java tooling for the bioformats reader which is installed along with the napari plugin, so I assume that's being used to open the image. After you pip install aicspylibczi, then I assume that aicspylibczi is used and apparently the two readers handle metadata differently or pass it differently to aicsimageio which is being used by this plugin.

evamaxfield commented 11 months ago

Yep, we simply do not have aicspylibczi built on conda. That library is tough to manage / build and we haven't had too much luck getting it working with conda. Install only works with pip

K-Meech commented 11 months ago

Thanks for the clarification both! Ah I see - I was wondering why it still managed to open the image (without aicspylibczi), but it using bioformats makes a lot of sense.

I was wondering in this case - if there would be a way to choose between bioformats and aicspylibczi if both are installed? (e.g. in the initial popup menu that appears when you open an image in napari). For this particular image, bioformats seems to handle the metadata better, so it would be great to be able to choose it without having to uninstall aicspylibczi or have a separate environment.

evamaxfield commented 11 months ago

Good question.... I don't think we have a method to select which reader to use when loading an image using the napari UI / file options (i.e. "load image" button from napari)

when using Python directly and opening napari from a python shell, you can create and enforce reader selection by:

from aicsimageio import AICSImage
from aicsimageio.readers.czi_reader import CziReader
# OR from aicsimageio.readers.bioformats_reader import BioformatsReader

img = AICSImage("path/to/file.czi", reader=CziReader)  # or reader=BioformatsReader
evamaxfield commented 11 months ago

I can also try to work on this problem in the move over to bioio (the new version of aicsimageio) -- my task this winter break is to create napari-bioio so will keep this issue in mind

K-Meech commented 11 months ago

Great - thanks @evamaxfield !