MouseLand / cellpose-napari

napari plugin for cellpose (see www.cellpose.org) - an anatomical segmentation tool
https://cellpose-napari.readthedocs.org
BSD 3-Clause "New" or "Revised" License
47 stars 22 forks source link

[FEATURE] add channel_axis and z_axis to widget #48

Open manerotoni opened 12 months ago

manerotoni commented 12 months ago

Hello, I was wondering how you are supposed to load a multi-channel image in the plugin.

Problem

I conclude from this that the plugin always think that an image with more than 2-dimension is a Z-stack.

What I tried

  1. Napari expects dimensions (T, Z, C, Y, X) and I tried to add more dimensions. This did not help. In fact to display the image as multi-channel you need to split stack.

  2. I converted in Fiji the image to a png/RGB. The image gets dimension (Y,X, C) with 3 channels. Napari displays the image as multi-channel without having to split stack. Cellpose can process the image. This solution is not good as converting yet in another format is not convenient and is something you try to avoid in image processing due to loss of information. If you try to make your image RGB in napari/python it is quite of a mess. You have to add an additional channel , ....

Possible solutions Specify the channels to use directly without going through the image layer. The plugin should understand different dimensions. In the cellpose GUI this works quite well.

psobolewskiPhD commented 11 months ago

Yeah I can reproduce this. The channel to segment menu is not very intuitive so it makes it seem like it should work, but it doesn't. The issue likes here: https://github.com/MouseLand/cellpose-napari/blob/6993beeacf7a7d66f4f0342b6ae6bd5cda6acb93/cellpose_napari/_dock_widget.py#L241-L248

So if you have a multichannel 3D image (4 dims) then you can make it work by naming one of the axes c e.g. by double clicking the number next to the axis or by providing a tuple to axis_labels. For example lets say I have CZYX, I would do: viewer.dims.axis_labels = ('c', 1, 2, 3) Then using channel to segment I can specify which channel to use and the axes labeled c will be used. Alas, for CYX there is no similar check. What would make more sense overall is if the channel_axis could be directly specified in the widget UI. I'll take a look.

manerotoni commented 11 months ago

Thanks, are you saying that for a standard CXY image it is not possible to use the napari cellpose plugin except by converting it to a different order image? I have not tried to change the order of the numpy array in python. Do you know if this works (no conversion to RGB).

carsen-stringer commented 1 month ago

you don't need to convert it, you need to label it in the napari GUI with a c. we can add this into the widget in the future