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

use zx-slice reconstruction method for lower memory footprint #21

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

McHaillet
Copy link
Member

@McHaillet McHaillet commented Nov 20, 2024

(Turns out to be much faster as well. Might be because I'm doing the backward and forward projection of the slice in one go now.)

@alisterburt could I get your opinion on this one?
I update projection matching to only reconstruct each xz-slice and immediately project it down to the next tilt angle. The intermediate tomograms is never explicitly reconstructed. It reduces memory requirements a ton and is also a lot faster (~70 sec. -> ~10 sec. per cycle in the example).

However, the downside is that you cannot account for X_rotations in the reconstruction, which I though could be cool at some point to perfectly flatten samples in the reconstruction.

What do you think? Is the memory/speed worth handing in some generality of the projection model?

@alisterburt
Copy link
Member

alisterburt commented Nov 20, 2024

@McHaillet very cool that you're pushing in this direction!! Thanks for the ping - I've taken a quick look but it's early and I am not sure I've fully understood, can you sanity check me?

  • you can now predict projections from the tilt-series directly rather than creating intermediate 3D reconstructions
  • your implementation does this by generating xz slices then projecting those
  • xz slices in the "reconstruction" (which is never made) each come from one row of data in the tilt series (like the IMOD program tilt), giving you speed ups
  • a consequence of the xz slice implementation is a more limited projection geometry

Am I right? If so, I think the limited projection geometry is a limitation of the implementation rather than the method itself and it's probably worth generalising...

If you know where all the tilt series data ends up in Fourier space after a Fourier space reconstruction and you know where you want to sample that Fourier space reconstruction to make projections you can directly sample from the 2D FFTs to make your projections. Does this feel clear? It should mean you can achieve similar speed ups without loss of generality of the projection model (which feels important)

As an aside, I was first introduced to this idea by @thomasfrosio who has worked on tilt series alignment during a PhD with Peijun Zhang, he might be able to provide useful thoughts/some implementation tips!

@McHaillet
Copy link
Member Author

Thanks for thinking along! I think my phrasing was bit poor, just to be clear: the full tomogram is not explicitly reconstructed, but each xz-slice is before it is immediately forward project. Exactly like IMOD you then just iterate over the y-axis. It definitely has a lower memory footprint. It is faster here because all the grids can be precalculated, making the calculation per loop iteration very low.

Am I right? If so, I think the limited projection geometry is a limitation of the implementation rather than the method itself and it's probably worth generalising...

Yes, seems like you understood! It is a limitation of the implementation because you need to assume the tilt-axis exactly aligns with the y-axis.

If you know where all the tilt series data ends up in Fourier space after a Fourier space reconstruction and you know where you want to sample that Fourier space reconstruction to make projections you can directly sample from the 2D FFTs to make your projections. Does this feel clear? It should mean you can achieve similar speed ups without loss of generality of the projection model (which feels important)

I get what you are saying and that sounds like a great implementation. I had some problems with the Fourier based reconstruction and projection before because you need to reconstruct a square box. The real space implementation just reconstructs a slab which actually serves as a mask for the region of interest of the tomograms, hence the alignz parameter is so important in AreTomo. Perhaps we should reconstruct smaller patches with box sizes corresponding to the assumed sample thickness, then we could make that work.

@thomasfrosio would love to hear your input but let me know if you need more clarification!

@McHaillet
Copy link
Member Author

I was thinking more about the discussion we had about this. In general doing the back- and forward- projection purely in Fourier space by interpolating which point from each slice end up in the forward projection is a great idea.

The masking we discussed would be very tricky I think. Multiplying with a 3D mask in real space (essentially a limited z-height reconstruction), would mean a convolution in 3D Fourier space. I don't think that can be easily integrated in this method. Probably, most logical to use patching/tiling in that case.

(This PR can probably be closed though.)

@alisterburt
Copy link
Member

@McHaillet you're right that it's a convolution but its only in 1d so is very efficient :-)

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.

2 participants