Add forward model and fitting routine for rotation/magnification/defocus parameter extraction#10
Draft
Add forward model and fitting routine for rotation/magnification/defocus parameter extraction#10
Conversation
…give reasonable results.
…a dimension after vmap
…ration Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Co-authored-by: DavidLanders95 <6655619+DavidLanders95@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add forward model for image generation with Gaussian beam
Add forward model and fitting routine for rotation/magnification/defocus parameter extraction
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements forward model to generate synthetic TEM images and JAX-differentiable fitting routine to extract rotation, magnification, and defocus parameters from diffraction patterns.
Implementation
Forward Model (
forward_model_collins.py)Fitting Routine (
rotation_magnification_defocus_fitting.py)jax.scipy.ndimage.map_coordinates(bilinear interpolation)Results (5-sample validation)
Technical Notes
Initial nearest-neighbor resampling broke gradient flow in JAX. Switching to bilinear interpolation in
map_coordinatespreserves gradients for rotation and scaling transforms:Also includes Gaussian beam reference implementation (
rotation_magnification_defocus_forward.py) and debug utilities.Files
forward_model_collins.py- Forward model generator (356 lines)rotation_magnification_defocus_fitting.py- Fitting routine (436 lines)debug_fitting.py- Validation utilities (126 lines)ROTATION_MAGNIFICATION_DEFOCUS_README.md- Usage documentationIMPLEMENTATION_SUMMARY.md- Technical detailsforward_model_data/dataset.pkl- 50 synthetic images (6.3 MB)Original prompt
Created from VS Code.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.