-
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
10.) Formalizing the ability to return extra info from spot finding #1615
Conversation
992dd01
to
984644d
Compare
Codecov Report
@@ Coverage Diff @@
## master #1615 +/- ##
===========================================
+ Coverage 47.75% 89.87% +42.12%
===========================================
Files 219 219
Lines 8117 8122 +5
===========================================
+ Hits 3876 7300 +3424
+ Misses 4241 822 -3419
Continue to review full report at Codecov.
|
f2cc8cf
to
2879c3c
Compare
b42b879
to
fa0296b
Compare
431ad13
to
9ac3b89
Compare
757bbc3
to
1cc1e36
Compare
@@ -68,7 +73,7 @@ def build_traces_sequential(spot_results: SpotFindingResults, **kwargs) -> Inten | |||
|
|||
i = 0 | |||
for (r, c), attrs in spot_results.items(): |
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.
would not call this attrs in this context because attrs and spot_attrs gets confusing.
@@ -84,7 +85,7 @@ def __init__( | |||
except ValueError: | |||
raise ValueError("Detector method must be one of {blob_log, blob_dog, blob_doh}") | |||
|
|||
def image_to_spots(self, data_image: Union[np.ndarray, xr.DataArray]) -> SpotAttributes: | |||
def image_to_spots(self, data_image: Union[np.ndarray, xr.DataArray]) -> PerImageSpotResults: |
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.
PerTileSpotResults?
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.
Would we call it tile though since we don't include a z value? I went back a forth about this but all your TileKey TileFetcher code includes a r/ch/z for each tile so I wasn't sure it was the same
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.
PerImageSliceSpotResults?
fwiw, I thought we should call n-dimensional tensors images (plural) rather than singular, which I think would have avoided this wonkiness. You should consult with the proponents of calling the entire n-dimensional tensor "image". :)
If they say nothing, then I would go with your judgement.
starfish/core/types/_constants.py
Outdated
@@ -40,6 +41,13 @@ class Coordinates(AugmentedEnum): | |||
""" | |||
|
|||
|
|||
PerImageSpotResults = namedtuple('PerImageSpotResults', 'spot_attrs, extras') |
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.
Would make this a dataclass.
starfish/core/types/_constants.py
Outdated
@@ -40,6 +41,13 @@ class Coordinates(AugmentedEnum): | |||
""" | |||
|
|||
|
|||
PerImageSpotResults = namedtuple('PerImageSpotResults', 'spot_attrs, extras') | |||
""" | |||
Named tuple that gets returned in every spot finding"s image_to_spots method, spot_attrs are the |
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.
Named tuple that gets returned in every spot finding"s image_to_spots method, spot_attrs are the | |
Named tuple that gets returned in every spot finding's image_to_spots method, spot_attrs are the |
starfish/core/types/_constants.py
Outdated
@@ -40,6 +41,13 @@ class Coordinates(AugmentedEnum): | |||
""" | |||
|
|||
|
|||
PerImageSpotResults = namedtuple('PerImageSpotResults', 'spot_attrs, extras') |
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.
wait is this right? this is just two strings.
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.
The strings are just the names of the values put into the named tuple. So you can access them like PerImageSpotResults.spot_attrs
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.
Shouldn't it be:
PerImageSpotResults = namedtuple('PerImageSpotResults', 'spot_attrs, extras') | |
PerImageSpotResults = namedtuple('PerImageSpotResults', 'spot_attrs', 'extras') |
@@ -11,7 +11,8 @@ | |||
|
|||
from starfish.core.imagestack.imagestack import ImageStack | |||
from starfish.core.spots.FindSpots import spot_finding_utils | |||
from starfish.core.types import Axes, Features, SpotAttributes, SpotFindingResults | |||
from starfish.core.types import Axes, Features, PerImageSpotResults, SpotAttributes, \ |
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 would wrap this like how you did it for starfish/core/spots/DecodeSpots/trace_builders.py
67d16b2
to
9580ccd
Compare
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.
see comments pls.
@@ -13,7 +13,8 @@ | |||
from starfish.core.config import StarfishConfig | |||
from starfish.core.imagestack.imagestack import ImageStack | |||
from starfish.core.spots.FindSpots import spot_finding_utils | |||
from starfish.core.types import Axes, Features, Number, SpotAttributes, SpotFindingResults | |||
from starfish.core.types import Axes, Features, Number, PerImageSliceSpotResults, SpotAttributes, \ |
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 can be wrapped without \
@@ -173,7 +174,8 @@ def _select_optimal_threshold(self, thresholds: np.ndarray, spot_counts: List[in | |||
|
|||
return selected_thr | |||
|
|||
def _compute_threshold(self, img: Union[np.ndarray, xr.DataArray]) -> float: | |||
def _compute_threshold(self, img: Union[np.ndarray, xr.DataArray] | |||
) -> Tuple[float, Optional[np.ndarray], Optional[List[int]]]: |
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.
can you update the docblock for this?
edf3226
to
af812f7
Compare
af812f7
to
ce9e2d0
Compare
Changes the return value for every image_to_spots method to PerImageSpotResults, a named tuple that contains the SpotAttributes found in the image as well as any extra information for QC and debugging. The only spot finder that returns extra data at this point is PeakLocalMax which now returns threshold information.
fixes: #908, #708