-
Notifications
You must be signed in to change notification settings - Fork 429
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
NF: Adding correct_mask to median_otsu #3140
base: master
Are you sure you want to change the base?
Conversation
Hello @pjsjongsung, Thank you for updating !
Comment last updated at 2024-04-16 17:46:25 UTC |
Could you please add a test of |
19b14ce
to
e62f7c3
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.
Hi @pjsjongsung,
Thank you for this. See below for minor comments
@@ -297,7 +298,7 @@ def __predict(self, x_test): | |||
def predict(self, T1, affine, | |||
voxsize=(1, 1, 1), batch_size=None, | |||
return_affine=False, return_prob=False, | |||
largest_area=True): |
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.
You might have to use deprecate_params
since this method is available the 2 last release at least.
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 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.
True. Do you know an example of deprecation by change in parameter name in DIPY I could follow?
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.
here it is :
Line 49 in 90489e8
@deprecated_params('sh_order', 'sh_order_max', since='1.9', until='2.0') |
dipy/segment/mask.py
Outdated
correct_mask : bool, optional | ||
Whether to remove potential holes or islands. | ||
Useful for solving minor errors. | ||
Default is True |
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.
default to remove
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 address this?
Can you also rebase or merge master? Thank you |
b485557
to
a306942
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3140 +/- ##
==========================================
- Coverage 83.65% 83.62% -0.04%
==========================================
Files 153 153
Lines 21272 21281 +9
Branches 3434 3425 -9
==========================================
Hits 17796 17796
- Misses 2618 2625 +7
- Partials 858 860 +2
|
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.
Hi @pjsjongsung,
Sorry for the late review. See below some comments. It is almost ready to go
dipy/segment/mask.py
Outdated
correct_mask : bool, optional | ||
Whether to remove potential holes or islands. | ||
Useful for solving minor errors. | ||
Default is True |
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 address this?
dipy/segment/utils.py
Outdated
except ValueError: | ||
warnings.warn('The mask has no background. \ | ||
Returning the original mask', | ||
DeprecationWarning, stacklevel=2) |
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 is not a DeprecationWarning
. I will keep it a UserWarning
dipy/segment/mask.py
Outdated
@@ -124,7 +125,7 @@ def crop(vol, mins, maxs): | |||
|
|||
|
|||
def median_otsu(input_volume, vol_idx=None, median_radius=4, numpass=4, | |||
autocrop=False, dilate=None): | |||
autocrop=False, dilate=None, correct_mask=True): |
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 will call this finalize_mask
or something similar
correct_mask
sounds like there is a bug so why should we put it False
? lol
dipy/nn/evac.py
Outdated
def predict(self, T1, affine, | ||
voxsize=(1, 1, 1), batch_size=None, | ||
return_affine=False, return_prob=False, | ||
largest_area=True): | ||
correct_mask=True): |
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 comment as below
a306942
to
2975244
Compare
Sorry about the late response. Hopefully it is all resolved! |
Hi @pjsjongsung, I did not look yet but your test is failing: =========================== short test summary info ============================
FAILED segment/tests/test_utils.py::test_remove_holes_and_islands - AssertionError:
Arrays are not equal
Mismatched elements: 34970 / 64000 (54.6%)
Max absolute difference: 1.0
Max relative difference: 1.0
x: array([[[1, 1, 1, ..., 0, 1, 1],
[1, 1, 1, ..., 0, 1, 1],
[1, 1, 1, ..., 1, 0, 1],...
y: array([[[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],...
===== 1 failed, 1020 passed, 65 skipped, 8 warnings in 1785.02s (0:29:45) ====== Can you look closely at this PR? thanks ! |
This PR aims to add a function that removes holes or islands of a binary mask to median_otsu. The function was already being used in dipy/nn/utils.py, so it has been moved to dipy/segment/utils.py, as it makes more sense for mask correction to be in segmentation module. Slice-wise hole removal was excluded from the function, since it can cause huge false positives if there is a lack of axial slices. Finally, the function's name has been changed to remove_holes_and_islands, to be more explicit about the functionality. Related parameter name and its descriptions have been changed as well.
2975244
to
2e3c310
Compare
My bad. I didn't think the test would fail since it worked before when it was in a different module. Changed the test so that it would not create non realistic tasks where the method would fail. |
This PR aims to add a function that removes holes or islands of a binary mask to median_otsu.
The function was already being used in
dipy/nn/utils.py, so it has been moved to dipy/segment/utils.py, as it makes more sense for mask correction to be in segmentation module.
Slice-wise hole removal was excluded from the function, since it can cause huge false positives if there is a lack of axial slices.
Finally, the function's name has been changed to
remove_holes_and_islands, to be more explicit about the functionality.
This PR is related to #3124