diff --git a/README.md b/README.md index cff7aab..86793a1 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 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) 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 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..d23e4e3 100644 --- a/deepcell_spots/applications/spot_detection.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 @@ -43,22 +42,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.featurenet.FeatureNet` 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 +85,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 +98,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 +201,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..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 SpotDetection\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", @@ -700,7 +700,7 @@ "outputs": [], "source": [ "# Instantiate the spot detection application\n", - "spots_app = SpotDetection()" + "spots_app = Polaris()" ] }, { @@ -1090,13 +1090,6 @@ "plt.tight_layout()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -1120,4 +1113,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..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 SpotDetection\n", + "from deepcell_spots.applications 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()" ] }, { @@ -437,13 +437,6 @@ "plt.tight_layout()\n", "plt.show()" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -467,4 +460,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file