czbiohub-sf / iohub

Pythonic and parallelizable I/O for N-dimensional imaging data with OME metadata
https://czbiohub-sf.github.io/iohub/
BSD 3-Clause "New" or "Revised" License
29 stars 6 forks source link

add TIFF writer #99

Open rachel-banks opened 1 year ago

rachel-banks commented 1 year ago

It would be great to have a writer for tiff files that preserves as much metadata as possible, that can be read by ImageJ. We use single channel z-stack TIFF files for segmentation with Cellpose. It would be useful if users could also open the images in ImageJ and see properties like the channel name, pixel size, and z step.

I think a useful folder structure would be: dataset > position > channel_name_t_idx.tiff

ziw-liu commented 1 year ago

During an offline meeting @Soorya19Pradeep pointed out that CellPose takes TIFF files as input but does not require any metadata. @rachel-banks can you elaborate on why you need ImageJ metadata for this intermediate step? Also, are you expecting a python API or CLI for this writer?

mattersoflight commented 1 year ago

@ziw-liu @rachel-banks I think that we need just enough metadata so that ImageJ readers (the built-in hyperstack reader and BioFormats reader) can load the ND data in the correct order.

rachel-banks commented 1 year ago

As long as the ImageJ readers can load the data in the correct order, it is fine. It would be nice to have the metadata for someone (maybe an RA or scientist) working with the images to be able to easily access the metadata, without having to go to the zarr store.

ziw-liu commented 1 year ago

It would be nice to have the metadata for someone (maybe an RA or scientist) working with the images to be able to easily access the metadata, without having to go to the zarr store.

Can you elaborate on what are these metadata and where are they extracted from?

JoOkuma commented 1 year ago

My impression is that cellpose is not propagating the metadata to the output labels, is that correct @rachel-banks?

CZI is working on a metadata plugin for napari, so there should be an interface for it soon.

rachel-banks commented 1 year ago

@ziw-liu metadata such as pixel size, z step, and channel name, they should all be in the micro-manager metadata

@JoOkuma that's correct

ziw-liu commented 1 year ago

@ziw-liu metadata such as pixel size, z step, and channel name, they should all be in the micro-manager metadata

The Zarr stores written by iohub always have the channel name and their display color. Z-step are also written if it's converted from a MM dataset. Currently only NDTIFF conversion writes pixel sizes, but we plan to support that for OME-TIFF as well (#103). These will show up in napari as layer names or layer metadata (if using the plugin @JoOkuma mentioned).

Given that these properties are accessible from a GUI, I think we can avoid data duplication and fragmentation (the purpose of iohub) by helping the users view them in napari instead of ImageJ, and keeping the intermediate TIFFs minimal just for CellPose.

JoOkuma commented 1 year ago

So it might be the case of contributing to cellpose so the metadata is propagated or writing a custom processing script and propagating the metadata yourself there.