Skip to content

Conversation

@allevitan
Copy link
Collaborator

@allevitan allevitan commented May 26, 2025

I'm starting some work to get a near-field ptychography model working. I thought about a few different ways to do it, and eventually I settled on the idea of making it just an option in fancy_ptycho. I think this has the main downside of making Fancy_ptycho more unwieldy, but it has many upsides:

  • It actually turned out to be quite easy to add, the only differences were adjusting the propagator, the pixel size calculation, and the initialization
  • All the same options (background, position refinement, etc) are immediately applicable
  • A lot of near-field and far-field ptycho is taken in situations where either model could be applicable, so there are genuinely many situations where one might want to simply test turning on the "near-field" switch.

The way that it works at present is that near-field can be turned on in the FancyPtycho.from_dataset() factory function by setting the near_field argument to True. In that case, the code will either set up:

(1) Genuine near-field propagation with a 2-step Fresnel propagator if "propagation_distance" is set to 0
(2) Fresnel-scaling-theorem propagation with a 2-step Fresnel propagator if "propagation_distance" is finite

This meshes with "propagation_distance" being the initial guess of the illumination's propagation distance from focus. Essentially, if one has a reconstruction working in Far-field with a moderate "propagation_distance" argument, there's a chance you can just try turning on near_field=True and the reconstruction will still work (even if far field is still the appropriate method).

Right now, I've tested the Fresnel-scaling theorem part on some internal datasets that I unfortunately can't share here.

Todos

  • Test Fresnel scaling theorem version internally, including oversampling
  • Test genuine near-field internally, including oversampling
  • Find test datasets for both cases that can be included in the CDTools repo (meeting size constraints and appropriately licensed)
  • Write example scripts for near field
  • Add test covereage for near-field mode

@allevitan allevitan changed the title Adding near field ptychography [WIP] Adding near field ptychography May 26, 2025
@allevitan
Copy link
Collaborator Author

I've now tested the near-field code on some near field data from a paper by Wenhui Xu. We are discussing the possibility of including this data in the repo and licensing it properly - if so, then I can add an example script using the data and that would leave only the test coverage

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