scottprahl / iad

Forward and Inverse Radiative Transport using the Adding-Doubling method
MIT License
22 stars 8 forks source link

Poor fitting to measured spectra using versions 3.11.5 onwards of IAD software #13

Closed anishabahl closed 10 months ago

anishabahl commented 1 year ago

Dear Sir/Madam/Mx, I have found the IAD software to be invaluable to my PhD (in King's College London supervised by Prof Tom Vercauteren) and am very grateful for its availability and documentation! We have found that using the latest versions of the software (versions 3.11.5 onwards) gives odd fits to the measured data in the output files. Examples of this can be found attached and in the MWE_phantom_IAD_version_discrepancy.ipynb here along with some example measurements. When using the dual-beam settings (as is relevant to our set-up) the absorbance and reduced scattering coefficients remain largely the same, however. We would be very grateful for any explanation of this or advice for how to improve these results! Many thanks, Anisha Bahl measuredvfitted_reflectance_versions measuredvfitted_transmittance_versions

tvercaut commented 1 year ago

In case it's easier to run iad without plotting etc, here is a small example illustrating the fitting issue with iad version >= 3.11.5

Input file: pbinput.rxt

IAD1
#
# Tests using measured values for M_R and M_T
# by Anisha Bahl
#
1.41  # Index of refraction of sample
1.0  # Index of refraction of top slide
2.65  # [mm] Thickness of sample
0.0  # [mm] Thickness of slides
10.0  # [mm] Diameter of illumination beam 
0.98  # Reflectance of calibration standard
1  # [mm] Number of spheres used during each measurement
# Reflection sphere properties (unused if n_spheres=0)
100.0  # [mm] Sphere Diameter
21.8  # [mm] Sample Port Diameter
18.3  # [mm] Entrance Port Diameter
8.0  # [mm] Detector Port Diameter
0.98  # Reflectivity of the sphere wall
# Transmission sphere properties (unused if n_spheres=0)
100.0  # [mm] Sphere Diameter
18.3  # [mm] Sample Port Diameter
0.0  # [mm] Entrance Port Diameter
8.0  # [mm] Detector Port Diameter
0.98  # Reflectivity of the sphere wall
2  # [mm] Number of measurements
# M_R M_T 
640.0 0.63162425 0.18490826999999999 #0.9
630.0 0.63364865 0.18168763 #0.9

Command line call

iad -X -i 8 -g 0.9 pbinput.rxt

output

# Inverse Adding-Doubling 3-12-0 (21 Jun 2023) 
# 
#                        Beam diameter =    10.0 mm
#                     Sample thickness =   2.650 mm
#                  Top slide thickness =   0.000 mm
#               Bottom slide thickness =   0.000 mm
#           Sample index of refraction =  1.4100
#        Top slide index of refraction =  1.0000
#     Bottom slide index of refraction =  1.0000
# 
#    Fraction unscattered refl. in M_R =   100.0 %
#   Fraction unscattered trans. in M_T =   100.0 %
# 
# Reflection sphere
#                      sphere diameter =   100.0 mm
#                 sample port diameter =    21.8 mm
#               entrance port diameter =    18.3 mm
#               detector port diameter =     8.0 mm
#                     wall reflectance =    98.0 %
#                 standard reflectance =    98.0 %
#                 detector reflectance =     0.0 %
#
# Transmission sphere
#                      sphere diameter =   100.0 mm
#                 sample port diameter =    18.3 mm
#               entrance port diameter =     0.0 mm
#               detector port diameter =     8.0 mm
#                     wall reflectance =    98.0 %
#               standard transmittance =   100.0 %
#                 detector reflectance =     0.0 %
#
# M_R and M_T were measured using the comparison (dual-beam) method.
# Single sphere corrections were used with light incident at 8 degrees from the normal.
# The inverse routine adapted to the input data.
# 
# 
#                 AD quadrature points =  12
#             AD tolerance for success =   0.00010
#      MC tolerance for mu_a and mu_s' =   0.010 %
#  Photons used to estimate lost light =   100000
#
#       Measured       M_R      Measured       M_T      Estimated   Estimated   Estimated
##wave     M_R         fit         M_T         fit        mu_a        mu_s'         g    
# [nm]    [---]       [---]       [---]       [---]       1/mm        1/mm        [---]  
 640.0     0.6316      0.6956      0.1849      0.2171      0.0202      2.6936      0.9000   # * 
 630.0     0.6336      0.5697      0.1817      0.2151      0.0204      2.7408      0.9000   # * 
scottprahl commented 10 months ago

@anishabahl @tvercaut Sorry for the long delay. I was very busy when the bug was initially reported and forgot about it until I was reviewing reported issues.

Thank you for the bug report. You are correct. I introduced a bug in 3.11.5 when I added another feature.

This problem was resolved in the recently released version v3.14.0

tvercaut commented 10 months ago

Many thanks!

anishabahl commented 10 months ago

Thank you!