|
26 | 26 | IFLOGGER = logging.getLogger('nipype.interface')
|
27 | 27 |
|
28 | 28 |
|
| 29 | +def fallback_svd(a, full_matrices=True, compute_uv=True): |
| 30 | + try: |
| 31 | + return np.linalg.svd(a, full_matrices=full_matrices, compute_uv=compute_uv) |
| 32 | + except np.linalg.LinAlgError: |
| 33 | + pass |
| 34 | + |
| 35 | + from scipy.linalg import svd |
| 36 | + return svd(a, full_matrices=full_matrices, compute_uv=compute_uv, lapack_driver='gesvd') |
| 37 | + |
| 38 | + |
29 | 39 | class ComputeDVARSInputSpec(BaseInterfaceInputSpec):
|
30 | 40 | in_file = File(
|
31 | 41 | exists=True, mandatory=True, desc='functional data, after HMC')
|
@@ -1191,7 +1201,7 @@ def compute_noise_components(imgseries, mask_images, num_components,
|
1191 | 1201 | # "The covariance matrix C = MMT was constructed and decomposed into its
|
1192 | 1202 | # principal components using a singular value decomposition."
|
1193 | 1203 | try:
|
1194 |
| - u, _, _ = np.linalg.svd(M, full_matrices=False) |
| 1204 | + u, _, _ = fallback_svd(M, full_matrices=False) |
1195 | 1205 | except np.linalg.LinAlgError:
|
1196 | 1206 | if self.inputs.failure_mode == 'error':
|
1197 | 1207 | raise
|
@@ -1273,7 +1283,7 @@ def _full_rank(X, cmax=1e15):
|
1273 | 1283 | X: array of shape(nrows, ncols) after regularization
|
1274 | 1284 | cmax=1.e-15, float tolerance for condition number
|
1275 | 1285 | """
|
1276 |
| - U, s, V = np.linalg.svd(X, 0) |
| 1286 | + U, s, V = fallback_svd(X, full_matrices=False) |
1277 | 1287 | smax, smin = s.max(), s.min()
|
1278 | 1288 | c = smax / smin
|
1279 | 1289 | if c < cmax:
|
|
0 commit comments