Skip to content

Commit

Permalink
deleting Decode and Detect modules in lieu of spot finding refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Shannon Axelrod committed Oct 18, 2019
1 parent bc10783 commit 7e24890
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 2,167 deletions.
22 changes: 13 additions & 9 deletions docs/source/_static/data_processing_examples/3d_smFISH.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

import starfish
import starfish.data
from starfish import FieldOfView, IntensityTable
from starfish import FieldOfView, DecodedIntensityTable
from starfish.types import TraceBuildingStrategies

# equivalent to %gui qt
ipython = get_ipython()
Expand Down Expand Up @@ -57,12 +58,11 @@
# local intensity maxima, and spots are matched to the gene they represent by looking them up in a
# codebook that records which (round, channel) matches which gene target.

tlmpf = starfish.spots.DetectSpots.TrackpyLocalMaxPeakFinder(
tlmpf = starfish.spots.FindSpots.TrackpyLocalMaxPeakFinder(
spot_diameter=5, # must be odd integer
min_mass=0.02,
max_size=2, # this is max radius
separation=7,
noise_size=0.65, # this is not used because preprocess is False
preprocess=False,
percentile=10, # this is irrelevant when min_mass, spot_diameter, and max_size are set properly
verbose=True,
Expand Down Expand Up @@ -100,6 +100,11 @@ def processing_pipeline(
print("Loading images...")
images = enumerate(experiment[fov_name].get_images(FieldOfView.PRIMARY_IMAGES))

decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(
codebook=codebook,
trace_building_strategy=TraceBuildingStrategies.SEQUENTIAL
)

for image_number, primary_image in images:
print(f"Filtering image {image_number}...")
filter_kwargs = dict(
Expand All @@ -113,13 +118,12 @@ def processing_pipeline(
clip2.run(primary_image, **filter_kwargs)

print("Calling spots...")
spot_attributes = tlmpf.run(primary_image)
all_intensities.append(spot_attributes)

spot_attributes = IntensityTable.concatenate_intensity_tables(all_intensities)
spots = tlmpf.run(primary_image)
print("Decoding spots...")
decoded_intensities = decoder.run(spots)
all_intensities.append(decoded_intensities)

print("Decoding spots...")
decoded = codebook.decode_per_round_max(spot_attributes)
decoded = DecodedIntensityTable.concatenate_intensity_tables(all_intensities)
decoded = decoded[decoded["total_intensity"] > .025]

return primary_image, decoded
Expand Down
37 changes: 2 additions & 35 deletions docs/source/api/spots/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Spots

Starfish provides a number of methods for which spots (or other regions of interest) are the main substrate.
These include :py:class:`starfish.spots.DetectPixels`, which exposes methods that identify which target code best corresponds to each pixel, and merges adjacent pixels into ROIs,
:py:class:`starfish.spots.DetectSpots`, which exposes methods that find bright spots against dark backgrounds,
:py:class:`starfish.spots.Decode`, which exposes methods that match patterns of spots detected across rounds and channels in the same spatial positions with target codes, and
:py:class:`starfish.spots.FindSpots`, which exposes methods that find bright spots against dark backgrounds,
:py:class:`starfish.spots.DecodeSpots`, which exposes methods that match patterns of spots detected across rounds and channels in the same spatial positions with target codes, and
:py:class:`starfish.spots.AssignTargets`, which exposes methods to assign spots to cells.

.. _detect_pixels:
Expand All @@ -23,29 +23,11 @@ Pixel Detectors can be imported using ``starfish.spots.DetectPixels``, which reg
.. automodule:: starfish.spots.DetectPixels
:members:


.. _detection:

Detecting Spots
---------------

Spot Detectors can be imported using ``starfish.spots.DetectSpots``, which registers all classes that subclass ``DetectSpotsAlgorithm``:

.. code-block:: python
from starfish.spots import DetectSpots
.. automodule:: starfish.spots.DetectSpots
:members:

.. _spot_finding:

Finding Spots
---------------

NOTE: Starfish is embarking on a SpotFinding data structures refactor see `Spot Finding Refactor Plan`_
DetectSpots will be replaced by the FindSpots module documented below.

Spot Finders can be imported using ``starfish.spots.FindSpots``, which registers all classes that subclass ``FindSpotsAlgorithm``:


Expand All @@ -58,21 +40,6 @@ Spot Finders can be imported using ``starfish.spots.FindSpots``, which registers
.. automodule:: starfish.spots.FindSpots
:members:


.. _decoding:

Decoding
--------

Decoders can be imported using ``starfish.spots.Decode``, which registers all classes that subclass ``DecodeAlgorithm``:

.. code-block:: python
from starfish.spots import Decode
.. automodule:: starfish.spots.Decode
:members:

.. _decode_spots:

Decoding Spots
Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ To see what improvements the developers have planned for starfish, please see th
<h2>Features</h2>

* Filtering: :ref:`API <filtering>`
* Spot-Finding: :ref:`API <detection>`
* Decoding: :ref:`API <decoding>`
* Spot-Finding: :ref:`API <spot_finding>`
* Decoding: :ref:`API <decode_spots>`
* Segmenting: :ref:`API <segmentation>`

.. raw:: html
Expand Down
19 changes: 7 additions & 12 deletions starfish/core/pipeline/algorithmbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import inspect
from abc import ABCMeta

from starfish.core.imagestack.imagestack import ImageStack
from starfish.core.types._constants import STARFISH_EXTRAS_KEY


Expand Down Expand Up @@ -35,16 +34,12 @@ def helper(*args, **kwargs):
spot_results = kwargs['spots']
spot_results.log.update_log(args[0])
result.attrs[STARFISH_EXTRAS_KEY] = spot_results.log.encode()
# OLD CODE FOR DETECT WILL GET REMOVED
if 'DetectSpots' in method_class_str or 'DetectPixels' in method_class_str:
if isinstance(args[1], ImageStack):
stack = args[1]
# update log with spot detection instance args[0]
stack.log.update_log(args[0])
# get resulting intensity table and set log
it = result
if isinstance(result, tuple):
it = result[0]
it.attrs[STARFISH_EXTRAS_KEY] = stack.log.encode()
if 'DetectPixels' in method_class_str:
stack = args[1]
# update log with spot detection instance args[0]
stack.log.update_log(args[0])
# get resulting intensity table and set log
it = result[0]
it.attrs[STARFISH_EXTRAS_KEY] = stack.log.encode()
return result
return helper
11 changes: 0 additions & 11 deletions starfish/core/spots/Decode/__init__.py

This file was deleted.

12 changes: 0 additions & 12 deletions starfish/core/spots/Decode/_base.py

This file was deleted.

72 changes: 0 additions & 72 deletions starfish/core/spots/Decode/metric_decoder.py

This file was deleted.

40 changes: 0 additions & 40 deletions starfish/core/spots/Decode/per_round_max_channel_decoder.py

This file was deleted.

Empty file.
54 changes: 0 additions & 54 deletions starfish/core/spots/Decode/test/test_decoding_without_spots.py

This file was deleted.

13 changes: 0 additions & 13 deletions starfish/core/spots/DetectSpots/__init__.py

This file was deleted.

Loading

0 comments on commit 7e24890

Please sign in to comment.