Skip to content

Commit

Permalink
Added cvxpy requirement and code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
etpeterson committed May 26, 2023
1 parent c4ab12b commit ba55cd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ logging
joblib
dipy
matplotlib
scienceplots
scienceplots
cvxpy
6 changes: 3 additions & 3 deletions src/original/OGC_AmsterdamUMC/LSQ_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def empirical_neg_log_prior(Dt0, Fp0, Dp0, S00=None):
# define the prior
def neg_log_prior(p):
# depends on whether S0 is fitted or not
if len(p) is 4:
if len(p) == 4:
Dt, Fp, Dp, S0 = p[0], p[1], p[2], p[3]
else:
Dt, Fp, Dp = p[0], p[1], p[2]
Expand All @@ -507,7 +507,7 @@ def neg_log_prior(p):
Dt_prior = stats.lognorm.pdf(Dt, Dt_shape, scale=Dt_scale)
Fp_prior = stats.beta.pdf(Fp, Fp_a, Fp_b)
# determine and return the prior for D, f and D* (and S0)
if len(p) is 4:
if len(p) == 4:
S0_prior = stats.beta.pdf(S0 / 2, S0_a, S0_b)
return -np.log(Dp_prior + eps) - np.log(Dt_prior + eps) - np.log(Fp_prior + eps) - np.log(
S0_prior + eps)
Expand All @@ -525,7 +525,7 @@ def neg_log_likelihood(p, bvalues, dw_data):
:param dw_data: 1D Array diffusion-weighted data
:returns: the log-likelihood of the parameters given the data
"""
if len(p) is 4:
if len(p) == 4:
return 0.5 * (len(bvalues) + 1) * np.log(
np.sum((ivim(bvalues, p[0], p[1], p[2], p[3]) - dw_data) ** 2)) # 0.5*sum simplified
else:
Expand Down

0 comments on commit ba55cd3

Please sign in to comment.