Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def __init__(self, gtab, bounds=None, maxiter=10, xtol=1e-8, rescale_units=False
(bounds[0][1]*1000, bounds[1][1]*1000), \
(bounds[0][2]*1000, bounds[1][2]*1000)])
else: # Finally, if units if µm2/ms are already used
self.bounds = np.array([(bounds[0][0], bounds[1][0], \
self.bounds = np.array([(bounds[0][0], bounds[1][0]), \
(bounds[0][1], bounds[1][1]), \
(bounds[0][2], bounds[1][2]))])
(bounds[0][2], bounds[1][2])])

@multi_voxel_fit
def fit(self, data, bounds_de=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def __init__(self, gtab, bounds=[[0, 0.005, 1e-5], [1, 0.1, 0.004]], \
(bounds[0][1]*1000, bounds[1][1]*1000), \
(bounds[0][2]*1000, bounds[1][2]*1000)])
else: # Finally, if units if µm2/ms are already used
self.bounds = np.array([(bounds[0][0], bounds[1][0], \
self.bounds = np.array([(bounds[0][0], bounds[1][0]), \
(bounds[0][1], bounds[1][1]), \
(bounds[0][2], bounds[1][2]))])
(bounds[0][2], bounds[1][2])])

@multi_voxel_fit
def fit(self, data):
Expand Down
9 changes: 5 additions & 4 deletions src/standardized/ASD_MemorialSloanKettering_QAMPER_IVIM.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,17 @@ def algorithm(self,dwi_arr, bval_arr, LB0, UB0, x0in):
return D_arr/1000, f_arr, Dx_arr/1000, s0_arr

def initialize(self, bounds, initial_guess):
if bounds is None:
if self.bounds is None:
print('warning, no bounds were defined, so algorithm-specific default bounds are used')
self.bounds=([1e-6, 0, 0.004, 0],[0.003, 1.0, 0.2, 5])
else:
self.bounds=bounds
if initial_guess is None:
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if self.initial_guess is None:
print('warning, no initial guesses were defined, so algorithm-specific default initial guess is used')
self.initial_guess = [0.001, 0.2, 0.01, 1]
else:
self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.use_initial_guess = True
self.use_bounds = True
Expand Down
13 changes: 11 additions & 2 deletions src/standardized/IAR_LU_biexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,19 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_biexp, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
if initial_guess is None:
self.use_initial_guess = False

# Check the inputs
# Adapt the standardized bounds to the format of the specific algorithm
self.bounds = [[self.bounds["S0"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["D"][0]],
[self.bounds["S0"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["D"][1]]]

# Adapt the standardized initial guess to the format of the specific algorithm
self.initial_guess = [self.initial_guess["S0"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["D"]]

# Initialize the algorithm
if self.bvalues is not None:
bvec = np.zeros((self.bvalues.size, 3))
Expand Down
13 changes: 9 additions & 4 deletions src/standardized/IAR_LU_modified_mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_modified_mix, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
self.use_initial_guess = False # This algorithm does not use initial guesses

# Additional options
self.stochastic = True

# Check the inputs

# Adapt the standardized bounds to the format of the specific algorithm
self.bounds = [[self.bounds["f"][0], self.bounds["Dp"][0]*1000, self.bounds["D"][0]*1000],
[self.bounds["f"][1], self.bounds["Dp"][1]*1000, self.bounds["D"][1]*1000]]
#self.bounds = [[bounds["f"][0], bounds["f"][1]], [bounds["Dp"][0]*1000, bounds["Dp"][1]*1000], [bounds["D"][0]*1000, bounds["D"][1]*1000]]

# Initialize the algorithm
if self.bvalues is not None:
bvec = np.zeros((self.bvalues.size, 3))
bvec[:,2] = 1
gtab = gradient_table(self.bvalues, bvec, b0_threshold=0)

self.IAR_algorithm = IvimModelVP(gtab, bounds=self.bounds, rescale_results_to_mm2_s=True)
self.IAR_algorithm = IvimModelVP(gtab, bounds=self.bounds, rescale_units=False, rescale_results_to_mm2_s=True)
else:
self.IAR_algorithm = None

Expand Down
16 changes: 14 additions & 2 deletions src/standardized/IAR_LU_modified_topopro.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_modified_topopro, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
self.use_initial_guess = False # This algorithm does not use initial guesses

# Additional options
self.stochastic = True

# Check the inputs
# Adapt the standardized bounds to the format of the specific algorithm
if self.bounds["Dp"][0] == self.bounds["D"][1]:
print('warning, bounds for D* and D are equal, this will likely cause fitting errors. Setting D_upper to 99 percent of D_upper')
self.bounds["D"][1] = self.bounds["D"][1]*0.99
self.bounds = [[self.bounds["f"][0], self.bounds["Dp"][0]*1000, self.bounds["D"][0]*1000],
[self.bounds["f"][1], self.bounds["Dp"][1]*1000, self.bounds["D"][1]*1000]]
# Check the inputs

# Initialize the algorithm
Expand Down
15 changes: 12 additions & 3 deletions src/standardized/IAR_LU_segmented_2step.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,25 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_segmented_2step, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
if initial_guess is None:
self.use_initial_guess = False
# Check the inputs

# Adapt the bounds to the format needed for the algorithm
self.bounds = [[self.bounds["S0"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["D"][0]], \
[self.bounds["S0"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["D"][1]]]

# Adapt the initial guess to the format needed for the algorithm
self.initial_guess = [self.initial_guess["S0"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["D"]]

# Initialize the algorithm
if self.bvalues is not None:
bvec = np.zeros((self.bvalues.size, 3))
bvec[:,2] = 1
gtab = gradient_table(self.bvalues, bvec, b0_threshold=0)

self.IAR_algorithm = IvimModelSegmented2Step(gtab, bounds=self.bounds, initial_guess=self.initial_guess, b_threshold=self.thresholds)
else:
self.IAR_algorithm = None
Expand Down
13 changes: 11 additions & 2 deletions src/standardized/IAR_LU_segmented_3step.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_segmented_3step, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
if initial_guess is None:
self.use_initial_guess = False
# Check the inputs

# Adapt the bounds to the format needed for the algorithm
self.bounds = [[self.bounds["S0"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["D"][0]], \
[self.bounds["S0"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["D"][1]]]

# Adapt the initial guess to the format needed for the algorithm
self.initial_guess = [self.initial_guess["S0"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["D"]]

# Initialize the algorithm
if self.bvalues is not None:
Expand Down
13 changes: 11 additions & 2 deletions src/standardized/IAR_LU_subtracted.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,18 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
super(IAR_LU_subtracted, self).__init__(bvalues, thresholds, bounds, initial_guess)
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False
self.use_initial_guess = False
if bounds is None:
self.use_bounds = False
if initial_guess is None:
self.use_initial_guess = False
# Check the inputs

# Adapt the bounds to the format needed for the algorithm
self.bounds = [[self.bounds["S0"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["D"][0]], \
[self.bounds["S0"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["D"][1]]]

# Adapt the initial guess to the format needed for the algorithm
self.initial_guess = [self.initial_guess["S0"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["D"]]

# Initialize the algorithm
if self.bvalues is not None:
Expand Down
5 changes: 3 additions & 2 deletions src/standardized/IVIM_NEToptim.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def initialize(self, bounds, initial_guess, fitS0, traindata, SNR, n):
self.training_data(self.bvalues,n=n,SNR=SNR)
self.arg=Arg()
if bounds is not None:
self.arg.net_pars.cons_min = bounds[0] # Dt, Fp, Ds, S0
self.arg.net_pars.cons_max = bounds[1] # Dt, Fp, Ds, S0
self.arg.net_pars.cons_min = np.array([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]])#bounds[0] # Dt, Fp, Ds, S0
self.arg.net_pars.cons_max = np.array([self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])#bounds[1] # Dt, Fp, Ds, S0
self.use_bounds = True
if traindata is None:
self.net = deep.learn_IVIM(self.train_data['data'], self.bvalues, self.arg)
else:
Expand Down
5 changes: 3 additions & 2 deletions src/standardized/OGC_AmsterdamUMC_Bayesian_biexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ def initialize(self, bounds=None, initial_guess=None, fitS0=True, prior_in=None,
print('warning, no bounds were defined, so default bounds are used of [0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3]')
self.bounds=([0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3])
else:
self.bounds=bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if initial_guess is None:
print('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.001, 0.01, 1]')
self.initial_guess = [0.001, 0.001, 0.01, 1]
else:
self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.use_bounds = True
if thresholds is None:
Expand Down
5 changes: 3 additions & 2 deletions src/standardized/OGC_AmsterdamUMC_biexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ def initialize(self, bounds, initial_guess, fitS0):
print('warning, no bounds were defined, so default bounds are used of [0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3]')
self.bounds=([0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3])
else:
self.bounds=bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if initial_guess is None:
print('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.001, 0.01, 1]')
self.initial_guess = [0.001, 0.1, 0.01, 1]
else:
self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.fitS0=fitS0
self.use_initial_guess = True
Expand Down
5 changes: 3 additions & 2 deletions src/standardized/OGC_AmsterdamUMC_biexp_segmented.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ def initialize(self, bounds, initial_guess, thresholds):
print('warning, no bounds were defined, so default bounds are used of [0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3]')
self.bounds=([0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3])
else:
self.bounds=bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if initial_guess is None:
print('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.001, 0.01, 1]')
self.initial_guess = [0.001, 0.001, 0.01, 1]
else:
self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.use_bounds = True
if thresholds is None:
Expand Down
5 changes: 3 additions & 2 deletions src/standardized/OJ_GU_bayesMATLAB.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ def initialize(self, bounds,initial_guess):
print('warning, no bounds were defined, so default bounds are used of [0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3]')
self.bounds=([0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3])
else:
self.bounds=bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if initial_guess is None:
print('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.001, 0.01, 1]')
self.initial_guess = [0.001, 0.1, 0.01, 1]
else:
self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.use_initial_guess = True
self.use_bounds = True
Expand Down
3 changes: 2 additions & 1 deletion src/standardized/OJ_GU_segMATLAB.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def initialize(self, bounds, thresholds):
print('warning, no bounds were defined, so algorithm-specific default bounds are used')
self.bounds=([1e-6, 0, 0.003, 0],[0.003, 1.0, 0.2, 5])
else:
self.bounds=bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
self.use_bounds = True
if thresholds is None:
self.thresholds = 200
Expand Down
6 changes: 5 additions & 1 deletion src/standardized/PV_MUMC_biexp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def __init__(self, bvalues=None, thresholds=None, bounds=None, initial_guess=Non
self.PV_algorithm = fit_least_squares
if bounds is not None:
print('warning, bounds from wrapper are not (yet) used in this algorithm')
self.use_bounds = False

self.bounds = ([self.bounds["S0"][0], self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0]],
[self.bounds["S0"][1], self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1]])

self.use_bounds = True
self.use_initial_guess = False


Expand Down
8 changes: 5 additions & 3 deletions src/standardized/TCML_TechnionIIT_SLS.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ def initialize(self, bounds, fitS0,thresholds):
self.bounds = ([0.0003, 0.001, 0.009, 0],[0.008, 0.5,0.04, 3])
else:
print('warning, although bounds are given, only D* is bounded)')
bounds=bounds
self.bounds = bounds
#bounds=bounds
#self.bounds = bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
self.fitS0=fitS0
self.use_bounds = False
self.use_bounds = True
if thresholds is None:
self.thresholds = 150
print('warning, no thresholds were defined, so default bounds are used of 150')
Expand Down
9 changes: 6 additions & 3 deletions src/standardized/TCML_TechnionIIT_lsqBOBYQA.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ def initialize(self, bounds, initial_guess, fitS0):
print('warning, no bounds were defined, so default bounds are used of [0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3]')
self.bounds = ([0, 0, 0.005, 0.7],[0.005, 1.0, 0.2, 1.3])
else:
bounds=bounds
self.bounds = bounds
#bounds=bounds
#self.bounds = bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if initial_guess is None:
print('warning, no initial guesses were defined, so default bounds are used of [0.001, 0.001, 0.01, 1]')
self.initial_guess = [0.001, 0.1, 0.02, 1] # D, Dp, f, S0
else:
self.initial_guess = initial_guess
#self.initial_guess = initial_guess
self.initial_guess = [self.initial_guess["D"], self.initial_guess["f"], self.initial_guess["Dp"], self.initial_guess["S0"]]
self.use_initial_guess = True
self.fitS0=fitS0
self.use_initial_guess = True
Expand Down
8 changes: 5 additions & 3 deletions src/standardized/TCML_TechnionIIT_lsq_sls_BOBYQA.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,17 @@ def initialize(self, bounds, fitS0, thresholds):
print('warning, no bounds were defined, so default bounds are used of ([0.0003, 0.001, 0.009, 0],[0.008, 1.0,0.04, 3])')
self.bounds = ([0.0003, 0.001, 0.009, 0],[0.008, 1.0 ,0.04, 3])
else:
bounds=bounds
self.bounds = bounds
#bounds=bounds
#self.bounds = bounds
self.bounds = ([self.bounds["D"][0], self.bounds["f"][0], self.bounds["Dp"][0], self.bounds["S0"][0]],
[self.bounds["D"][1], self.bounds["f"][1], self.bounds["Dp"][1], self.bounds["S0"][1]])
if thresholds is None:
self.thresholds = 200
print('warning, no thresholds were defined, so default bounds are used of 200')
else:
self.thresholds = thresholds
self.fitS0=fitS0
self.use_bounds = False
self.use_bounds = True
self.use_initial_guess = False

def ivim_fit(self, signals, bvalues, **kwargs):
Expand Down
Loading
Loading