@@ -41,9 +41,11 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
4141 Our OsipiBase object could contain functions that compare the inputs with
4242 the requirements.
4343 """
44- #super(OGC_AmsterdamUMC_biexp, self).__init__(bvalues, bounds, initial_guess, fitS0)
4544 super (ASD_MemorialSloanKettering_QAMPER_IVIM , self ).__init__ (bvalues = bvalues , bounds = bounds , initial_guess = initial_guess )
46- self .initialize (bounds , initial_guess )
45+
46+ self .use_bounds = {"f" : True , "D" : True , "Dp" : True , "S0" : True }
47+ self .use_initial_guess = {"f" : True , "D" : True , "Dp" : True , "S0" : True }
48+
4749 if eng is None :
4850 print ('initiating matlab; this may take some time. For repeated testing one could use the optional input eng as an already initiated matlab engine' )
4951 self .eng = matlab .engine .start_matlab ()
@@ -63,21 +65,6 @@ def algorithm(self,dwi_arr, bval_arr, LB0, UB0, x0in):
6365 (f_arr , D_arr , Dx_arr , s0_arr , fitted_dwi_arr , RSS , rms_val , chi , AIC , BIC , R_sq ) = results
6466 return D_arr / 1000 , f_arr , Dx_arr / 1000 , s0_arr
6567
66- def initialize (self , bounds , initial_guess ):
67- if bounds is None :
68- print ('warning, no bounds were defined, so algorithm-specific default bounds are used' )
69- self .bounds = ([1e-6 , 0 , 0.004 , 0 ],[0.003 , 1.0 , 0.2 , 5 ])
70- else :
71- self .bounds = bounds
72- if initial_guess is None :
73- print ('warning, no initial guesses were defined, so algorithm-specific default initial guess is used' )
74- self .initial_guess = [0.001 , 0.2 , 0.01 , 1 ]
75- else :
76- self .initial_guess = initial_guess
77- self .use_initial_guess = True
78- self .use_initial_guess = True
79- self .use_bounds = True
80-
8168 def ivim_fit (self , signals , bvalues , ** kwargs ):
8269 """Perform the IVIM fit
8370
@@ -88,12 +75,16 @@ def ivim_fit(self, signals, bvalues, **kwargs):
8875 Returns:
8976 _type_: _description_
9077 """
78+ bounds = ([self .bounds ["D" ][0 ], self .bounds ["f" ][0 ], self .bounds ["Dp" ][0 ], self .bounds ["S0" ][0 ]],
79+ [self .bounds ["D" ][1 ], self .bounds ["f" ][1 ], self .bounds ["Dp" ][1 ], self .bounds ["S0" ][1 ]])
80+
81+ initial_guess = [self .initial_guess ["D" ], self .initial_guess ["f" ], self .initial_guess ["Dp" ], self .initial_guess ["S0" ]]
9182
9283 bvalues = np .array (bvalues )
93- LB = np .array (self . bounds [0 ])[[1 ,0 ,2 ,3 ]]
94- UB = np .array (self . bounds [1 ])[[1 ,0 ,2 ,3 ]]
84+ LB = np .array (bounds [0 ])[[1 ,0 ,2 ,3 ]]
85+ UB = np .array (bounds [1 ])[[1 ,0 ,2 ,3 ]]
9586
96- fit_results = self .algorithm (np .array (signals )[:,np .newaxis ], bvalues , LB , UB , np .array (self . initial_guess )[[1 ,0 ,2 ,3 ]])
87+ fit_results = self .algorithm (np .array (signals )[:,np .newaxis ], bvalues , LB , UB , np .array (initial_guess )[[1 ,0 ,2 ,3 ]])
9788
9889 results = {}
9990 results ["D" ] = fit_results [0 ]
0 commit comments