-
-
Notifications
You must be signed in to change notification settings - Fork 64
Allow custom filters in TissueMask #377
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
Allow custom filters in TissueMask #377
Conversation
e1fc845 to
2a61e23
Compare
Codecov Report
@@ Coverage Diff @@
## master #377 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 17 17
Lines 1411 1430 +19
Branches 218 222 +4
=========================================
+ Hits 1411 1430 +19
Continue to review full report at Codecov.
|
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.
Thanks for your contribution @Christopher22 ❤️ !
I have some concerns on this PR 🤷🏽♂️ . The first thing is the tests you provided. Please read my comment.
Furthermore @alessiamarcolini can give you other consideration on you work.
2a61e23 to
6e10639
Compare
ernestoarbitrio
left a comment
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.
@Christopher22 I did this CR round with @alessiamarcolini.
Sorry for the bunch of request changes ... but overall looks neat.
Could you please address the comments in order to make us able to do a final round?
Thanks again for you effort 💪🏽 ... we really appreciated it 😄
tests/unit/test_masks.py
Outdated
| tissue_mask = TissueMask(*custom_filters) | ||
| _ = tissue_mask(slide) | ||
|
|
||
| set_custom_filters_.assert_called_once() |
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'm not a huge fan of assert_called_once. The reason is that, yes, you're asserting that a proper method has been called, but the interesting info would be also know with which parameters? I'd suggest to switch to assert_called_once_with and check the calling args 😉
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 try to remove all of the things. However, I sometimes have no access to the "self" parameter. In this case, I try to check only the remaining arguments.
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.
Sorry I do not understand this point. Could you elaborate? Thx
tests/unit/test_masks.py
Outdated
| # and the custom filter itself is called | ||
| set_custom_filters_.assert_called_once() | ||
| assert set_custom_filters_.call_args[0][1] == custom_filters[0] | ||
| custom_filter_call_.assert_called_once() |
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
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.
Regarding the whole test: I feel that testing that RgbToGrayscale is called is not a good strategy, because:
- usually we want to mock all the methods/instances that get called/used directly by the method we are testing, so in this case it would be
Tile.calculate_tissue_mask - as a proof for my first point: this test is not really checking that the mask is built with the custom filters, because
RgbToGrayscaleis actually the first filter in the "default" filter sequence (for bothSlideand Tile). So this test would actually pass with both the default and the "custom" filters represented by[RgbToGrayscale()]🤓
Please let me know if this makes sense for you!
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.
@Christopher22 I think you misunderstood my points here. This updated test covers point number 2 but not number 1, the mocked object is not directly called/used by the method you're testing.
6e10639 to
f404b38
Compare
|
Thank you so much for your comments! I hope, I was able to fix the things up you mentioned. As a small refactor, I removed my 'set_custom_filters' and replaced it with a meaningful constructor which fits better in your existing codebase. |
ernestoarbitrio
left a comment
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.
Hey @Christopher22 thanks for all your commitment. I left a couple of furhter minor comments. Could you please take a look? After that we are probably ready to go.
Heads up to @alessiamarcolini ☝🏽
f404b38 to
64be2da
Compare
|
Amazing! Your highlighed areas should be fixed by now :) |
alessiamarcolini
left a comment
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.
| [False, True], | ||
| ] | ||
| tissue_mask_tile_.return_value = expected_mask | ||
|
|
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.
not your responsibility, but since you touched this method... this line should also be removed
tests/unit/test_masks.py
Outdated
| # and the custom filter itself is called | ||
| set_custom_filters_.assert_called_once() | ||
| assert set_custom_filters_.call_args[0][1] == custom_filters[0] | ||
| custom_filter_call_.assert_called_once() |
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.
Regarding the whole test: I feel that testing that RgbToGrayscale is called is not a good strategy, because:
- usually we want to mock all the methods/instances that get called/used directly by the method we are testing, so in this case it would be
Tile.calculate_tissue_mask - as a proof for my first point: this test is not really checking that the mask is built with the custom filters, because
RgbToGrayscaleis actually the first filter in the "default" filter sequence (for bothSlideand Tile). So this test would actually pass with both the default and the "custom" filters represented by[RgbToGrayscale()]🤓
Please let me know if this makes sense for you!
64be2da to
11cd78d
Compare
|
Such cute apes! ;) Your comments should be integrated by now! |
alessiamarcolini
left a comment
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.
Please check the comment I left about the it_knows_its_mask_tile_and_supports_custom_filters test.
PS please squash the commits at the end of the review, otherwise it's more difficult for us to be on track with the changes between review rounds ✌🏼
|
@alessiamarcolini Do you prefer a test such as this instead? :) |
alessiamarcolini
left a comment
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.
|
Ready for squash ;) |
alessiamarcolini
left a comment
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.
d595284 to
41aa5e2
Compare
|
@Christopher22 thank you so much for your valuable contribution! 👏🏼👏🏼 Now, to have a consistent code base, we would like to provide the same flexibility for the |
Description
This small patch allows a custom "pipeline" of image filters within the TissueMask to optimize for specific demands regarding tissue. The default behavior is not changed.
Types of Changes
Issues Fixed or Closed by This PR
Checklist