Description
The read_tiff function seems like it will error for any non-imagej formatted image written by tifffile -- and perhaps any non-imagej tiff whatsoever -- as tifffile's read function will find the "imagej_metadata" attribute (which when not saved in imagej format = None) and that creates an error in NAVis, since NAVis expects the imagej_metadata attribute to not exist at all.
Secondarily, when I tried saving the image as with imagej metadata, because it was greyscale, navis still errored because of no support for greyscale / 2D tiffs (only 4D ZCYX tifs).
Is there a simple / alternate way to load numpy array data or .tiff image data into NAVis?
To Reproduce
import navis
import tifffile
import numpy
directory = "C:/some/place/on/your/disc"
array = np.zeros([500,400]) ## should be any 2-dimensional grey-scale array which fails
array = array[np.newaxis, np.newaxis, :, :] ## trying to mimic "TCYX" order by adding axes changes nothing
#### Non-imageJ format fails:
tifffile.imwrite(directory, array)
navis.read_tiff(directory)
#### ImageJ format for greyscale / 2D fails:
tifffile.imwrite(directory, array.astype("uint8"), imagej = True, metadata = {})
navis.read_tiff(directory)
...
The arrays I'm trying to save are from an already skeletonized cell segmentations (hence the grayscale / 2D). What I've been working with tend to be small (smaller then the np.zeros faux-data in the example) because they are not necessarily neurons nor from very high resolution images. I have tried adding dimensions manually before saving to make them faux-4D, but somewhere in the save / load process they revert to 2D.
This error should apply to all non-imagej format tiffs:

This error should apply to greyscale imagej format tiffs:

Expected behavior
read_tiff reads tiffs
Your system
- NAVis version: 1.7.0
-
- Python: 3.9
- Operating System: windows
Description
The read_tiff function seems like it will error for any non-imagej formatted image written by tifffile -- and perhaps any non-imagej tiff whatsoever -- as tifffile's read function will find the "imagej_metadata" attribute (which when not saved in imagej format = None) and that creates an error in NAVis, since NAVis expects the imagej_metadata attribute to not exist at all.
Secondarily, when I tried saving the image as with imagej metadata, because it was greyscale, navis still errored because of no support for greyscale / 2D tiffs (only 4D ZCYX tifs).
Is there a simple / alternate way to load numpy array data or .tiff image data into NAVis?
To Reproduce
The arrays I'm trying to save are from an already skeletonized cell segmentations (hence the grayscale / 2D). What I've been working with tend to be small (smaller then the np.zeros faux-data in the example) because they are not necessarily neurons nor from very high resolution images. I have tried adding dimensions manually before saving to make them faux-4D, but somewhere in the save / load process they revert to 2D.
This error should apply to all non-imagej format tiffs:

This error should apply to greyscale imagej format tiffs:

Expected behavior
read_tiff reads tiffs
Your system