Skip to content

Commit

Permalink
Merge pull request #1740 from skoudoro/fix-cvxpy-1.0.15
Browse files Browse the repository at this point in the history
[FIX] mapmri  with cvxpy 1.0.15
  • Loading branch information
arokem committed Feb 15, 2019
2 parents 818658b + 014b57f commit 04ddc4e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dipy/reconst/mapmri.py
Expand Up @@ -396,10 +396,16 @@ def fit(self, data):
data_norm = np.asarray(data / data[self.gtab.b0s_mask].mean())
c = cvxpy.Variable(M.shape[1])
design_matrix = cvxpy.Constant(M)
objective = cvxpy.Minimize(
cvxpy.sum_squares(design_matrix * c - data_norm) +
lopt * cvxpy.quad_form(c, laplacian_matrix)
)
# workaround for the bug on cvxpy 1.0.15 when lopt = 0
# See https://github.com/cvxgrp/cvxpy/issues/672
if not lopt:
objective = cvxpy.Minimize(
cvxpy.sum_squares(design_matrix * c - data_norm))
else:
objective = cvxpy.Minimize(
cvxpy.sum_squares(design_matrix * c - data_norm) +
lopt * cvxpy.quad_form(c, laplacian_matrix)
)
M0 = M[self.gtab.b0s_mask, :]
constraints = [(M0[0] * c) == 1,
(K * c) >= -0.1]
Expand Down Expand Up @@ -457,7 +463,6 @@ def __init__(self, model, mapmri_coef, mu, R, lopt, errorcode=0):
that after positivity constraint failed, also matrix inversion
failed.
"""

self.model = model
self._mapmri_coef = mapmri_coef
self.gtab = model.gtab
Expand Down

0 comments on commit 04ddc4e

Please sign in to comment.