Projectional Engines#
Learning more about projectional engines/algorithms such as the popular difference map algorithm.
In PtyPy we have implemented a generalised version of the difference map algorithm with the following update for the exit wave
where alpha
parameter accordingly
p.engines.engine00 = u.Param()
p.engines.engine00.name = "DM"
p.engines.engine00.numiter = 80
p.engines.engine00.alpha = 0.95
The Fourier update#
During the Fourier update
where
with fourier_power_bound
engine parameter. For Poisson-sampled data, the theoretical value for this power bound parameter is
p.engines.engine00.fourier_power_bound = 0.25
but it often makes sense to lower or higher this power bound parameter based on the experimental conditions. If the power bound is too low, it might lead to over-fitting. If the power bound is too high, the Fourier update would no longer be enforced.
The overlap update#
During the Overlap update
where
for all views overlap_max_iterations
or if the root mean square difference between the current and previous estimate of the probe is smaller than overlap_converge_factor
. Additionally, the behaviour of the overlap update can be controlled by delaying the first update of the probe using probe_update_first
or by swapping the order of the object and probe update using update_object_first
which is True
by default.
p.engines.engine00.overlap_converge_factor = 0.05
p.engines.engine00.overlap_max_iterations = 10
p.engines.engine00.update_object_first = True
p.engines.engine00.probe_update_start = 2
Challenge
Modify different DM engine parameters and observe their impact on the outcome of the reconstruction.
import ptypy
import ptypy.utils as u
p = u.Param()
p.verbose_level = "interactive"
p.io = u.Param()
p.io.rfile = None
p.io.autosave = u.Param(active=False)
p.io.interaction = u.Param(active=False)
# Live-plotting
p.io.autoplot = u.Param()
p.io.autoplot.active=True
p.io.autoplot.threaded = False
p.io.autoplot.layout = "jupyter"
p.io.autoplot.interval = 10
p.scans = u.Param()
p.scans.MF = u.Param()
p.scans.MF.name = "Full"
p.scans.MF.data= u.Param()
p.scans.MF.data.name = "MoonFlowerScan"
p.scans.MF.data.shape = 128
p.scans.MF.data.num_frames = 200
p.scans.MF.data.save = None
p.scans.MF.data.density = 0.2
p.scans.MF.data.photons = 1e8
p.scans.MF.data.psf = 0.
# Define reconstruction engines
p.engines = u.Param()
# Difference Map (DM) engine
p.engines.engine00 = u.Param()
p.engines.engine00.name = "DM"
p.engines.engine00.numiter = 80
# General update
p.engines.engine00.alpha = 0.95
# Fourier update
p.engines.engine00.fourier_power_bound = 0.25
# Overlap update
p.engines.engine00.overlap_converge_factor = 0.05
p.engines.engine00.overlap_max_iterations = 10
p.engines.engine00.update_object_first = True
p.engines.engine00.probe_update_start = 2
P = ptypy.core.Ptycho(p,level=5)