Skip to content

Commit

Permalink
Rename SpotDetection application to Polaris (#13)
Browse files Browse the repository at this point in the history
* Rename SpotDetection app to Polaris

* Fix import statement

* Update app name in README

* Touch ups
  • Loading branch information
elaubsch authored Dec 10, 2021
1 parent 3b5c546 commit 7d03f96
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 34 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion deepcell_spots/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# limitations under the License.
# ==============================================================================

from deepcell_spots.applications.spot_detection import SpotDetection
from deepcell_spots.applications.polaris import Polaris
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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',
Expand All @@ -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,
Expand Down Expand Up @@ -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``.
Expand Down
13 changes: 3 additions & 10 deletions notebooks/Multiplex FISH Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -700,7 +700,7 @@
"outputs": [],
"source": [
"# Instantiate the spot detection application\n",
"spots_app = SpotDetection()"
"spots_app = Polaris()"
]
},
{
Expand Down Expand Up @@ -1090,13 +1090,6 @@
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -1120,4 +1113,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
13 changes: 3 additions & 10 deletions notebooks/Singleplex FISH Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -297,7 +297,7 @@
"outputs": [],
"source": [
"# Initialize spot detection application\n",
"spots_app = SpotDetection()"
"spots_app = Polaris()"
]
},
{
Expand Down Expand Up @@ -437,13 +437,6 @@
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -467,4 +460,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}

0 comments on commit 7d03f96

Please sign in to comment.