-
Notifications
You must be signed in to change notification settings - Fork 38
Dictionary bounds + standard OSIPI bounds #126
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
base: main
Are you sure you want to change the base?
Conversation
… bounds stored in the standardized OSIPI dictionary format. self.bounds will get manipulated by the individual algorithm subclasses
… not being found.
|
To resolve some of the failing tests:
The MATLAB-based algorithms are passing |
Thanks for checking this. As I've mentioned previously I think original code should only be adjusted by the authors. So in this testing, we seems to be able to find limitations in certain algorithms which in one way is good. What is not good is that these will continue to be viewed as fails, and if we continue to change the wrapper or other surrounding code, we won't know whether we are getting fails due to the problem with the algorithm, or problem with our own code. What are your thoughts on this? |
This is kind of a unique situation. In the future, PRs with new algorithms will only be merged if they pass the tests. Now we had a bunch of algorithms before all tests were up and running... But I guess we can still ask authors to adjust their code. The problem with bounds only applied to a subset of the model parameters is a bit tricky. One solution could be to throuw a warning and set the bounds to +/- inf for the parameters where bounds are not used. This can then be detected by the test to skip testing of the bound for the specific parameter. +/- inf should be accepted as bounds by most optimization algorithms. |
You're making a good point regarding the bug fixing. We could fix the issue in PV's algorithm and see if we can get a thumbs up from her since it's such a small thing. Regarding the two algorithms that are mine. The subtracted does not estimate f, but calculates it based on the two S0's estimations. So there are no bounds to be applied there. The same is true for the intermediate step in the 3step algorithm (although there is a final estimation of f in the 3rd step where bounds are applied). This is by design and if this conflicts with the testing, then they should be excluded yeah. Or there's perhaps some other way we could change the test pass/fail criteria? E.g. only fail if we get a completely right answer for all parameters, and not only if one of the parameters are outside the strict bounds. |
| self.bounds = bounds | ||
| #bounds=bounds | ||
| #self.bounds = bounds | ||
| self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]], |
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 would be in favour of letting self.bounds remain the dictionary and only translate it to algorithm-specific notation in the ivim_fit routine, as a temporary variable. This gives more consistency and allows changing bounds in standardized fashion.
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.
Ah, I also sent an e-mail, although I see OScar may have touched upon some of those topics.
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 Pauliens code gives some of these errors that P0 is outside the bounds. Here is why:
1: Paulien does not use the user-specified P0, she calculates P0 herself. (src/original/PV_MUMC/two_step_IVIM_fit.py, e.g. line 79, 80)
2: She does this wrongly. She takes the mean of the bounds, but swaps he bounds. This means S0 initial guess is the mean of the Dt bounds and Dt initial guess is the mean of the S0 bounds.
79 boundsmonoexp = ([bounds[0][1], bounds[0][2]], [bounds[1][1], bounds[1][2]])
80 params, _ = curve_fit(monofit, high_b, high_dw_data, p0=[(bounds[1][1]-bounds[0][1])/2,(bounds[1][2]-bounds[0][2])/2], bounds=boundsmonoexp)
I do not know what to do here; it is source code, so we should not adapt it. But Paulien will also not really have time to fix this, I guess? @paulienvoorter ?
this does open a general discussion: what to do with faulty contributions? Should we at a point start trimming?
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.
And for src/standardized/IAR_LU_segmented_3step.py, the inital guess changes half way the fit routine. If we take a look at src/original/IAR_LundUniversity/ivim_fit_method_segmented_3step.py and then particular line 83, we see you update the intial guess for f0. Now if tight bounds are set, this runs into problems. Maybe you can add a check to see whether this new estimate is within the predefined fit boundaries?
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.
From the TCML_TechnionIIT there are a lot of fails, but this seems related to the fact that they do not really use bounds (properly)?
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.
@oliverchampion I dont think I was swapping the bounds, as I first pass Dt and then f (S0 bounds are not considered in the monoexponential fit in line 80). But Oscar is correct about the typo in line 80, which causes an incorrect initial guess.
I corrected this in #128
Let me know if I need to change this in other places as well
Describe the changes you have made in this PR
Implemented dictionary bounds and initial guesses in standardized algorithms where appropriate
Some issues remain when testing the "unreasonable" bounds.
I wasn't able to test the matlab code. Could one of you do it to check if it works?
Checklist