CellProfiler / CellProfiler-plugins

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

Add flow_threshold and cellprob_threshold params as cp settings #129

Closed alicelucas closed 2 years ago

alicelucas commented 2 years ago

Currently the CellPose plugin does not allow for user to specify parameters for flow_threshold and cellprob_threshold parameters. Defaults are used. This PR adds these two parameters as settings that the user can specify, which are then subsequently used in the eval() method of Cellpose's model.

Merging this closes #128

bethac07 commented 2 years ago

LGTM! Thanks!

abhamacher commented 2 years ago

Thanks a lot for your quick action on this topic! I tried the updated version this morning and recognized, that the cellprob_threshold value cannot be below 0.0. I need to use -1.0 for my current cells and if I understand the cellpose documentation right, values from -6 to +6 are possible.

Regards, Anna

alicelucas commented 2 years ago

Sorry about that! I can make this change. Would you mind pointing me to the cellpose documentation that refers to the [-6, 6] interval? I had thought that because cellprob_threshold refers to a threshold probability value, we should assume that the minimum is 0, since probabilities can't be negative.

abhamacher commented 2 years ago

Sure! See https://cellpose.readthedocs.io/en/latest/settings.html:

Cell probability threshold

"The network predicts 3 outputs: flows in X, flows in Y, and cell “probability”. The predictions the network makes of the probability are the inputs to a sigmoid centered at zero (1 / (1 + e^-x)), so they vary from around -6 to +6. The pixels greater than the cellprob_threshold are used to run dynamics and determine masks. The default is cellprob_threshold=0.0. Decrease this threshold if cellpose is not returning as many masks as you’d expect. Similarly, increase this threshold if cellpose is returning too masks particularly from dim areas."

If you run cellpose with the python GUI, you have a slider to change this value, which is default at 0 and can be moved to negative and positive values:

cellposeGUI

Regards, Anna

alicelucas commented 2 years ago

Great, thanks @abhamacher for the clarification! I've made another PR to change this. Hopefully things should work for you soon. Let us know if you encounter any other problems, Alice