-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.) SeqFish/StarMap/LocalBlobSearch #1592
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1592 +/- ##
==========================================
+ Coverage 88.04% 88.26% +0.21%
==========================================
Files 151 152 +1
Lines 5171 5241 +70
==========================================
+ Hits 4553 4626 +73
+ Misses 618 615 -3
Continue to review full report at Codecov.
|
cffb21c
to
5996a09
Compare
5996a09
to
8dd6a0b
Compare
ed13a8b
to
6d4a553
Compare
notebooks/py/STARmap.py
Outdated
threshold=np.percentile(np.ravel(stack.xarray.values), 95), | ||
exclude_border=2) | ||
|
||
spots = bd.run(scaled, n_processes=8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why this has an explicit n_processes setting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, changed it to the default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's also possible that it was done to survive travis...?
notebooks/py/STARmap.py
Outdated
decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook, | ||
anchor_round=0, | ||
search_radius=10, | ||
trace_building_strategy= | ||
TraceBuildingStrategies.NEAREST_NEIGHBOR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, if you stick the parameters onto the next line, it'll format better.
decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook, | |
anchor_round=0, | |
search_radius=10, | |
trace_building_strategy= | |
TraceBuildingStrategies.NEAREST_NEIGHBOR) | |
decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel( | |
codebook=experiment.codebook, | |
anchor_round=0, | |
search_radius=10, | |
trace_building_strategy=TraceBuildingStrategies.NEAREST_NEIGHBOR) |
notebooks/py/SeqFISH.py
Outdated
threshold=threshold) | ||
|
||
spots = bd.run(clipped) | ||
decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook=exp.codebook, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above.
def __init__( | ||
self, | ||
codebook: Codebook, | ||
anchor_round: Optional[int]=1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the parameter order you have in the docblock makes more sense as the optional params only pertain to certain selections of trace_building_strategy
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def build_traces_nearest_neighbors(spot_results: SpotFindingResults, anchor_round: int=1, | ||
search_radius: int=3): | ||
""" | ||
Combine spots found across round and channels of ana ImageStack using a nearest neighbors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine spots found across round and channels of ana ImageStack using a nearest neighbors | |
Combine spots found across round and channels of an ImageStack using a nearest neighbors |
feature_index = np.arange(ind.shape[0], dtype=int) | ||
|
||
# mask spots that are outside the search radius | ||
mask = np.asarray(dist[r] < search_radius) # indices need not match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meta question (and out of the scope of this PR), but why is distance in x-y space treated the same as distance in z-space? intuitively that seems incorrect to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good question @ambrosejcarr ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the properties of the data acquisition, In most cases it should not be treated the same (although there are exceptions). This is the way the search was implemented by the authors of the pipeline, and so it is how we implemented it. If it is simple to set search radii differently for x, y, z, that would be an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a really good question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose that we file an issue to discuss this, and perhaps engage some ppl who use this approach to discuss. It may not matter in the end, but it does not currently pass the smell test. :)
) -> Dict[int, pd.DataFrame]: | ||
"""Merge DataFrames containing spots from different channels into one DataFrame per round. | ||
|
||
Executed on the output of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
notebooks/py/STARmap.py
Outdated
decoder = starfish.spots.DecodeSpots.PerRoundMaxChannel(codebook=experiment.codebook, | ||
anchor_round=0, | ||
search_radius=10, | ||
trace_building_strategy= | ||
TraceBuildingStrategies.NEAREST_NEIGHBOR) | ||
|
||
decoded = decoder.run(spots=spots) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go after the next markdown block.
from starfish.core.types import Axes | ||
|
||
|
||
def traversing_code() -> ImageStack: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be really exhaustive, there should probably be a test case for testing the distance filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which distance filter? the search_radius param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically to make sure that trace building deals with the search_radius
param correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh got it. More then what's already in the jitter_code test where it checks that it doesn't build traces when the search radius is below the 3px distance?
for r in sorted(set(round_dataframes.keys()) - {anchor_round, }): | ||
query_df = round_dataframes[r] | ||
query_coordinates = query_df[[Axes.ZPLANE, Axes.Y, Axes.X]] | ||
nn = NearestNeighbors(n_neighbors=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does NN not support a distance filter intrinsically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like no there's a metric param that might work. But probs another question for @ambrosejcarr
6d4a553
to
f4c676c
Compare
e6c6431
to
cf170a5
Compare
147cd1a
to
c80190f
Compare
1f4858f
to
df82f1e
Compare
df82f1e
to
a900ebd
Compare
assert np.all(c == np.array([0, 0, 1])) | ||
assert np.all(r == np.array([0, 2, 1])) | ||
|
||
# test again with smaller search radius |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
feature_index = np.arange(ind.shape[0], dtype=int) | ||
|
||
# mask spots that are outside the search radius | ||
mask = np.asarray(dist[r] < search_radius) # indices need not match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose that we file an issue to discuss this, and perhaps engage some ppl who use this approach to discuss. It may not matter in the end, but it does not currently pass the smell test. :)
Tests are failing though. |
a900ebd
to
cd62776
Compare
Both STARmap and current Seqfish currently use LocalSearchBlobDetector. This refactor eliminates the need for a separate LocalSearchBlobDetector class and instead both assays now use the regular BlobDetector and the PerRoundMaxChannel with a trace building strategy of 'nearest neighbors'. A lot of the changes here are mostly just moving code that already existed in LocalSearchBlobDetector and a few changes to make BlobDetector work for both ISS and STARmap.
depends on: #1518 #1517