cellpose-napari icon indicating copy to clipboard operation
cellpose-napari copied to clipboard

[FEATURE] add channel_axis and z_axis to widget

Open manerotoni opened this issue 2 years ago • 3 comments

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

Problem

  • If I load a multipage tif with two channels and python dimensions (C, Y, X), the plugin gives the error ERROR tuple index out of range
  • If I set the stitch threshold > 0 or 3D on the image is processed as Z-stack, which is wrong.

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.

manerotoni avatar Nov 13 '23 10:11 manerotoni

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.

psobolewskiPhD avatar Dec 06 '23 21:12 psobolewskiPhD

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).

manerotoni avatar Dec 07 '23 08:12 manerotoni

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

carsen-stringer avatar Sep 13 '24 05:09 carsen-stringer