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

New year - new ptycho functionality #375

Merged
merged 92 commits into from
Feb 22, 2023
Merged

New year - new ptycho functionality #375

merged 92 commits into from
Feb 22, 2023

Conversation

gvarnavi
Copy link
Member

@gvarnavi gvarnavi commented Jan 11, 2023

Opening a draft PR on the remaining ptychography roadmap to move some of the discussion from slack (and also typeset some of the associated math).

Features already implemented:

  • Add projection-set type reconstruction algorithms
    A whole family of projection-set algorithms can be formulated using the exit wave view update scheme
    $$\psi^{j+1} = x \psi^j + a \hat{P}*\hat{O} + b \mathcal{F}_c \left[ c \hat{P} * \hat{O} + y \psi^j \right],$$
    such that $\hat{P} * \hat{O}$ and $\mathcal{F}_c$ are the overlap and Fourier projections respectively, and $x= 1-a-b$, and $y=1-c$.

          reconstruction_method='generalized-projection',
          reconstruction_parameter=(a,b,c),

    For convenience, we also implement common named projections:

    • Linear interpolation between difference-map (DM) and alternating-projection (AP) algorithms using (a,b,c)=(-α,1,1+α) where α, between 0-1, is used to smoothly interpolate between the AP (α=0) and DM (α=1) algorithms:
          reconstruction_method='DM_AP',
          reconstruction_parameter=α,
          reconstruction_method='RAAR',
          reconstruction_parameter=β,
          reconstruction_method='RRR',
          reconstruction_parameter=γ,
          reconstruction_method='SUPERFLIP',
  • Enable batch-updating of probes/objects

    • We implement batch-updating for the original gradient-descent algorithm which can be accessed using:
          reconstruction_method='GD',
          max_batch_size=n,
    • Note: batching is only supported for reconstruction_method='GD'.
  • Enable affine transformation position correction constraint

    • Updated position correction to respect max_batch_size and update positions using a least-squares fit to the measured/estimated intensity difference
    • In addition, added a new option to PtychographicReconstruction.reconstruct(), global_affine_transformation=True, which constraints the updated positions to be an affine transformation of the initial scan positions
  • Joint Electrostatic and Magnetic Vector Potential Reconstruction Ptychography

    ptycho_sim = py4DSTEM.process.phase.SimultaneousPtychographicReconstruction(
        (datacube_reverse,datacube_forward),
        simultaneous_measurements_mode='-+',
        ...
    )
    • Supports three main classes of experiments ('-+', '-0+', '0+', where -/+ refer to the sign of the magnetic vector potential and 0 is for the case where it's turned off)
    • Need to ensure reconstructions are quantitative
  • Multislice Ptychography

    ptycho_ms = py4DSTEM.process.phase.MultislicePtychographicReconstruction(
        datacube,
        num_slices=6,
        slice_thicknesses=slice_thicknesses,
        ...
    ) 
    • Switched normalization_min default to 1 for MultisliceReconstruction, since we don't sum the back-propagated probes
  • Mixed-State Ptychography

    ptycho_mix = py4DSTEM.process.phase.MixedStatePtychographicReconstruction(
        datacube,
        num_probes=2,
        ...
    )
    • Applicable for both projection-set and gradient-descent based algorithms, however the orthogonalize_probe functionality works best for a small max_batch_size, so it is recommended to run with reconstruction_method='GD'.
  • Butterworth Filtering in Fourier space

    • Note q_highpass accepts values in 'A^-1' and is-infact a low-pass filter
    • Need to add high-pass filtering too
  • Separate tuning function to run after PtychographicReconstruction.preprocess() and before PtychographicReconstruction.reconstruct() for coarser step-size/rotation tuning ?

    ptycho.tune_angle_and_defocus(
      
        num_angle_values=3,
        num_defocus_values=4,
        max_iter=5,
        plot_reconstructions=True,
        plot_convergence=True,
        return_values=False,
      
        # checking parameters get passed properly in reconstruct
        max_batch_size=256,
        progress_bar=False,
    )
    • Note this uses a new method which must exist in all reconstruction classes _visualize_last_iteration_figax
  • Make BFReconstruction consistent with other classes, add gpu-support

bf_recon = py4DSTEM.process.phase.BFReconstruction(
      datacube_cropped,
      energy= 300e3,
      verbose=True,
      device="gpu"
  ).preprocess(
      normalize_images=True,
      plot_average_bf=True,
      #defocus_guess=-500,
  )
  
bf_recon = bf_recon.reconstruct(
    reset=True,
    regularize_shifts=True,
    running_average=True,
    min_alignment_bin=1,
    plot_aligned_bf=True,
    )

bf_recon.aberration_correct(
    plot_corrected_bf=True,
)
  • Do a pass through docstrings and check notebooks all work

Features to be added before merging:

  • None?

@gvarnavi gvarnavi marked this pull request as ready for review February 17, 2023 06:20
@smribet
Copy link
Collaborator

smribet commented Feb 18, 2023

This notebook may be helpful for reviewing the PR
Phase_Contrast_PR-Checks.ipynb.zip

@bsavitzky bsavitzky merged commit f5e94a4 into dev Feb 22, 2023
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.

4 participants