Skip to content

Warn about unrealistic bounds and initial guesses - #179

Open
vishrutgrover wants to merge 1 commit into
OSIPI:mainfrom
vishrutgrover:warn-unrealistic-bounds
Open

vishrutgrover wants to merge 1 commit into
OSIPI:mainfrom
vishrutgrover:warn-unrealistic-bounds

Conversation

@vishrutgrover

@vishrutgrover vishrutgrover commented Oct 3, 2026 •

Copy link
Copy Markdown

Describe the changes you have made in this PR

Adds OsipiBase.osipi_check_bounds_and_initial_guess(), which warns (UserWarning) when user-provided fit settings look unrealistic:

  • a lower bound is not below its upper bound
  • a bound or initial guess lies outside REALISTIC_BOUND_RANGES — the same ranges already asserted for default bounds in test_default_bounds_and_initial_guesses (D and Dp in mm²/s, normalised signal). This catches e.g. diffusivities given in µm²/ms.
  • an initial guess lies outside its own bounds
  • the upper bound of D exceeds the lower bound of Dp

The check runs once per object: when an algorithm is initiated via OsipiBase(algorithm=...), it runs in the second __init__ call only, so warnings are not duplicated. It is a warning only, fitting behaviour is unchanged. The generic and body-part defaults raise no warnings.

Example (D and Dp given in µm²/ms):

UserWarning: Possibly unrealistic fit setting: the upper bound of D (5) is outside the realistic range [0, 0.01]. Note that D and Dp are expected in mm2/s and the signal to be normalised.

New tests in tests/IVIMmodels/unit_tests/test_bounds_initial_guess_check.py (16 cases). Full suite locally (macOS, Python 3.11): 711 passed, 0 failed (695 before + 16 new).

Link this PR to an issue [optional]

Fixes #176

Checklist

  • Self-review of changed code
  • Added automated tests where applicable
  • Update Docs & Guides

Contributor: Vishrut Grover

@vishrutgrover
vishrutgrover deleted the warn-unrealistic-bounds branch October 3, 2026 08:25
@vishrutgrover
vishrutgrover restored the warn-unrealistic-bounds branch October 3, 2026 08:27
@vishrutgrover vishrutgrover reopened this Oct 3, 2026
@IvanARashid
IvanARashid self-requested a review October 5, 2026 14:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Warning when unrealistic bounds or starting values are given to fit algorithm

1 participant