Skip to content
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

Merged
merged 6 commits into from
Apr 15, 2019

Conversation

kne42
Copy link
Collaborator

@kne42 kne42 commented Apr 4, 2019

closes #875

Copy link
Collaborator

@ttung ttung left a 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 Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved

Parameters
----------
masks : list of xr.DataArray
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 Show resolved Hide resolved
starfish/segmentation_mask.py Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
----------
path : str
Path of the directory to write to.
overwrite : bool, optional
Copy link
Collaborator

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. :)

Copy link
Collaborator Author

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.

starfish/segmentation_mask.py Outdated Show resolved Hide resolved
Copy link
Member

@ambrosejcarr ambrosejcarr left a 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.

starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
intensities: IntensityTable,
in_place: bool,
) -> IntensityTable:
cell_ids = []

for spot in intensities:
Copy link
Member

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.

Copy link
Collaborator Author

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.

starfish/image/_segmentation/watershed.py Show resolved Hide resolved
starfish/image/_segmentation/watershed.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@shanaxel42 shanaxel42 left a 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!

starfish/image/_segmentation/_base.py Outdated Show resolved Hide resolved
starfish/test/test_segmentation_mask.py Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Apr 10, 2019

Codecov Report

Merging #1135 into master will decrease coverage by 2.21%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
starfish/test/full_pipelines/cli/test_iss.py 100% <ø> (ø) ⬆️
starfish/image/_segmentation/watershed.py 96.72% <100%> (+0.05%) ⬆️
starfish/image/_segmentation/_base.py 97.14% <100%> (+0.08%) ⬆️
starfish/spots/_target_assignment/_base.py 97.22% <100%> (ø) ⬆️
starfish/test/full_pipelines/api/test_iss_api.py 100% <100%> (ø) ⬆️
starfish/segmentation_mask.py 93.58% <93.58%> (ø)
starfish/spots/_target_assignment/label.py 94.44% <93.75%> (+5.55%) ⬆️
starfish/util/argparse.py 0% <0%> (-85.72%) ⬇️
starfish/compat.py 10.84% <0%> (-55.83%) ⬇️
starfish/imagestack/parser/tileset/_parser.py 81.69% <0%> (-3.26%) ⬇️
... and 51 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d2bc0f0...c8df372. Read the comment docs.

@kne42
Copy link
Collaborator Author

kne42 commented Apr 11, 2019

Ok, thanks for all the comments! I've addressed them (I hope) so this should be ready for re-review :)

@kne42
Copy link
Collaborator Author

kne42 commented Apr 11, 2019

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.

@ttung
Copy link
Collaborator

ttung commented Apr 12, 2019

Ok, thanks for all the comments! I've addressed them (I hope) so this should be ready for re-review :)

when you want to ask for a re-review, you can do so using the github UI. This way, it shows up on the reviewers' dashboards.

Screen Shot 2019-04-12 at 10 49 55 AM

Copy link
Collaborator

@ttung ttung left a 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!

masks : list of xr.DataArray
Segmentation masks.
"""
_masks: List[xr.DataArray]
Copy link
Collaborator

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.

starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
starfish/segmentation_mask.py Outdated Show resolved Hide resolved
Copy link
Member

@ambrosejcarr ambrosejcarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kne42 kne42 merged commit 9d4bf1d into spacetx:master Apr 15, 2019
@kne42 kne42 deleted the segmentation-mask branch April 15, 2019 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propose a format for segmentation results
5 participants