Skip to content

Commit ba9fa91

Browse files
update
1 parent 66cb0db commit ba9fa91

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/original/OGC_AmsterdamUMC/LSQ_fitting.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,17 @@ def fit_segmented(bvalues, dw_data, bounds=([0, 0, 0.005],[0.005, 0.7, 0.2]), cu
134134
params, _ = curve_fit(lambda b, Dt, int: int * np.exp(-b * Dt ), high_b, high_dw_data,
135135
p0=(p0[0], p0[3]-p0[1]),
136136
bounds=bounds1)
137-
Dt, Fp = 0+params[0], 1 - params[1]
138-
if Fp < bounds[0][1] : Fp = bounds[0][1]
139-
if Fp > bounds[1][1] : Fp = bounds[1][1]
137+
Dt, Fp = params[0], 1 - params[1]
138+
if Fp < bounds[0][1] : Fp = np.float64(bounds[0][1])
139+
if Fp > bounds[1][1] : Fp = np.float64(bounds[1][1])
140140

141141
# remove the diffusion part to only keep the pseudo-diffusion
142142
dw_data_remaining = dw_data - (1 - Fp) * np.exp(-bvalues * Dt)
143143
bounds2 = (bounds[0][2], bounds[1][2])
144144
# fit for D*
145145
params, _ = curve_fit(lambda b, Dp: Fp * np.exp(-b * Dp), bvalues, dw_data_remaining, p0=(p0[2]), bounds=bounds2)
146-
Dp = 0+params[0]
147-
return Dt, np.float64(Fp), Dp
146+
Dp = params[0]
147+
return Dt, Fp, Dp
148148
except:
149149
# if fit fails, return zeros
150150
# print('segmented fit failed')

0 commit comments

Comments
 (0)