@@ -48,23 +48,16 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
4848
4949 def initialize (self , bounds , initial_guess , fitS0 ):
5050 if bounds is None :
51- print ('warning, no bounds were defined, so default bounds are used of ([0.0003, 0.001, 0.009, 0],[0.008, 0.5,0.04, 3])' )
52- self .bounds = ([0.0003 , 0.001 , 0.009 , 0 ],[0.008 , 0.5 ,0.04 , 3 ])
51+ self .use_bounds = {"f" : False , "Dp" : False , "D" : False }
5352 else :
54- #bounds=bounds
55- #self.bounds = bounds
56- self .bounds = ([self .bounds ["D" ][0 ], self .bounds ["f" ][0 ], self .bounds ["Dp" ][0 ], self .bounds ["S0" ][0 ]],
57- [self .bounds ["D" ][1 ], self .bounds ["f" ][1 ], self .bounds ["Dp" ][1 ], self .bounds ["S0" ][1 ]])
53+ self .use_bounds = {"f" : True , "Dp" : True , "D" : True }
54+
5855 if initial_guess is None :
59- print ('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.1, 0.01, 1]' )
60- self .initial_guess = [0.001 , 0.1 , 0.01 , 1 ] # D, Dp, f, S0
56+ self .use_initial_guess = {"f" : False , "Dp" : False , "D" : False }
6157 else :
62- #self.initial_guess = initial_guess
63- self .initial_guess = [self .initial_guess ["D" ], self .initial_guess ["f" ], self .initial_guess ["Dp" ], self .initial_guess ["S0" ]]
64- self .use_initial_guess = True
58+ self .use_initial_guess = {"f" : True , "Dp" : True , "D" : True }
59+
6560 self .fitS0 = fitS0
66- self .use_initial_guess = True
67- self .use_bounds = True
6861
6962 def ivim_fit (self , signals , bvalues , ** kwargs ):
7063 """Perform the IVIM fit
@@ -76,12 +69,11 @@ def ivim_fit(self, signals, bvalues, **kwargs):
7669 Returns:
7770 _type_: _description_
7871 """
72+ bounds = ([self .bounds ["D" ][0 ], self .bounds ["Dp" ][0 ], self .bounds ["f" ][0 ], self .bounds ["S0" ][0 ]],
73+ [self .bounds ["D" ][1 ], self .bounds ["Dp" ][1 ], self .bounds ["f" ][1 ], self .bounds ["S0" ][1 ]])
74+ initial_guess = [self .initial_guess ["D" ], self .initial_guess ["Dp" ], self .initial_guess ["f" ], self .initial_guess ["S0" ]]
7975
8076 bvalues = np .array (bvalues )
81- bounds = np .array (self .bounds )
82- bounds = [bounds [0 ][[0 , 2 , 1 , 3 ]], bounds [1 ][[0 , 2 , 1 , 3 ]]]
83- initial_guess = np .array (self .initial_guess )
84- initial_guess = initial_guess [[0 , 2 , 1 , 3 ]]
8577 fit_results = self .fit_least_squares (bvalues , np .array (signals )[:,np .newaxis ], bounds ,initial_guess )
8678
8779 results = {}
0 commit comments