Skip to content
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

Projection from 2D -> 1D for common lines #67

Merged
merged 13 commits into from
Feb 29, 2024

Conversation

McHaillet
Copy link
Member

@McHaillet McHaillet commented Feb 28, 2024

@alisterburt I started some work on a PR for the 2D -> 1D projection. I copied and adapted the code your wrote for the real space 3D->2D projection to create an equivalent function. It would be nice if you could give some feedback on that code and where to place it. I now added it to project_real but some other libraries seems to have separate files for 3d/2d, should that be the case for this as well?

The same still needs to be done for Fourier space 2D->1D but that seems more complicated as besides functions in project_fourier, it also requires a sample_dft_2d in interpolation.

I updated the coarse alignment example as well to test if the proper tilt-axis angle could be optimised based on common lines. Seems to work quite nicely! I start with an angle that is way off (-30, while the actual angle is -88.7), and it finds the correct angle back. Importantly, I need to run it on the raw tilt-series. If I first apply the xcorr shifts, the tilt-axis is quite off (-100).

This is a PR that closes #65 (partly).

Copy link
Member

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@McHaillet once again, so so psyched to see this!!

I've left a few minor comments but very happy to merge this once those are addressed

@@ -1,2 +1,2 @@
from .project_fourier import project_fourier
from .project_real import project_real
from .project_real import project_real_3d, project_real_2d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something about this doesn't feel 100% clear - how about project_volume and project_image? 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it now to project_volume_real and project_image_real to not mess with potential variants from project_fourier. Let me know if you agree.

src/libtilt/projection/project_real.py Outdated Show resolved Hide resolved
src/libtilt/projection/project_real.py Outdated Show resolved Hide resolved
src/libtilt/projection/project_real.py Outdated Show resolved Hide resolved
examples/coarse_alignment.py Outdated Show resolved Hide resolved
@alisterburt
Copy link
Member

The same still needs to be done for Fourier space 2D->1D but that seems more complicated as besides functions in project_fourier, it also requires a sample_dft_2d in interpolation.

Good point! I can add this

@McHaillet
Copy link
Member Author

I managed to make the optimization work on the coarse aligned tilt-series. Some images here of the 2D -> 1D projections after optimizing the tilt-axis angle. (each row is a projected tilt image)

Firstly this was the set of lines when optimizing on the 'raw' tilt-series:
optimized_common_lines_no_alignment

These were the lines when optimizing on the aligned tilt-series:
optimized_common_lines_with_alignment

On these I noticed that the right and left sides get some artifacts which come from the fact that the tilt image is masked before projecting. The line is then normalized to mean0std1, which creates artifacts from the mask.

After some experimenting, I thought to do a 2D->1D projection of the mask to correctly weight the information in the lines. This manages to make the axis angle optimization work also after applying the shifts 😄

optimized_lines_mask_weights

About the wrap-around thing, it seems to work here now. But still likely that it can cause some issues.

@McHaillet McHaillet marked this pull request as ready for review February 29, 2024 10:00
Copy link
Member

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're a wizard, those common line images are gorgeous 😍 great example of why vis is so important!

I had another thought when rereading the code - the 'grid' with one grid point is useful only if we might later want to increase the resolution to model the tilt axis varying over time... otherwise a bare torch parameter would look more normal

Amazing work once again! Let's merge and iterate here ☺️

@alisterburt alisterburt merged commit 5d45d72 into teamtomo:main Feb 29, 2024
@McHaillet
Copy link
Member Author

Thanks!!

I had another thought when rereading the code - the 'grid' with one grid point is useful only if we might later want to increase the resolution to model the tilt axis varying over time... otherwise a bare torch parameter would look more normal

I left it because I tried optimizing with multiple grid points that vary with tilt angle, which is described in the AreTomo paper. Although in my experience running AreTomo it only ever optimizes a single tilt-axis (in-plane rotation). But I agree, varying over time could make sense!

@McHaillet McHaillet deleted the project_2d branch March 1, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2D to 1D projection for common lines
2 participants