royerlab / ultrack

Cell tracking and segmentation software
https://royerlab.github.io/ultrack
BSD 3-Clause "New" or "Revised" License
86 stars 11 forks source link

Recommended image file formats #67

Open tischi opened 8 months ago

tischi commented 8 months ago

hi @JoOkuma,

What are your recommended image file format? Are OME-TIFF or OME-Zarr good? What would be the pros and cons?

If so, are you shipping python libraries to open them?

Our current code that we got from you looks like this:

    im = imread(im_path)  # T, C, Z, Y, X
    scale = (10, 1, 1)

    if interactive:
        viewer = napari.Viewer()
        viewer.add_image(im, channel_axis=1, scale=scale)

    cells = im[:, 1]

    detection = _detect_foreground(cells)
    # edges = _segmentation_topology(cells)
    edges = _edt(detection)

    if interactive:
        viewer.add_labels(detection, visible=False, scale=scale)
        viewer.add_image(edges, visible=False, colormap="gray_r", scale=scale)

I guess that should work for 5-D OME-TIFF? But for OME-Zarr?

JoOkuma commented 8 months ago

Hi @tischi,

What are your recommended image file format?

Any format should work as long as they are loaded as a numpy-compatible array with time as the first axis — for example, dask, Zarr, and numpy itself, which could come from tiffffile.imread.

I don't have a strong preference; most of the time, I use dask for the original data (see below) and zarr (no dask) for intermediate arrays (e.g. detection and edges) without any metadata.

Two very common use cases for the original data are:

If so, are you shipping python libraries to open them?

We are not shipping any format-specific library because these can lead to complicated dependencies. The user should install their preferred library.

This might change soon because we will add some ome-zarr-only functionalities.

I guess that should work for 5-D OME-TIFF? But for OME-Zarr?

Most of our inputs expect a 3- or 4-D (T, Z, Y, X) array, where Z is optional. Except where we need the channel information, then the channel axis is a parameter.

The command line interface works with any format as long as the user has a napari reader plugin installed.

tischi commented 7 months ago

Thanks!

What would we need to add to be able to read from OME-Zarr?

JoOkuma commented 7 months ago

napari-ome-zarr

tischi commented 7 months ago

I am opening an OME-TIFF now:

image shape (16, 63, 2, 512, 512)

so it seems that the channel order is

T, Z, C, Y, X

is that something you normally also have? I think in the code from you the C and Z were swapped....

as an input to ultrack, would I need to do something like this?

cells = im[:, :, channel_index, :, :]

JoOkuma commented 7 months ago

Yes, works im[:, :, channel_index, :, :]`, because you need to select a channel for tracking.

If you had Z, T, Y, X,, you could transpose the array using im.transpose((1, 0, 2, 3)) to get the right order.

ultrack only requires that time comes before the spatial axes.