CellProfiler / CellProfiler-plugins

Community-contributed and experimental CellProfiler modules.
http://plugins.cellprofiler.org/
56 stars 67 forks source link

Installation and Functionality Problems with Cellpose Plugin #161

Closed jenna-tomkinson closed 1 year ago

jenna-tomkinson commented 1 year ago

Installation and Functionality Problems with Cellpose Plugin:

My goal is to compare Cellpose stand-alone to the Cellpose plugin inside CellProfiler

But, I have run into many issues, ranging from installing using source to the module not working. I will be discussing the issues I had while on my Linux computer - Hopefully this documentation can help guide others who may have similar challenges. I did have issues similar to the ones I discussed that I asked about on the forum (see https://forum.image.sc/t/macos-source-install-of-cellprofiler-importerror/71058).

Installation Issues from Source

I had to try and install CellProfiler from cloning so that I could follow the instructions from the forum post for using the Cellpose plugin. I cross-referenced these steps as shown in the "Linux (e.g Ubuntu) Only" section of the Conda Installation part of the Wiki, since the .yaml file would install CellProfiler from the Github to allow for me to add the plugin.

After creating the Conda environment with the provided .yaml file, I ran into pip installation errors where the Python version was 2.0 but CellProfiler needs to run Python >= 3.8. Based on this, that means that the dependencies that are being installed with this file are out of date for CellProfiler v4.2.4. Even after I tried updating some of the dependencies to download the up-to-date versions, it created an error where the files were conflicting with each other and it had to find the issue (which was taking over 10 minutes to run).

Since this file failed to work, I decided to use the "CellProfiler 4" .yaml file structure from the same page, but changed the pip dependencies install from - cellprofiler==4.2.4 to - git+https://github.com/CellProfiler/CellProfiler.git@master.

Note: Because the link is set to @master, the version of CellProfiler that will be ran (when I did get it work as described below) is v5.0.0beta1.

When CellProfiler didn't work, I then uninstalled and tried installing after cloning the repo by running:

cd CellProfiler pip install -e .

Anytime I would try to start CellProfiler after installing, I got one of two different errors:

1) cellprofiler: not a command OR 2) ImportError: cannot import name 'set_force_bioformats' from 'cellprofiler_core.preferences'

I could not pinpoint a pattern of when one would happen over another.

When I got the cellprofiler: not a command, I would use python3 cellprofiler and then CellProfiler would open, which is weird because the command cellprofiler should work.

Note: I have no errors when I pip install cellprofiler==4.2.4 and I can open the program using the cellprofiler command. But I can not add the plugin into the appropriate folder since it wasn’t installed from the Github repo.

Even after changing to the v4.2.4 tag in the repo and having CellProfiler-core cloned and installed, I still had issues and it look many tries of uninstalling and installing for it to finally work (and using the python3 cellprofiler command).

RunCellpose Issues

When I finally had CellProfiler version 4.2.4 running from the cloned repo, I tried following the instructions to add the runcellpose.py file into the cellprofiler directory, specifically a Plugins folder in my CellProfiler preferences.

I could not find a preferences folder and there were two plugins folders, located in the 'CellProfilerfolder and in themodulesfolder. No matter if I put the file into either of those folders, theRunCellpose` module would not show up when I opened CellProfiler.

The way that worked for me was adding the file into the modules folder and adding the module into the __init__.py files (e.g adding "runcellpose": "RunCellpose",).

Once RunCellpose was available to use in the CellProfiler GUI, I tried testing it with my images. I did make sure that I already installed Cellpose (pip install cellpose) before attempting to use the module.

When I fixed the parameters, I decided before starting test mode to test the Test GPU button. I then got this error on my terminal:

AttributeError: module 'cellpose.models' has no attribute 'use_gpu'

When I tried running the module in test mode, there were two errors produced in terminal:

1) ModuleNotFoundError: No module named 'cellpose' 2) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf3 in position 0: invalid continuation byte

Then CellProfiler would crash.

These are the issues that I came across when trying to use the Cellpose plugin. I do really want to use this plugin to test how it works in comparison to Cellpose 2.0 GUI so I do hope that these observations help.

Desktop:

bethac07 commented 1 year ago

Hi,

I'm sorry you've been having so many issues!

I'm also going to move this over to the plugins repo, since it seems to be a plugins issue. We'll try to get it sorted for you!

jenna-tomkinson commented 1 year ago

@bethac07

You are a miracle worker! Once I did this step (e.g. configure the location in the preferences menu, the module finally appeared in CellProfiler.

I started testing it in the test mode, and the only issue I had was that my computer would create a popup that said "CellProfiler is not responding" but I can see in the terminal it is running. When I run analyze images, the popup does not come up.

I think the main issue here was that my CellProfiler plugins setting did not have the correct path to where the plugin was located. I fixed this by going into File -> Preferences and setting the path for the CellProfiler plugins to the CellProfiler repo (specifically in the cellprofiler/modules directory within the folder. In that modules folder, I already had the runcellpose.py file in there and within the init.py file.

I do have one question regarding this plugin. In the CellProfiler Cellpose plugin, there are two detection modes (not including custom), which are Nuclei and Cells. In the traditional Cellpose, the models you can select from are nuclei or cyto.

Since here is no model named cyto, can I assume that the model in the CellProfiler Cellpose plugin called Cells is the same model?

If the Cells mode is not synonymous with the cyto model, how would I be able to import that model?

Thank you in advance for your amazing help!

ErinWeisbart commented 1 year ago

I do have one question regarding this plugin. In the CellProfiler Cellpose plugin, there are two detection modes (not including custom), which are Nuclei and Cells. In the traditional Cellpose, the models you can select from are nuclei or cyto.

Since here is no model named cyto, can I assume that the model in the CellProfiler Cellpose plugin called Cells is the same model?

If the Cells mode is not synonymous with the cyto model, how would I be able to import that model?

@fefossa When you work on CellPose issues, can you answer this and update the help info in the plugin to clarify this?

fefossa commented 1 year ago

Hi @jenna-tomkinson

I do have one question regarding this plugin. In the CellProfiler Cellpose plugin, there are two detection modes (not including custom), which are Nuclei and Cells. In the traditional Cellpose, the models you can select from are nuclei or cyto.

Since here is no model named cyto, can I assume that the model in the CellProfiler Cellpose plugin called Cells is the same model?

If the Cells mode is not synonymous with the cyto model, how would I be able to import that model?

If you get into any new issues please let us know!