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

Set upper bound on cellpose to 0.7.2 #28

Closed psobolewskiPhD closed 2 years ago

psobolewskiPhD commented 2 years ago

This is a fix for https://github.com/MouseLand/cellpose-napari/issues/21 It's a bummer that cellpose-napari installs fine from the napari plugin GUI, but then doesn't run because the current cellpose version isn't compatible. By setting an upper bound, the plugin will work until a new version of the plugin can be developed to account for the breaking changes in current cellpose versions.

tlambert03 commented 2 years ago

Thanks @psobolewskiPhD. Since you’re already digging in to it, did you happen to see how hard it would be to just fix the import? (It’s just a logger and I kinda imagine it could be a 1-2 line fix?). Maybe not

psobolewskiPhD commented 2 years ago

i think it might be more than just the logger, because in 0.7.2 (the newest version that works), I also get a warning:

19:17:07 WARNING cellprob_threshold and dist_threshold are being deprecated in a future release, use mask_threshold instead

I'll try and find some time to take a closer look, but this week is looking rather brutal.

psobolewskiPhD commented 2 years ago

@tlambert03 I guess I have a hard time letting things go 🤣 If you replace every from cellpose import logger (and similar) with

import logging
logger = logging.getLogger(__name__)

Then the plugin works for the 2D sample. Edit: but it no longer prints to console the messages. I guess they are just logged?

The 3D doesn't work due to IndexError: index 2 is out of bounds for axis 1 with size 2 I think it may be because of the data shape:

viewer.layers[0].data.shape
Out[1]: (75, 2, 75, 75)

So that is ZCYX.

Edit: Derp...I should try checking the box for stack as 3D—spoiled by Stardist-napari! It works, but the broadcasting is strange.

image

I will see if swapping the dims helps? Bingo!

image
psobolewskiPhD commented 2 years ago

OK, I got the logger thing fixed so it prints. Will make a PR for that. Then will make a PR for the sample images if I can figure that out. Edit: i think I have the issue with the sample image sorted out too. Made a separate PR. That one works only if cellpose <= 0.7.2.

codecov-commenter commented 2 years ago

Codecov Report

Merging #28 (3dccda7) into main (70a3581) will not change coverage. The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #28   +/-   ##
=======================================
  Coverage   29.81%   29.81%           
=======================================
  Files           3        3           
  Lines         218      218           
=======================================
  Hits           65       65           
  Misses        153      153           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 70a3581...3dccda7. Read the comment docs.

psobolewskiPhD commented 2 years ago

The windows test fails are due to the OpenGL install. I've made a new PR to try to fix that: https://github.com/MouseLand/cellpose-napari/pull/32 Eitherway, this PR hopefully can be closed, because https://github.com/MouseLand/cellpose-napari/pull/29 is a better solution.

tlambert03 commented 2 years ago

closing in favor of #29