You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have added ModelSelectionResult dataclass and compare_models() function in file osipy\dce\fitting.py that fits multiple DCE models to the same data and compare them using aic ,bic and R^2.
ModelSelectionResult class holds the best-model map, aic, bic, R^2 score maps, and the full DCEFitResult class which is Result container for DCE model fitting for each model.
compare_models() takes a list of model names, fits each one using the fit_model() pipeline and calculates aic, bic, and return which model is better at each voxel.
3 selection criteria for user - aic, bic and R^2 which is default criterion.
The code also has error handling for edge cases. Every warning is logged and even if 1 fails, other models continues to fit.
Feature fixes#101 is implemented here.
Updated PR also fixes#102
Since the feature implementation and bug fix was in same file so I fixed in same file. @ltorres6 sir please see it. This is just a proof of concept PR, I will update it after your suggestion accordingly. I closed the previous PR as its issue #102 was fixed in this.Thank you sir.
Hey! Nice work adding model comparison — that's a useful feature. A few suggestions from reviewing the diff:
1. except Exception: without as e: (issue #102 fix)
The silent pass is replaced with logging, which is great. However the pattern used here:
exceptException:
logger.debug(...)
doesn't capture the exception object. The rest of the codebase (e.g., bayesian_ivim.py line 206) uses except Exception as e: and logs the actual error:
This gives much better diagnostic information when debugging fitting failures.
2. GPU compatibility in compare_models()
compare_models() uses np.asarray(concentration) directly. The osipy codebase is designed to be GPU/CPU agnostic using xp = get_array_module(array) (see osipy/common/backend/). Hardcoding np.asarray() would break when CuPy or JAX arrays are passed. Consider:
3. Bundling a bug fix (#102) with a feature (#101)
This PR bundles the #102 bug fix (4 lines) with the #101 model-selection feature (200+ lines). Separating them into individual PRs makes review easier and lets the quick bug fix land independently. The contributing guide recommends focused, single-concern PRs.
Hope this helps! Happy to discuss any of these points.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have added ModelSelectionResult dataclass and compare_models() function in file osipy\dce\fitting.py that fits multiple DCE models to the same data and compare them using aic ,bic and R^2.
ModelSelectionResult class holds the best-model map, aic, bic, R^2 score maps, and the full DCEFitResult class which is Result container for DCE model fitting for each model.
compare_models() takes a list of model names, fits each one using the fit_model() pipeline and calculates aic, bic, and return which model is better at each voxel.
3 selection criteria for user - aic, bic and R^2 which is default criterion.
The code also has error handling for edge cases. Every warning is logged and even if 1 fails, other models continues to fit.
Feature fixes #101 is implemented here.
Updated PR also fixes #102