Skip to content

Commit

Permalink
Changed ().I for np.linalg.pinv to address Singular mat error
Browse files Browse the repository at this point in the history
  • Loading branch information
jcohenadad committed Jun 24, 2020
1 parent 111289a commit a456fa5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions spinalcordtoolbox/centerline/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ def reconstructGlobalApproximation(self, P_x, P_y, P_z, p, n, w):
Tz.append(somme)
Tz = np.matrix(Tz)

P_xb = (R.T * W * R).I * Tx.T
P_yb = (R.T * W * R).I * Ty.T
P_zb = (R.T * W * R).I * Tz.T
P_xb = np.linalg.pinv(R.T * W * R) * Tx.T
P_yb = np.linalg.pinv(R.T * W * R) * Ty.T
P_zb = np.linalg.pinv(R.T * W * R) * Tz.T

# Modification of first and last control points
P_xb[0], P_yb[0], P_zb[0] = P_x[0], P_y[0], P_z[0]
Expand Down
2 changes: 1 addition & 1 deletion unit_testing/test_centerline.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from sct_utils import init_sct

init_sct(log_level=2) # Set logger in debug mode
VERBOSE = 2 # Set to 2 to save images, 0 otherwise
VERBOSE = 0 # Set to 2 to save images, 0 otherwise


# Generate a list of fake centerlines: (dummy_segmentation(params), dict of expected results)
Expand Down

0 comments on commit a456fa5

Please sign in to comment.