Skip to content

Conversation

@hayakawa16
Copy link
Member

So far we have 3 inversion command line scripts:

  1. R(rho) to find chromophore concentrations of [Hb HbO2 H2O], with fixed single rho=1mm, 13 wavelengths [400:50:1000]nm and scatterer Power Law coefficients A=1.2, b=1.42. Scaled Monte Carlo with Nurbs forward solver provides the simulated measured data and PointSourceSDA provides the model used during the inversion.
    The optimization is performed by a python library scipy.
  2. same as above but instead of python scipy optimize, the inversion is performed using Vts.MPFitLevenbergMarquardt.Solve method.
    Currently 1) and 2) provide identical results
  3. R(fx) to find chromophore concentrations [Hb HbO2] and power law coefficients [A b] using fixed fx=[0 0.2]/mm and wavelengths=[650:50:1000]nm. Scaled Monte Carlo with Nurbs forward solver provides the simulated measured data and PointSourceSDA provides the model used during the inversion.
    The optimization is performed by a python library scipy.

hayakawa16 and others added 19 commits June 2, 2025 17:55
…ncentrations (assumes scattering fixed) for R(rho) measurements over a range of wavelengths. I am committing the "inverse crime" here because I'm using NURBS for simulated measured data and the model used for inversion. This runs and provides reasonable results using the python scipy.optimize least_squares method. However if I change the model to SDA point source it has warnings. Similar code can be found in MATLAB interop code and runs fine with SDA. So not sure if python optimization method not as robust as lsqcurvefit or if something else is wrong with code.
…y however tries to call our C# Solve method. The tricky thing here is that in order to use Solve we have to determine a way for python to create a "func" that can be read by our C# code. When this is executed, an error about the "func" not being of the correct format is given.
…A as model function! I would like to compare results with MATLAB generated results.

I updated r-of-rho-multi-op-prop-inversion-using-csharp.py to have updates made.
…ta as in vts_solver_demo.m, however found error in vts_solver_demo Example 18 last line of code. Error should show error between recovered chromophore concs and measured, it currently shows error of first 3 R(rho) estimates for measured and recovered.

Updated the -csharp-solve accordingly.
…...]. This version flattens data in order [op1fx1 op2fx2 op3fx1 ...]. These two version give same results. For both it bothers me that Chi2 converged is larger than initial guess. I thought reordering of flattened data would change something but it didn't. I guess that makes sense.
…eration values to be the chromophores not mua.
….. results using python optimization and C# Solve are identical.
…... script but having trouble converting IScatterer.GetMusp(wavelength) to an array that python understands.
…. No wonder results look so good. Here I am using PointSourceSDA. This is the reason results don't match.
@hayakawa16 hayakawa16 requested a review from lmalenfant June 10, 2025 22:08
@hayakawa16 hayakawa16 linked an issue Jun 10, 2025 that may be closed by this pull request
@hayakawa16
Copy link
Member Author

@lmalenfant, I am ready for review on this PR.

Copy link
Member

@lmalenfant lmalenfant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled the code locally and everything runs great, I just noticed an inconsistency in the axis label for wavelength and noted it in the code.

opsFit = Tissue(chromophoresFit, scatterer, "", n=1.4).GetOpticalProperties(wavelengths)
rOfRhoFit= forwardSolverForInversion.ROfRho(opsFit, rho)
# plot the results using Plotly
xLabel = "wavelengths [nm]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the other plot this is singular, we should keep it consistent for both plots.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Thanks!

@hayakawa16 hayakawa16 merged commit 50d58ee into main Jun 24, 2025
@hayakawa16 hayakawa16 deleted the feature/18-add-inverse-solution-scripts branch June 24, 2025 22:00
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.

Add inverse solution scripts

3 participants