py4dstem / py4DSTEM

GNU General Public License v3.0
199 stars 135 forks source link

Ptychography gridding pattern #644

Closed erh3cq closed 4 months ago

erh3cq commented 5 months ago

Problem: Ptychography reconstruction on Dectris (and other hybrid detectors with segments) is creating a 'gridding pattern' upon reconstruction. The grid can be seen in real and reciprocal space, but is most obvious in reciprocal space. qbin2ptycho_-_reconstruction_obj_phase_720 qbin2ptycho_-_reconstruction_fft_720

Trouble shooting:

  1. The periodicity matches the probe step size. I have run acquisitions with various combinations of max outer angle, binning, and probe step size. qbin2ptycho_-_reconstruction_fft_720 ptycho_-_reconstruction_fft_720
  2. @smribet rean Bayesian Optimization of position, aberrations, and mixed state. This helped to some minor degree but the issue is still prominent. 240223_eric_object_fft_360
  3. I ran the "ptycho01_gold_on_carbon.ipynb" file then ran it again with simulated boarder pixels by averaging (e.g. each boarder pixel is a 2x1 pixel that is then assigned to two 1x1 pixels with each having the same intensity). The artifact did not appear. This would suggest it is not Figure 48 the averaging of the boarder pixels that creates the issue. Figure 49

Expected behavior: artifact free reconstruction

Things to try @cophus suggested a series of filter that @smribet or @gvarnavi could implement

py4DSTEM version 0.14.9 (from github phase) Python version 3.12.1 Operating system Windows

tcpekin commented 5 months ago

I saw extremely similar grid artifacts using a Dectris when either the pixel or step size was incorrect. The mitigation by updating probes and probe position kind of also hints at that... Idk could just be a me problem, but I am haunted by grid patterns that look like that 😂

gvarnavi commented 5 months ago

Thanks for the report @erh3cq! I've been sitting on a tutorial notebook which investigates gridding-artifacts for the past couple of weeks, and haven't found time to finalize/post it. Attaching it here in the meantime, you can find the necessary data files here.

iterative-ptychography_02.zip

Unfortunately, gridding is a pathological artifact in "blind" ptychography (i.e. where one tries to solve for the probe and the object simultaneously). This is well-known in the X-Ray ptychography literature, and in-fact why they have switched away from raster-scans and instead opt for spiral scans.

That being said, the notebook investigates regimes where this is more/less pronounced - and possible remedies. I summarize them here briefly with this figure, but do have a look at the notebook:

gridding-experiments

Finally, you mention implementing a filter for this. Indeed - the gridding artifacts are predictable, and we can easily add a Fourier filter which zeros-out those pixels. You get what you ask for with Fourier-filtering, so indeed this can reduce/remove gridding but our tests have shown the reconstructions to be fairly sub-optimal in other ways.

gvarnavi commented 5 months ago

To clarify, and connect with @tcpekin comment above:

I saw extremely similar grid artifacts using a Dectris when either the pixel or step size was incorrect

Gridding is a pathological artifact due to the translation periodicity ambiguity introduced by raster scan patterns, and can be exacerbated by ANY kind of model-mismatch. The notebook above investigates the probe aperture and cropping box mismatch, but indeed calibration mismatch (including pixel-sizes and rotation) also result in gridding..

gvarnavi commented 4 months ago

Closing this issue, now that the tutorials have been updated to include gridding-artifacts.