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
[BF] IVIM fixes #1931
[BF] IVIM fixes #1931
Conversation
Hello @ShreyasFadnavis, Thank you for updating ! Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated at 2019-08-01 02:01:33 UTC |
Codecov Report
@@ Coverage Diff @@
## master #1931 +/- ##
=========================================
Coverage ? 84.55%
=========================================
Files ? 119
Lines ? 14719
Branches ? 2334
=========================================
Hits ? 12446
Misses ? 1726
Partials ? 547
|
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.
Overall it looks good. Just take care of you rebase because you are deleting previous work like warning management and setup_module
for pytest.
Thank you @ShreyasFadnavis for this update on IVIM
dipy/reconst/ivim.py
Outdated
@@ -10,6 +10,11 @@ | |||
cvxpy, have_cvxpy, _ = optional_package("cvxpy") | |||
|
|||
|
|||
# global variables for bounding least_squares in both models | |||
BOUNDS_TRF = ([0., 0., 0., 0.], [np.inf, .2, 1., 1.]) | |||
BOUNDS_VP = ([0.01, 0.005, 10**-4], [0.3, 0.02, 0.003]) |
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.
pep8: Can you remove one space before 0.003
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.
@skoudoro ! Thank you 👍 I have made the suggested changes...
dipy/reconst/tests/test_ivim.py
Outdated
needs_cvxpy = dec.skipif(not have_cvxpy) | ||
|
||
|
||
def setup_module(): |
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, do not remove this function setup_module()
. Can you update this function instead of coming back to an old version. Thank you
dipy/reconst/tests/test_ivim.py
Outdated
@@ -337,18 +320,8 @@ def test_noisy_fit(): | |||
around 135 and D and D_star values are equal. Hence doing a test based on | |||
Scipy version. | |||
""" | |||
model_one_stage = IvimModel(gtab, fit_method='LM') | |||
with warnings.catch_warnings(record=True) as w: |
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 here, please keep the warning management and just update the model call
dipy/reconst/tests/test_ivim.py
Outdated
@@ -442,18 +415,7 @@ def test_leastsq_failing(): | |||
Test for cases where leastsq fitting fails and the results from a linear | |||
fit is returned. | |||
""" | |||
with warnings.catch_warnings(record=True) as w: |
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 above, keep the warning management.
dipy/reconst/tests/test_ivim.py
Outdated
@@ -465,17 +427,23 @@ def test_leastsq_error(): | |||
passed. If an unfeasible x0 value is passed using which leastsq fails, the | |||
x0 value is returned as it is. | |||
""" | |||
with warnings.catch_warnings(record=True) as w: | |||
warnings.simplefilter("always", category=UserWarning) |
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 above
Thank you for the quick correction @ShreyasFadnavis! @arokem, Can you have a quick look at this PR? |
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.
A few comments from me.
Also, why "TRF"
for trust reflective region? Shouldn't that be "TRR"
?
dipy/reconst/ivim.py
Outdated
|
||
""" | ||
boundsWarning = 'Bounds for this fit have been set from experiments ' | ||
boundsWarning += 'and literature survey. To change the bounds, please ' |
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 here
dipy/reconst/ivim.py
Outdated
|
||
""" | ||
boundsWarning = 'Bounds for this fit have been set from experiments ' | ||
boundsWarning += 'and literature survey. To change the bounds, please ' | ||
boundsWarning += 'input your bounds in model definition...' |
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 here
dipy/reconst/ivim.py
Outdated
if fit_method.lower() == 'lm': | ||
return IvimModelLM(gtab, **kwargs) | ||
if fit_method.lower() == 'trf': | ||
warnings.warn(boundsWarning, UserWarning) |
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.
IIUC, this warning would be raised even if the user set the bounds themselves.
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.
Yes!
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.
So this warning will always popup whatever the user does? What is the goal of this warning?
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.
As discussed in #1817 , it is to warn the users that there is no fixed recipe for the bounds and we provide the users a way to change them.. makes sense?
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.
ok, but when the user changes the bounds, the warning will still appear, right? Do we really want that or should we adapt? if the user changes it, no warning otherwise, a warning appears
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.
@skoudoro You are right! I have tried to address this in my latest commit :)
dipy/reconst/ivim.py
Outdated
@@ -10,6 +10,11 @@ | |||
cvxpy, have_cvxpy, _ = optional_package("cvxpy") | |||
|
|||
|
|||
# global variables for bounding least_squares in both models | |||
BOUNDS_TRF = ([0., 0., 0., 0.], [np.inf, .2, 1., 1.]) | |||
BOUNDS_VP = ([0.01, 0.005, 10**-4], [0.3, 0.02, 0.003]) |
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 must be missing something: why are separate bounds set for each method?
dipy/reconst/ivim.py
Outdated
@@ -590,7 +600,7 @@ def fit(self, data, bounds_de=None): | |||
x_f = self.x_and_f_to_x_f(x, f) | |||
|
|||
# Setting up the bounds for least_squares | |||
bounds = ([0.01, 0.005, 10**-4], [0.3, 0.02, 0.003]) | |||
bounds = BOUNDS_VP |
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.
It looks like it's overwriting the input (from the keyword argument). Shouldn't this only be set from the global variable if bounds is None
?
Co-Authored-By: Ariel Rokem <arokem@gmail.com>
Fixed all that was suggested :) Let me know in case of any further changes 👍 |
Does Anyone want to add another comments ? Can you have a last look @arokem? I would like to merge this tomorrow at noon EST |
OK. I believe this is ready to go! @skoudoro : the GitHub PR says you still have requested changes, but it looks like @ShreyasFadnavis has already addressed all your comments. If you are pleased, please go ahead and merge this. |
will do!! as soon as Travis is happy, just waiting for that! Thank you @ShreyasFadnavis and @arokem |
Thanks @ShreyasFadnavis and @arokem ! Merging |
Minor fixes, fix #1817