From fe3b04270ad4d67deab5335fa2855b70b890c81b Mon Sep 17 00:00:00 2001 From: Emily Laubscher Date: Thu, 9 Dec 2021 15:25:34 -0800 Subject: [PATCH 1/4] Rename SpotDetection app to Polaris --- .../{spot_detection.py => polaris.py} | 20 +++++++++---------- notebooks/Multiplex FISH Analysis.ipynb | 6 +++--- notebooks/Singleplex FISH Analysis.ipynb | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) rename deepcell_spots/applications/{spot_detection.py => polaris.py} (94%) diff --git a/deepcell_spots/applications/spot_detection.py b/deepcell_spots/applications/polaris.py similarity index 94% rename from deepcell_spots/applications/spot_detection.py rename to deepcell_spots/applications/polaris.py index ed79362..2ec59c7 100644 --- a/deepcell_spots/applications/spot_detection.py +++ b/deepcell_spots/applications/polaris.py @@ -43,22 +43,22 @@ 'saved-models/SpotDetection-3.tar.gz') -class SpotDetection(Application): - """Loads a :mod:`deepcell.model_zoo.panopticnet.PanopticNet` model - for nuclear segmentation with pretrained weights. +class Polaris(Application): + """Loads a :mod:`deepcell.model_zoo.panopticnet.FeatureNets` model + for fluorescent spot detection with pretrained weights. The ``predict`` method handles prep and post processing steps to return a labeled image. Example: .. code-block:: python from skimage.io import imread - from deepcell_spots.applications import SpotDetection + from deepcell_spots.applications import Polaris # Load the image - im = imread('HeLa_nuclear.png') + im = imread('spots_image.png') # Expand image dimensions to rank 4 im = np.expand_dims(im, axis=-1) im = np.expand_dims(im, axis=0) # Create the application - app = SpotDetection() + app = Polaris() # create the lab labeled_image = app.predict(im) Args: @@ -86,7 +86,6 @@ class SpotDetection(Application): def __init__(self, model=None): if model is None: - # model_path = '/data/20210331-training_data/models/em_model' archive_path = tf.keras.utils.get_file( 'SpotDetection.tgz', MODEL_PATH, file_hash='2b9a46087b25e9aab20a2c9f67f4f559', @@ -100,7 +99,7 @@ def __init__(self, model=None): } ) - super(SpotDetection, self).__init__( + super(Polaris, self).__init__( model, model_image_shape=model.input_shape[1:], model_mpp=0.65, @@ -203,8 +202,9 @@ def predict(self, preprocess_kwargs=None, postprocess_kwargs=None, threshold=0.9): - """Generates a labeled image of the input running prediction with - appropriate pre and post processing functions. + """Generates a list of coordinate spot locations of the input + running prediction with appropriate pre and post processing + functions. Input images are required to have 4 dimensions ``[batch, x, y, channel]``. Additional empty dimensions can be added using ``np.expand_dims``. diff --git a/notebooks/Multiplex FISH Analysis.ipynb b/notebooks/Multiplex FISH Analysis.ipynb index 7baec55..af263d7 100644 --- a/notebooks/Multiplex FISH Analysis.ipynb +++ b/notebooks/Multiplex FISH Analysis.ipynb @@ -21,7 +21,7 @@ "from skimage import transform\n", "from skimage.feature import register_translation\n", "from sklearn.cluster import DBSCAN\n", - "from deepcell_spots.applications.spot_detection import SpotDetection\n", + "from deepcell_spots.applications.spot_detection import Polaris\n", "from deepcell_spots.spot_em import define_edges\n", "from deepcell_spots.point_metrics import *\n", "from deepcell_spots.singleplex import *\n", @@ -700,7 +700,7 @@ "outputs": [], "source": [ "# Instantiate the spot detection application\n", - "spots_app = SpotDetection()" + "spots_app = Polaris()" ] }, { @@ -1120,4 +1120,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/notebooks/Singleplex FISH Analysis.ipynb b/notebooks/Singleplex FISH Analysis.ipynb index 49a6204..bce9bcc 100644 --- a/notebooks/Singleplex FISH Analysis.ipynb +++ b/notebooks/Singleplex FISH Analysis.ipynb @@ -14,7 +14,7 @@ "from deepcell_toolbox.processing import histogram_normalization,normalize\n", "from deepcell_toolbox.deep_watershed import deep_watershed\n", "from deepcell.applications import CytoplasmSegmentation,NuclearSegmentation\n", - "from deepcell_spots.applications.spot_detection import SpotDetection\n", + "from deepcell_spots.applications.spot_detection import Polaris\n", "from deepcell_spots.singleplex import *\n", "\n", "class OverrideCytoplamSegmentation(CytoplasmSegmentation):\n", @@ -297,7 +297,7 @@ "outputs": [], "source": [ "# Initialize spot detection application\n", - "spots_app = SpotDetection()" + "spots_app = Polaris()" ] }, { @@ -467,4 +467,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file From 1bd51c45f95894eca97241b2f62745cd2035cd79 Mon Sep 17 00:00:00 2001 From: Emily Laubscher Date: Thu, 9 Dec 2021 15:30:59 -0800 Subject: [PATCH 2/4] Fix import statement --- deepcell_spots/applications/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepcell_spots/applications/__init__.py b/deepcell_spots/applications/__init__.py index a66e7db..9d64edf 100644 --- a/deepcell_spots/applications/__init__.py +++ b/deepcell_spots/applications/__init__.py @@ -24,4 +24,4 @@ # limitations under the License. # ============================================================================== -from deepcell_spots.applications.spot_detection import SpotDetection +from deepcell_spots.applications.polaris import Polaris From 9ed842287a7d011301ce5893e26e74aba67e58d8 Mon Sep 17 00:00:00 2001 From: Emily Laubscher Date: Thu, 9 Dec 2021 15:37:48 -0800 Subject: [PATCH 3/4] Update app name in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cff7aab..85449da 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,9 @@ docker run --gpus '"device=0"' -it \ ### How to Use ```python -from deepcell_spots.applications.spot_detection import SpotDetection +from deepcell_spots.applications.polaris import Polaris -app = SpotDetection() +app = Polaris() # image is an np array with dimensions (batch,x,y,channel) # threshold is the probability threshold that a pixel must exceed to be considered a spot coords = app.predict(image,threshold=0.9) From 50eef2218bcb1adfddef4aadfc66b565070a4319 Mon Sep 17 00:00:00 2001 From: Emily Laubscher Date: Thu, 9 Dec 2021 16:13:36 -0800 Subject: [PATCH 4/4] Touch ups --- README.md | 2 +- deepcell_spots/applications/polaris.py | 3 +-- notebooks/Multiplex FISH Analysis.ipynb | 9 +-------- notebooks/Singleplex FISH Analysis.ipynb | 9 +-------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 85449da..86793a1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ docker run --gpus '"device=0"' -it \ ### How to Use ```python -from deepcell_spots.applications.polaris import Polaris +from deepcell_spots.applications import Polaris app = Polaris() # image is an np array with dimensions (batch,x,y,channel) diff --git a/deepcell_spots/applications/polaris.py b/deepcell_spots/applications/polaris.py index 2ec59c7..d23e4e3 100644 --- a/deepcell_spots/applications/polaris.py +++ b/deepcell_spots/applications/polaris.py @@ -33,7 +33,6 @@ import tensorflow as tf from deepcell.applications import Application -from deepcell_spots.dotnet import * from deepcell_spots.dotnet_losses import DotNetLosses from deepcell_spots.postprocessing_utils import y_annotations_to_point_list_max from deepcell_spots.preprocessing_utils import min_max_normalize @@ -44,7 +43,7 @@ class Polaris(Application): - """Loads a :mod:`deepcell.model_zoo.panopticnet.FeatureNets` model + """Loads a :mod:`deepcell.model_zoo.featurenet.FeatureNet` model for fluorescent spot detection with pretrained weights. The ``predict`` method handles prep and post processing steps to return a labeled image. diff --git a/notebooks/Multiplex FISH Analysis.ipynb b/notebooks/Multiplex FISH Analysis.ipynb index af263d7..6b28dc6 100644 --- a/notebooks/Multiplex FISH Analysis.ipynb +++ b/notebooks/Multiplex FISH Analysis.ipynb @@ -21,7 +21,7 @@ "from skimage import transform\n", "from skimage.feature import register_translation\n", "from sklearn.cluster import DBSCAN\n", - "from deepcell_spots.applications.spot_detection import Polaris\n", + "from deepcell_spots.applications import Polaris\n", "from deepcell_spots.spot_em import define_edges\n", "from deepcell_spots.point_metrics import *\n", "from deepcell_spots.singleplex import *\n", @@ -1090,13 +1090,6 @@ "plt.tight_layout()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/notebooks/Singleplex FISH Analysis.ipynb b/notebooks/Singleplex FISH Analysis.ipynb index bce9bcc..58b5487 100644 --- a/notebooks/Singleplex FISH Analysis.ipynb +++ b/notebooks/Singleplex FISH Analysis.ipynb @@ -14,7 +14,7 @@ "from deepcell_toolbox.processing import histogram_normalization,normalize\n", "from deepcell_toolbox.deep_watershed import deep_watershed\n", "from deepcell.applications import CytoplasmSegmentation,NuclearSegmentation\n", - "from deepcell_spots.applications.spot_detection import Polaris\n", + "from deepcell_spots.applications import Polaris\n", "from deepcell_spots.singleplex import *\n", "\n", "class OverrideCytoplamSegmentation(CytoplasmSegmentation):\n", @@ -437,13 +437,6 @@ "plt.tight_layout()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {