-
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
replace label images with segmentation masks #1135
Conversation
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.
comment checkpoint.
starfish/segmentation_mask.py
Outdated
|
||
Parameters | ||
---------- | ||
masks : list of xr.DataArray |
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.
What do you foresee as the access pattern for these masks?
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 whole collection will effectively serve as a proxy to these. Do you think it's better practice to expose this as a public attribute?
What I would normally/prefer to do is not create a class at all and just use a functional approach which is much cleaner IMO (outside of type hints) but I wanted this to blend in with the rest of the package which feels a bit class-happy tbh.
starfish/segmentation_mask.py
Outdated
---------- | ||
path : str | ||
Path of the directory to write to. | ||
overwrite : bool, optional |
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 pattern used thus far in this repo is to do:
overwrite : bool
Whether to overwrite the directory if it exists. (default: False)
If you don't feel strongly about it, let's stick with this convention. If you do feel strongly about it, let's discuss. :)
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 don't feel too strongly about this although I do think that the , optional
part is useful to users and the (default: False)
is not so much since they can just take a look at the signature for the default value.
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.
Looks like there is some issue from the CLI call with the validation command (see travis). Otherwise this looks quite good! I've made a bunch of minor comments.
intensities: IntensityTable, | ||
in_place: bool, | ||
) -> IntensityTable: | ||
cell_ids = [] | ||
|
||
for spot in intensities: |
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 this is worth a short comment on the strategy. "for each spot, test whether the spot falls inside the area of each mask"
Second: I'm guessing this is really fast because there just aren't that many spot/mask combinations? If it's not, we could build an interval tree over the mask dimensions to speed this up.
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.
For our test cases there aren't many, sure. If you think that there are users who (will) have a lot of spots/masks then we could look into improving the algorithm.
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.
Good work! I agree with the comments Ambrose and Tony made about adding some comments and making sure not to have any of the code dependent on axis ordering, but overall awesome!
Codecov Report
@@ Coverage Diff @@
## master #1135 +/- ##
==========================================
- Coverage 90.47% 88.25% -2.22%
==========================================
Files 125 129 +4
Lines 4566 4931 +365
==========================================
+ Hits 4131 4352 +221
- Misses 435 579 +144
Continue to review full report at Codecov.
|
Ok, thanks for all the comments! I've addressed them (I hope) so this should be ready for re-review :) |
There are also some nice features I could add such as enforcing unique label names which would open up the possibility to index by label or lazy load from disk. |
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.
There's a couple small lint issues that's preventing this from going green. Generally this looks great now!
starfish/segmentation_mask.py
Outdated
masks : list of xr.DataArray | ||
Segmentation masks. | ||
""" | ||
_masks: List[xr.DataArray] |
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 constructor assigning this variable implicitly types the field.
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.
👍
closes #875