Skip to content

Commit 9dfe0af

Browse files
author
IvanARashid
committed
Bugfixes for bounds and initial guesses
1 parent becea1a commit 9dfe0af

7 files changed

+17
-17
lines changed

src/original/IAR_LundUniversity/ivim_fit_method_linear.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ def sivim_model(self, b, S0, f, D):
8383

8484
def set_bounds(self, bounds):
8585
# Use this function for fits that uses curve_fit
86-
if bounds == None:
86+
if bounds is None:
8787
self.bounds = np.array([(0, 0, 0), (np.inf, 1, 0.004)])
8888
else:
89-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
89+
self.bounds = np.array([bounds[0], bounds[1]])
9090

9191
def set_initial_guess(self, initial_guess):
92-
if initial_guess == None:
92+
if initial_guess is None:
9393
self.initial_guess = (1, 0.2, 0.001)
9494
else:
9595
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_modified_mix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, gtab, bounds=None, maxiter=10, xtol=1e-8, rescale_units=False
7878
if gtab.bvals[-1] >= 10:
7979
self.bvals = gtab.bvals/1000
8080

81-
if bounds == None:
81+
if bounds is None:
8282
# Bounds expressed as (lower bound, upper bound) for [f, D*, D].
8383
self.bounds = np.array([(0, 1), (5, 100), (0, 4)])
8484
elif (bounds[0][1] <= 1) or rescale_units: # Realistically, if mm2/s units are used, D* bound is <= 1

src/original/IAR_LundUniversity/ivim_fit_method_modified_topopro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def __init__(self, gtab, bounds=[[0, 0.005, 1e-5], [1, 0.1, 0.004]], \
7676
# and are thus not changed.
7777
if gtab.bvals[-1] >= 10:
7878
self.bvals = gtab.bvals/1000
79-
if bounds == None:
79+
if bounds is None:
8080
# Bounds expressed as (lower bound, upper bound) for [f, D*, D].
8181
self.bounds = np.array([(0, 1), (5, 100), (0, 4)])
8282
elif (bounds[0][1] <= 1) or rescale_units: # Realistically, if mm2/s units are used, D* bound is <= 1

src/original/IAR_LundUniversity/ivim_fit_method_segmented_2step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ def ivim_signal(self, b, S0, f, D_star, D):
8686

8787
def set_bounds(self, bounds):
8888
# Use this function for fits that uses curve_fit
89-
if bounds == None:
89+
if bounds is None:
9090
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
9191
else:
92-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
92+
self.bounds = np.array([bounds[0], bounds[1]])
9393

9494
def set_initial_guess(self, initial_guess):
95-
if initial_guess == None:
95+
if initial_guess is None:
9696
self.initial_guess = (1, 0.2, 0.03, 0.001)
9797
else:
9898
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_segmented_3step.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ def ivim_signal(self, b, S0, f, D_star, D):
105105

106106
def set_bounds(self, bounds):
107107
# Use this function for fits that uses curve_fit
108-
if bounds == None:
108+
if bounds is None:
109109
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
110110
else:
111-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
111+
self.bounds = np.array([bounds[0], bounds[1]])
112112

113113
def set_initial_guess(self, initial_guess):
114-
if initial_guess == None:
114+
if initial_guess is None:
115115
self.initial_guess = (1, 0.2, 0.03, 0.001)
116116
else:
117117
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_sivim.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ def sivim_model(self, b, S0, f, D):
7777

7878
def set_bounds(self, bounds):
7979
# Use this function for fits that uses curve_fit
80-
if bounds == None:
80+
if bounds is None:
8181
self.bounds = np.array([(0, 0, 0), (np.inf, 1, 0.004)])
8282
else:
83-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
83+
self.bounds = np.array([bounds[0], bounds[1]])
8484

8585
def set_initial_guess(self, initial_guess):
86-
if initial_guess == None:
86+
if initial_guess is None:
8787
self.initial_guess = (1, 0.2, 0.001)
8888
else:
8989
self.initial_guess = initial_guess

src/original/IAR_LundUniversity/ivim_fit_method_subtracted.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def perfusion_signal(self, b, S0, D_star):
9393

9494
def set_bounds(self, bounds):
9595
# Use this function for fits that uses curve_fit
96-
if bounds == None:
96+
if bounds is None:
9797
self.bounds = np.array([(0, 0, 0.005, 0), (np.inf, 1, 0.1, 0.004)])
9898
else:
99-
self.bounds = np.array([(0, *bounds[0]), (np.inf, *bounds[1])])
99+
self.bounds = np.array([bounds[0], bounds[1]])
100100

101101
def set_initial_guess(self, initial_guess):
102-
if initial_guess == None:
102+
if initial_guess is None:
103103
self.initial_guess = (1, 0.2, 0.03, 0.001)
104104
else:
105105
self.initial_guess = initial_guess

0 commit comments

Comments
 (0)