Open geoffwoollard opened 1 year ago
Some thoughts on implementation:
equinox.internal
submodule. The while loop in core JAX only supports forward-mode autodiff.AbstractPotentialIntegrator
, which takes in an abstract interface for an atomistic representation of a potential (which does not yet exist!). cryojax
imaging pipeline. Right now, we go from 3D potential -> phase shifts -> squared wavefunction but we will need to support potential -> wavefunction -> squared wavefunction. I expect this generalization will involve work in the Instrument
and AbstractSpecimen
, and creating a new AbstractOptics
model for a complex-exponential CTF. Should be a good opportunity to improve upon the code.Re 2, I drafted some mulislice code that slices through a discretized potential, and produces the exit wave.
It takes in the potential, slice thickness, and beam wavelength (lambda), and produces the exit wave.
Can you draft something that I can put the core multislice code into?
Starting to implement handling passing an exit wave through the imaging pipeline. A few comments
One issue in this is that the ImageConfig
needs to store a full frequency plane, rather than the half plane needed for the fourier transform of a real-valued function. For now, we’ve just computed more frequency coordinate systems upon ImageConfig.__init__
, but this is too cumbersome I think.
Instead, I wonder if all coordinate systems in pixels can be computed at run-time and stored in the ImageConfig
as python properties (using @property
or @cached_property
). I bet XLA will know to compute the meshes only once.
Okay also, it would be good to have a way that the user can externally check if a particular integrator returns an exit wave or a phase contrast. This can either be done through a ClassVar, or by making abstract interfaces that subclass AbstractPotentialIntegrator. Perhaps names like AbstractMultiSliceIntegrator and AbstractProjectionApproximation would be appropriate.
The current treatment of the solvent
won’t be compatible with passing an exit wave through the pipeline, since the solvent model just randomly samples a phase contrast field. We may need to generalize this to turn the phase contrast into an exit wave, or just add a run-time error that deems them incompatible. In general, the solvent model needs work. Also, the AssemblyPipeline
relies on linearity and is fundamentally incompatible with multislice, so this will need a run-time error.
FYI the multislice treatment (for material science applications, including using density functional theory for the potential) in https://abtem.readthedocs.io/en/latest/intro.html follows Eq 6 in Vulović, M., Ravelli, R. B. G., van Vliet, L. J., Koster, A. J., Lazić, I., Lücken, U., … Rieger, B. (2013). Image formation modeling in cryo-electron microscopy. Journal of Structural Biology, 183(1), 19–32. http://doi.org/10.1016/j.jsb.2013.05.008
Added an initial commit in the multislice-updated
branch
Recent TODOs
Translations should be taken care of!
This package may be great for implementing this: https://github.com/patrick-kidger/diffrax