From 96e8965c14bda01471216dd7ddfbbf2820154ac3 Mon Sep 17 00:00:00 2001 From: arokem Date: Thu, 8 Feb 2018 14:05:30 -0800 Subject: [PATCH 1/2] Suppress a FutureWarning in csdeconv. --- dipy/reconst/csdeconv.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dipy/reconst/csdeconv.py b/dipy/reconst/csdeconv.py index 8152d6801c..a5e67e14e6 100644 --- a/dipy/reconst/csdeconv.py +++ b/dipy/reconst/csdeconv.py @@ -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=None)[0] n_response = n m_response = m self.response_scaling = response[1] @@ -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=None)[0] # initial ODF estimation odf_sh = np.dot(self.P, s_sh) qball_odf = np.dot(self.B_reg, odf_sh) @@ -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=None)[0] fodf_sh[15:] = 0 fodf = np.dot(B_reg, fodf_sh) @@ -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=None)[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. @@ -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=None)[0] response = r_sh_all / data.shape[0] res_obj = AxSymShResponse(data[:, gtab.b0s_mask].mean(), response) From 87b1863de8060815a3b62ad00b5e046db3efd4e9 Mon Sep 17 00:00:00 2001 From: arokem Date: Fri, 9 Feb 2018 08:32:13 -0800 Subject: [PATCH 2/2] Replace `rcond=None` with the (back-compatible?) `rcond=-1` --- dipy/reconst/csdeconv.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dipy/reconst/csdeconv.py b/dipy/reconst/csdeconv.py index a5e67e14e6..8f470a43cf 100644 --- a/dipy/reconst/csdeconv.py +++ b/dipy/reconst/csdeconv.py @@ -160,7 +160,7 @@ def __init__(self, gtab, response, reg_sphere=None, sh_order=8, lambda_=1, 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], - rcond=None)[0] + rcond=-1)[0] n_response = n m_response = m self.response_scaling = response[1] @@ -315,7 +315,7 @@ 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], - rcond=None)[0] + rcond=-1)[0] # initial ODF estimation odf_sh = np.dot(self.P, s_sh) qball_odf = np.dot(self.B_reg, odf_sh) @@ -643,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, rcond=None)[0] + fodf_sh = np.linalg.lstsq(R, odf_sh, rcond=-1)[0] fodf_sh[15:] = 0 fodf = np.dot(B_reg, fodf_sh) @@ -678,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, rcond=None)[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. @@ -1046,7 +1046,7 @@ def recursive_response(gtab, data, mask=None, sh_order=8, peak_thr=0.01, # 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], - rcond=None)[0] + rcond=-1)[0] response = r_sh_all / data.shape[0] res_obj = AxSymShResponse(data[:, gtab.b0s_mask].mean(), response)