-
-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Suppress "Bad Rotation Matrix" warnings #1697
Conversation
Example of occurrence: Progress | 0 | 0.01 | 0.0345 | 0.059 | 0.0835 | 0.108 | 0.1325 | 0.157 | 0.1815 | 0.206 | 0.2305 | 0.255WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581E7CA7F0): Bad Rotation Matrix 1.02555 -0.00607706 0.00711725 1.02636 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581E930950): Bad Rotation Matrix 1.0038 0.000658097 0.0181835 1.0196 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581E8193D0): Bad Rotation Matrix 1.01296 -0.000485504 0.00252202 0.99968 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581F07ABF0): Bad Rotation Matrix 1.00139 -0.0353489 0.014181 0.954691 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581E8F5140): Bad Rotation Matrix 0.94323 0.00672548 -0.0293821 1.00311 | 0.2795 | 0.304 | 0.3285 | 0.353 | 0.3775 | 0.402 | 0.4265 | 0.451 | 0.4755 | 0.5WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EC262E0): Bad Rotation Matrix 1.01756 -0.00261415 0.0241831 1.00784 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EC265A0): Bad Rotation Matrix 1.05521 -0.0124403 0.0215943 0.991163 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581F29B710): Bad Rotation Matrix 0.943761 -0.00148547 -0.0278611 1.00295 | 0.5245 | 0.549 | 0.5735 | 0.598 | 0.6225 | 0.647 | 0.6715 | 0.696 | 0.7205 | 0.745WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EF693A0): Bad Rotation Matrix 1.02405 -0.00516537 0.0336307 1.01107 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EF69BE0): Bad Rotation Matrix 1.04952 -0.0166267 0.00826341 0.983876 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EF69D40): Bad Rotation Matrix 0.946308 -0.0141908 -0.0155272 1.0036 | 0.7695 | 0.794 | 0.8185 | 0.843 | 0.8675 | 0.892 | 0.9165 | 0.941 | 0.9655 | 0.99WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EDCFCE0): Bad Rotation Matrix 1.02332 -0.0042626 0.0304406 1.01458 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EDD07E0): Bad Rotation Matrix 1.04445 -0.00741455 0.0214106 0.99242 WARNING: In C:\Dev\ANTsWasm\VS22py\_deps\ants_inner-src\ImageRegistration\itkANTSCenteredAffine2DTransform.hxx, line 138 ANTSCenteredAffine2DTransform (000002581EDD0680): Bad Rotation Matrix 0.955261 -0.0237769 -0.00559731 0.994758 | 1 Filter took 147.606 seconds.
Ping! |
It looks like it's not able to get a pure rotation matrix from the transform, which seems bad but I don't know for sure why this is happening. If you register the same data with |
I am using Faces example. The warning gets triggered by the original script too:
|
@ntustison @stnava do you know if these warnings are harmless? |
I dont know - are these matrices stored in |
These are intermediate affine matrices which are getting averaged during groupwise registration. |
Here's the function that produces the error ANTs/ImageRegistration/itkANTSCenteredAffine2DTransform.hxx Lines 96 to 140 in 0ec3fa5
It does a QR decomposition on the matrix but then uses R to get m_Angle, which looks backwards to me. Then it sets the full matrix and checks that matrix[1][0] == sin(m_Angle), but don't you need to do the QR decomposition again to extract the rotation? |
OH! ANTs/ImageRegistration/itkANTSCenteredAffine2DTransform.hxx Lines 106 to 107 in 0ec3fa5
OK now it all makes sense. So I think the answer is that the matrix is correct, but the check for "bad rotation" is not, because it's checking the full affine transform directly and not just the rotation part. |
Feel free to take over this PR if you have an improvement! |
Sure, I will change it to do the sanity check by redoing the decomposition, but only if in debug mode. |
Will merge shortly. I re-ran the template example and don't see the warning now, even in debug mode. The rotations look correct, the warning was being triggered by a test on the composed affine transform, not the rotation component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
This warning show up a lot for me (e.g. from here). Should I be concerned?
Example of occurrence:
Should we try to retain these warnings in command-line tools?