Skip to content

Commit 38891ff

Browse files
committed
ENH: making the svd tol matching MATLAB's tol
1 parent 1e171a3 commit 38891ff

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

nibabel/orientations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def io_orientation(affine, tol=None):
3737
threshold below which SVD values of the affine are considered zero. If
3838
`tol` is None, and ``S`` is an array with singular values for `affine`,
3939
and ``eps`` is the epsilon value for datatype of ``S``, then `tol` set to
40-
``S.max() * eps``.
40+
``S.max() * max(S.shape) * eps``.
4141
4242
Returns
4343
-------
@@ -62,7 +62,7 @@ def io_orientation(affine, tol=None):
6262
P, S, Qs = npl.svd(RS)
6363
# Threshold the singular values to determine the rank.
6464
if tol is None:
65-
tol = S.max() * np.finfo(S.dtype).eps
65+
tol = S.max() * max(S.shape) * np.finfo(S.dtype).eps
6666
keep = (S > tol)
6767
R = np.dot(P[:, keep], Qs[keep])
6868
# the matrix R is such that np.dot(R,R.T) is projection onto the

0 commit comments

Comments
 (0)