Moving-Least-Squares icon indicating copy to clipboard operation
Moving-Least-Squares copied to clipboard

When pTwp is not invertible in affine deformation

Open darongliu opened this issue 3 years ago • 1 comments

Hi, I am a little confused about the code dealing with the situation when pTwp is not invertible in affine deformation (line94 in img_utils.py). If I’m not mistaken, code directly set M to be an identity matrix (according to line 129, 130) when the determinant is close to zero. I supposed this kind of issue should be done by pseudo-inverse. This discussion in stackoverflow should help: https://stackoverflow.com/questions/49357417/why-is-numpy-linalg-pinv-preferred-over-numpy-linalg-inv-for-creating-invers

Thanks for the implementation.

darongliu avatar Jan 18 '22 09:01 darongliu

Besides, I think the calculation of the adjoint matrix (line 99) is also wrong. It should be adjoint = pTwp[[[1, 1], [0, 1]], [[1, 0], [0, 0]], :, :] .

darongliu avatar Jan 18 '22 09:01 darongliu