-
Notifications
You must be signed in to change notification settings - Fork 26
Angs #1172
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
Angs #1172
Conversation
271e834 to
317bf53
Compare
|
These changes are the minimal set that allow me to reproduce the initial rotations estimate from the published MATLAB common line sync 3n algorithm (up to transposing the image data). For the amount of effort to get there, its not much code to look at :D. I have put in branches/options with different defaults to allow the other python common lines implementations to continue functioning as they were. I was able to salvage using the ZYZ convention so we don't need to worry about that ATM. yay 🥳 . |
j-c-c
left a comment
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 great! Can't believe it only took ~100 lines.
Just one small docstring thing. Also, looks like CI failed. Is that from flakiness or is something wrong there?
|
To be clear, this is just to fix the voting procedure angle outputs. Gonna go on a limb and guess the rest of the CL algorithm(s) in the current code base are also not reproducing MATLAB.... one piece at a time... Saw that unit test fail for first time last night. Not sure about that yet. Because it is almost exactly 90* off, im wondering if it relates to the synchronization and convention I tried to put back. I got out of using the old rotation convention/conversion because the sync condition was "fixing" the cases that were different into the domain that is equivalent (but maybe the sync check it isn't working quite right numerically on that one platform). I'll try to look into that more. |
|
Yeah, I'm not really sure what is going on with the test. I can reproduce the failure locally. Its almost like the remaining common lines code doesn't work with the correct initial rotation estimates. |
Oof, apparently the upstream code doesn't like the patch that returns actual rotation matrices. Reverting allows the test to pass. I figured there was more to do here, but was hoping I wouldn't need to do in this PR. Note the direct averaging of rotation matrices is used by every other CL algo we have in Python... |
315877b to
73c245e
Compare
|
Okay, had to dig in more and found an additional issue with During this effort, I confirmed for a small (unit test size of 41px) problem that this code can now reproduce MATLAB sync 3N's output rotations up to global reflections when given an identical common lines matrix. This was done for cases S0J0 S1J0 S0J1 S1J1 corresponding to S_weighting and J_weighting. I will be moving onto the next problem size, 80s at 89px. Afterwards I will put this up for review consideration again. |
|
|
new changes (nearest_rotation) seems to resolve unit test
|
@j-c-c , can you take another look at this before I send it to Joakim, thanks! |
Sure! |
j-c-c
left a comment
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 great!
janden
left a comment
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 great! Just one thing.
src/aspire/utils/matrix.py
Outdated
| Uses the SVD method to compute the set of nearest rotations to the set A of noisy rotations. | ||
| :param A: A 2D array or a 3D array where the first axis is the stack axis. | ||
| :param allow_reflection: Optionally correct reflections. |
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.
Other way around, no? (Setting the option does not correct reflections.)
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.
Setting the option to True allows reflections.
I'll add disable to the docstring to better indicate the default; which I think is what you meant by setting.
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.
Thank you!
Stashing debug work.
So far I have found two errors in the initial estimating rotations method preventing us from achieving the results from MATLAB. First we should be taking the average of 1d (alpha) angles, not the rotation matrices. Second, the euler to rotation conversion in our current python code is not equivalent to the one in MATLAB (and originally ported by Junchao).
I saved the alpha angles from MATLAB for all i,j image pairs. Following #1171 we can make an equivalent CL mat. Following above we can take the alpha MATLAB angles and generate the same rotations.
There is a small (1.5*) discrepancy between the alpha angles computed in Python and those in MATLAB. This is coincidentally the value I would expect in this particular problem if we had an 'off by one bin' error. (Not sure, just thinking atm).
I will continue working this, hopefully resulting in MATLAB parity up to initial rotation estimates for one of the JSB problems.