-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The D_and_Ds_swap() method in OsipiBase corrects mislabelled D and D* (Dp) parameters after fitting. When the optimizer assigns them to the wrong parameter (i.e., D > Dp and Dp < 0.05), it swaps them and adjusts f = 1 - f.
Currently, only 9 out of 22 non-DL/non-MATLAB algorithms call this method after fitting. The remaining 13 algorithms skip this correction, leading to inconsistent parameter labelling across algorithms when the optimizer produces swapped results.
Screenshots [optional]
No response
Steps To Reproduce
import numpy as np
import os, sys
sys.path.insert(0, os.getcwd())
# Check source code for the presence of D_and_Ds_swap
algo_dir = os.path.join("src", "standardized")
algorithms = [
"IAR_LU_biexp", "IAR_LU_segmented_2step", "IAR_LU_segmented_3step",
"IAR_LU_subtracted", "IAR_LU_modified_mix", "IAR_LU_modified_topopro",
"PV_MUMC_biexp",
"OGC_AmsterdamUMC_biexp", "OGC_AmsterdamUMC_biexp_segmented", "OGC_AmsterdamUMC_Bayesian_biexp",
"OJ_GU_seg", "PvH_KB_NKI_IVIMfit", "TF_reference_IVIMfit",
"TCML_TechnionIIT_lsqlm", "TCML_TechnionIIT_lsqtrf", "TCML_TechnionIIT_lsqBOBYQA",
"TCML_TechnionIIT_SLS", "TCML_TechnionIIT_lsq_sls_lm",
"TCML_TechnionIIT_lsq_sls_trf", "TCML_TechnionIIT_lsq_sls_BOBYQA",
"ETP_SRI_LinearFitting", "ASD_MemorialSloanKettering_QAMPER_IVIM",
]
for algo in sorted(algorithms):
fpath = os.path.join(algo_dir, f"{algo}.py")
if os.path.exists(fpath):
with open(fpath) as f:
content = f.read()
has_it = "D_and_Ds_swap" in content
tag = "HAS" if has_it else "MISSING"
print(f" [{tag:7s}] {algo}")Expected behavior
All algorithms should consistently apply D_and_Ds_swap() after fitting to ensure correct D/D* labelling.
Additional context
Output on main branch:
[HAS ] ASD_MemorialSloanKettering_QAMPER_IVIM
[HAS ] ETP_SRI_LinearFitting
[HAS ] IAR_LU_biexp
[HAS ] IAR_LU_modified_mix
[HAS ] IAR_LU_modified_topopro
[HAS ] IAR_LU_segmented_2step
[MISSING] IAR_LU_segmented_3step
[MISSING] IAR_LU_subtracted
[MISSING] OGC_AmsterdamUMC_Bayesian_biexp
[MISSING] OGC_AmsterdamUMC_biexp
[MISSING] OGC_AmsterdamUMC_biexp_segmented
[MISSING] OJ_GU_seg
[MISSING] PV_MUMC_biexp
[MISSING] PvH_KB_NKI_IVIMfit
[HAS ] TCML_TechnionIIT_lsqBOBYQA
[HAS ] TCML_TechnionIIT_lsqlm
[MISSING] TCML_TechnionIIT_lsq_sls_BOBYQA
[MISSING] TCML_TechnionIIT_lsq_sls_lm
[MISSING] TCML_TechnionIIT_lsq_sls_trf
[HAS ] TCML_TechnionIIT_lsqtrf
[MISSING] TCML_TechnionIIT_SLS
[MISSING] TF_reference_IVIMfit
13 algorithms are MISSING the call.
Suggested Fix
Add results = self.D_and_Ds_swap(results) just before return results in the ivim_fit() method of each of the 13 missing algorithms.
Are you working on this?
Yes