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

Empty dims when importing TIFF, LIF (vs say CZI) #24

Closed
psobolewskiPhD opened this issue Sep 13, 2021 · 7 comments · Fixed by #32
Closed

Empty dims when importing TIFF, LIF (vs say CZI) #24

psobolewskiPhD opened this issue Sep 13, 2021 · 7 comments · Fixed by #32

Comments

@psobolewskiPhD
Copy link
Collaborator

Description

When importing LIF, for example test/resources/s_1_t_1_c_2_z_1.lif
the two image layers (1 per C) are returned as [0 0 Y X] with T and Z being 0.
This means that tools like napari-stardist pre-trained 2D model doesn't work, because it requires just YX.
The same happens with s_1_t_1_c_1_z_1.ome.tiff

By comparison, importing example test/resources/s_1_t_1_c_1_z_1.czi returns an image layer with [Y X] and no extra dims.

Expected Behavior

All file types should have the same behavior, that of CZI.

Reproduction

Drag-and-drop any combination of LIF, TIFF, and CZI files from test/resources that don't have all channels used, so for example T=1 or Z=1.

Environment

napari: 0.4.11
Platform: macOS-11.5.2-arm64-arm-64bit
System: MacOS 11.5.2
Python: 3.9.6 | packaged by conda-forge | (default, Jul 6 2021, 08:51:19) [Clang 11.1.0 ]
Qt: 5.15.2
PyQt5: 5.15.4
NumPy: 1.21.0
SciPy: 1.7.0
Dask: 2021.06.2
VisPy: 0.7.0

OpenGL:
- GL version: 2.1 Metal - 71.7.1
- MAX_TEXTURE_SIZE: 16384

Screens:
- screen 1: resolution 1680x1050, scale 2.0

Plugins:
- aicsimageio-out-of-memory: 0.3.5
- console: 0.0.4
- napari-properties-viewer: 0.0.2
- napari-skimage-regionprops: 0.1.2
- ome-types: 0.2.9
- scikit-image: 0.4.11
- svg: 0.1.5

@evamaxfield
Copy link
Collaborator

Ahhhhh this is because we use the aicsimageio.reader.Reader instead of standardizing to aicsimageio.AICSImage.

Basically, a while back we made a decision to have napari-aicsimageio always return the "raw Reader data" aka, whatever is exactly in the file instead of standardizing to something.

This is basically to protect against formats that have a ton of dimensions that can be useful for visualization. We didn't want to clip those when we convert to standard.

So it's not that the LIF or TIFF is missing those dims, those dims just aren't specified in the file / metadata.


I think there is value in always having the standard dims. I.e. if a standard dimension isn't in the reader file just add it as a singleton. Thoughts?

@psobolewskiPhD
Copy link
Collaborator Author

So it's not that the LIF or TIFF is missing those dims, those dims just aren't specified in the file / metadata.

Maybe I wasn't clear: it's not that LIF and TIFF are missing dims, it's that empty dims are passed to napari. Napari doesn't care, but some plugins do—arguably they should be able to figure out that [0 0 Y X] is a 2D image and not 4D, but...

CZI import on the other hand (properly) eliminates empty dims and returns just dims that have data.

I worked around this with my open file importing using AICSImageIO, but it's a kludge?
/~https://github.com/psobolewskiPhD/napari_scripts/blob/796684a1dbebcfdd6b12571d91fbe40705b08e0c/Browse_LIF_widget.py#L56-L84

(BTW, I'm trying to enable colleagues to move a Fiji workflow to napari. Not code savvy, so it which relies on drag-n-drop to import and using napari plugins for segmentation and analysis.)

@evamaxfield
Copy link
Collaborator

Oh interesting.... Huh I will look into this.

@evamaxfield
Copy link
Collaborator

didnt have time to get to this... I also just don't know how to test it? How can I access the data once it is in the viewer?

@psobolewskiPhD
Copy link
Collaborator Author

If you use the file i mention above in test/resources/s_1_t_1_c_2_z_1.lif, drag-n-drop to open, then the scene is loaded and channels are unpacked.
Open the napari console and type:
viewer.layers["Green--FLUO--GFP"].data.shape
This should return:
(1, 1, 2048, 2048)
So there are two additional axes and StarDist won't work, but they're singletons, so they aren't doing anything.
Maybe clearer:
If you use s_1_t_1_c_1_z_1.czi

viewer.layers["Bright"].data.shape
Out[2]: (325, 475)

If you use s_1_t_1_c_1_z_1.ome.tiff

viewer.layers["Bright"].data.shape
Out[3]: (1, 1, 325, 475)

@evamaxfield
Copy link
Collaborator

Ahhhh thanks! Will try to get to this next week!

@psobolewskiPhD
Copy link
Collaborator Author

Maybe I find some time to take a look—I'm getting braver 🤕

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

Successfully merging a pull request may close this issue.

2 participants