Skip to content

Commit

Permalink
changing more old iss blob code
Browse files Browse the repository at this point in the history
  • Loading branch information
Shannon Axelrod committed Sep 26, 2019
1 parent fb9b662 commit 89a13f2
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 22 deletions.
3 changes: 1 addition & 2 deletions notebooks/ISS.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@
"\n",
"dots_max_projector = Filter.Reduce((Axes.ROUND, Axes.ZPLANE), func=\"max\", module=Filter.Reduce.FunctionSource.np)\n",
"dots_max = dots_max_projector.run(dots)\n",
"# locate spots in a reference image\n",
"# spots = lp.run(reference_image=dots_max, image_stack=registered_imgs)\n",
"\n",
"spots = bd.run(image_stack=registered_imgs, reference_image=dots_max)\n",
"\n",
"decoder = DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook)\n",
Expand Down
3 changes: 1 addition & 2 deletions notebooks/py/ISS.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@

dots_max_projector = Filter.Reduce((Axes.ROUND, Axes.ZPLANE), func="max", module=Filter.Reduce.FunctionSource.np)
dots_max = dots_max_projector.run(dots)
# locate spots in a reference image
# spots = lp.run(reference_image=dots_max, image_stack=registered_imgs)

spots = bd.run(image_stack=registered_imgs, reference_image=dots_max)

decoder = DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def test_per_round_max_spot_decoding_without_spots():

codebook, image_stack, max_intensity = two_spot_sparse_coded_data_factory()

bd = starfish.spots.DetectSpots.BlobDetector(
bd = starfish.spots.FindSpots.BlobDetector(
min_sigma=1, max_sigma=1, num_sigma=1, threshold=max_intensity + 0.1)
no_spots = bd.run(image_stack)

decode = starfish.spots.Decode.PerRoundMaxChannel(codebook)
decoded_no_spots: starfish.DecodedIntensityTable = decode.run(no_spots)
decode = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook)
decoded_no_spots: starfish.DecodedIntensityTable = decode.run(spots=no_spots)

decoded_spot_table = decoded_no_spots.to_decoded_dataframe()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def run(self, spots: SpotFindingResults, *args) -> DecodedIntensityTable:
IntensityTable decoded and appended with Features.TARGET and Features.QUALITY values.
"""
# if no spots
intensities = build_spot_traces_exact_match(spots)
transfer_physical_coords_to_intensity_table(intensity_table=intensities, spots=spots)
return self.codebook.decode_per_round_max(intensities)
4 changes: 2 additions & 2 deletions starfish/core/types/_spot_finding_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def __init__(
"""
spot_attributes_list = spot_attributes_list or []
self._results: MutableMapping[Tuple, SpotAttributes] = {
indices: spots
for indices, spots in spot_attributes_list
tuple(indices[i] for i in AXES_ORDER): spots
for spots, indices in spot_attributes_list
}
self.physical_coord_ranges: Mapping[Hashable, xr.DataArray] = {
Axes.X.value: imagestack_coords[Coordinates.X.value],
Expand Down
17 changes: 12 additions & 5 deletions workflows/wdl/iss_published/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from starfish import FieldOfView
from starfish.image import Filter
from starfish.image import ApplyTransform, LearnTransform
from starfish.spots import DetectSpots
from starfish.spots import DecodeSpots, FindSpots
from starfish.types import Axes


Expand Down Expand Up @@ -50,17 +50,24 @@ def process_fov(field_num: int, experiment_str: str):
filt.run(dots, verbose=True, in_place=True)
filt.run(nuclei, verbose=True, in_place=True)

print("Detecting")
detector = DetectSpots.BlobDetector(
print("Finding Spots")
bd = FindSpots.BlobDetector(
min_sigma=1,
max_sigma=10,
num_sigma=30,
threshold=0.01,
measurement_type='mean',
)

intensities = detector.run(filtered_imgs, blobs_image=dots, blobs_axes=(Axes.ROUND, Axes.ZPLANE))
dots_max_projector = Filter.Reduce((Axes.ROUND, Axes.ZPLANE), func="max",
module=Filter.Reduce.FunctionSource.np)
dots_max = dots_max_projector.run(dots)

spots = bd.run(image_stack=filtered_imgs, reference_image=dots_max)

print("Decoding Spots")
decoder = DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook)
decoded = decoder.run(spots=spots)

decoded = experiment.codebook.decode_per_round_max(intensities)
df = decoded.to_decoded_dataframe()
return df
18 changes: 10 additions & 8 deletions workflows/wdl/iss_spaceTX/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,23 @@ def process_fov(field_num: int, experiment_str: str):
tmp = dots.sel({Axes.ROUND:0, Axes.CH:0, Axes.ZPLANE:0})
dots_threshold = np.percentile(np.ravel(tmp.xarray.values), 50)

# find spots
p = starfish.spots.DetectSpots.BlobDetector(
bd = starfish.spots.FindSpots.BlobDetector(
min_sigma=1,
max_sigma=10,
num_sigma=30,
threshold=dots_threshold,
measurement_type='mean',
)

# blobs = dots; define the spots in the dots image, but then find them again in the stack.
intensities = p.run(filtered_imgs, blobs_image=dots, blobs_axes=(Axes.ROUND, Axes.ZPLANE))
dots_max_projector = starfish.image.Filter.Reduce(
(Axes.ROUND, Axes.ZPLANE), func="max",
module=starfish.image.Filter.Reduce.FunctionSource.np)
dots_max = dots_max_projector.run(dots)

# decode
decoded = experiment.codebook.decode_per_round_max(intensities)
spots = bd.run(image_stack=filtered_imgs, reference_image=dots_max)

decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook)
decoded = decoder.run(spots=spots)

# save results
df = decoded.to_decoded_dataframe()
return df
return df

0 comments on commit 89a13f2

Please sign in to comment.