Skip to content

Commit

Permalink
Merge pull request dipy#1419 from arokem/suppress_rcond_warning
Browse files Browse the repository at this point in the history
Suppress rcond warning
  • Loading branch information
skoudoro committed Feb 9, 2018
2 parents fc82829 + 87b1863 commit 7f45261
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dipy/reconst/csdeconv.py
Expand Up @@ -159,7 +159,8 @@ def __init__(self, gtab, response, reg_sphere=None, sh_order=8, lambda_=1,
else:
self.S_r = estimate_response(gtab, self.response[0],
self.response[1])
r_sh = np.linalg.lstsq(self.B_dwi, self.S_r[self._where_dwi])[0]
r_sh = np.linalg.lstsq(self.B_dwi, self.S_r[self._where_dwi],
rcond=-1)[0]
n_response = n
m_response = m
self.response_scaling = response[1]
Expand Down Expand Up @@ -313,7 +314,8 @@ def __init__(self, gtab, ratio, reg_sphere=None, sh_order=8, lambda_=1.,

@multi_voxel_fit
def fit(self, data):
s_sh = np.linalg.lstsq(self.B_dwi, data[self._where_dwi])[0]
s_sh = np.linalg.lstsq(self.B_dwi, data[self._where_dwi],
rcond=-1)[0]
# initial ODF estimation
odf_sh = np.dot(self.P, s_sh)
qball_odf = np.dot(self.B_reg, odf_sh)
Expand Down Expand Up @@ -641,7 +643,7 @@ def odf_deconv(odf_sh, R, B_reg, lambda_=1., tau=0.1, r2_term=False):
return np.zeros_like(odf_sh), 0

# Generate initial fODF estimate, which is the ODF truncated at SH order 4
fodf_sh = np.linalg.lstsq(R, odf_sh)[0]
fodf_sh = np.linalg.lstsq(R, odf_sh, rcond=-1)[0]
fodf_sh[15:] = 0

fodf = np.dot(B_reg, fodf_sh)
Expand Down Expand Up @@ -676,7 +678,7 @@ def odf_deconv(odf_sh, R, B_reg, lambda_=1., tau=0.1, r2_term=False):
M = np.concatenate((R, lambda_ * B_reg[k, :]))
ODF = np.concatenate((odf_sh, np.zeros(k.shape)))
try:
fodf_sh = np.linalg.lstsq(M, ODF)[0]
fodf_sh = np.linalg.lstsq(M, ODF, rcond=-1)[0]
except np.linalg.LinAlgError as lae:
# SVD did not converge in Linear Least Squares in current
# voxel. Proceeding with initial SH estimate for this voxel.
Expand Down Expand Up @@ -1043,7 +1045,8 @@ def recursive_response(gtab, data, mask=None, sh_order=8, peak_thr=0.01,
r, theta, phi = cart2sphere(x, y, z)
# for the gradient sphere
B_dwi = real_sph_harm(0, n, theta[:, None], phi[:, None])
r_sh_all += np.linalg.lstsq(B_dwi, data[num_vox, where_dwi])[0]
r_sh_all += np.linalg.lstsq(B_dwi, data[num_vox, where_dwi],
rcond=-1)[0]

response = r_sh_all / data.shape[0]
res_obj = AxSymShResponse(data[:, gtab.b0s_mask].mean(), response)
Expand Down

0 comments on commit 7f45261

Please sign in to comment.