05. Pad Vacuum

05. Pad Vacuum#

Description of this walkthrough goes here.

 1# Created with PtyRAD 0.1.0b13
 2# Documentation: https://ptyrad.readthedocs.io/en/latest/
 3# Detailed description for each option: https://ptyrad.readthedocs.io/en/latest/_autosummary/ptyrad.params.html
 4
 5# Pad vacuum layers to previous reconstructions and resume reconstructions
 6
 7# tBL_WSe2
 8
 9init_params:
10    # Experimental params
11    probe_kv               : 80 # [kV] Acceleration voltage
12    probe_conv_angle       : 24.9 # [mrad] Semi-convergence angle for probe-forming aperture
13    probe_aberrations      : {'C10': 0} # [Angstrom, degree] Aberration coefficients in Krivanel polar notations. C10 = -df, and positive C10 refers to overfocus (stronger lens).  
14    meas_Npix              : 128 # Detector pixel number, EMPAD is 128. Only supports square detector for simplicity
15    pos_N_scan_slow        : 128 # Number of scan position along slow scan direction. Usually it's the vertical direction of acquisition GUI
16    pos_N_scan_fast        : 128 # Number of scan position along fast scan direction. Usually it's the horizontal direction of acquisition GUI
17    pos_scan_step_size     : 0.4290 # [Angstrom] Step size between probe positions in a rectangular raster scan pattern
18    # Model complexity
19    probe_pmode_max        : 6 # Maximum number of mixed probe modes
20    obj_Nlayer             : 6 # Number of slices for multislice object
21    obj_slice_thickness    : 2 # [Angstrom] Slice thickness (propagation distance) for multislice ptychography. Typical values are between 1 to 20 Ang.
22    # Preprocessing
23    meas_permute           : null # Permute meas array with a list of ints to reorder datasets into (N_scans, ky, kx) if needed.
24    meas_reshape           : null # Reshape meas array with a list of 3 ints to convert the 4D diffraction dataset (Ry,Rx,ky,kx) into 3D (N_scans,ky,kx) for PtyRAD.
25    meas_flipT             : [1,0,0] # Flip meas orientation with a list of 3 binary booleans (0 or 1) as [flipud, fliplr, transpose]
26    pos_scan_affine        : null # Affine transformation [scale, asymmetry, rotation, shear] of scan patterns. e.g, [1,0,3,0], rotation and shear are in unit of degree.
27    
28    ## NOTE: You can pad more layers to the loaded object along depth, and padding vacuum is the most common usage.
29    ##       You can change 'pad_layers' to achieve asymmetric padding to better center your object,
30    ##       or use 'pad_types' to pad 'vacuum', 'edge', or 'mean' layers. Padding 'mean' layer can be used to quickly explore total thickness.
31    ##       obj_z_pad often requires to use with probe_z_shift so the relative axial alignment of probe and object is conserved.
32    ##       Because the probe array interacts with the entrance plane of the object, and padding ON TOP changes that entrace plane.
33    ##       For example, if you pad 20 Ang of vacuum ON TOP of the current object, you'll need to apply probe_z_shift: -20 Ang.
34    ##       This rewinds the probe backward by 20 Ang, so when the probe passes through the 20 Ang vacuum padded on top of the current object,
35    ##       it will remain the same level of defocus while interacting with the object.
36    obj_z_pad              : {'pad_layers': [2,2], 'pad_types': ['vacuum', 'vacuum']} # Pad the 4D object (omode, Nz, Ny, Nx) along depth dimension (Nz) and expands the object thickness.
37    probe_z_shift          : -20 # Shifts the initialized probe axially along the depth (z) dimension. Positive value means to propagate the probe further into the object (i.e., forward direction).
38
39    # Input source and params
40    meas_params            : {'path': 'data/tBL_WSe2/Panel_g-h_Themis/scan_x128_y128.raw', 'key': null} # Supports EMPAD .raw, .hdf5, .mat, and .tif
41    probe_source           : 'PtyRAD' # Data source of the probe. Currently supporting 'simu', 'PtyRAD', 'PtyShv', 'py4DSTEM', and 'custom'
42    probe_params           : 'output/walkthrough/01_multi_slice/full_N16384_dp128_flipT100_random32_p6_1obj_6slice_dz2_orblur0.4_ozblur1.0/model_iter0200.hdf5' # Provide a str path of 'path/to/reconstruction_model.hdf5'
43    pos_source             : 'PtyRAD' # Data source of the probe positions. Currently supporting 'simu', 'PtyRAD', 'PtyShv', 'py4DSTEM', 'foldslice_hdf5', and 'custom'
44    pos_params             : 'output/walkthrough/01_multi_slice/full_N16384_dp128_flipT100_random32_p6_1obj_6slice_dz2_orblur0.4_ozblur1.0/model_iter0200.hdf5' # Provide a str path of 'path/to/reconstruction_model.hdf5'
45    obj_source             : 'PtyRAD' # Data source of the object. Currently supporting 'simu', 'PtyRAD', 'PtyShv', 'py4DSTEM', and 'custom'
46    obj_params             : 'output/walkthrough/01_multi_slice/full_N16384_dp128_flipT100_random32_p6_1obj_6slice_dz2_orblur0.4_ozblur1.0/model_iter0200.hdf5' # Provide a str path of 'path/to/reconstruction_model.hdf5'
47
48loss_params:
49    loss_single: {'state': true, 'weight': 1.0, 'dp_pow': 0.5} # Amplitude noise model for typical dataset (dose-sufficient) under the maximum-likelihood formalism
50    loss_sparse: {'state': true, 'weight': 0.1, 'ln_order': 1} # L_n norm sparsity regularization calculated for object phase ('objp')
51
52constraint_params:
53    obj_zblur     : {'start_iter': 1,    'step': 1, 'end_iter': null, 'obj_type': 'both', 'kernel_size': 5, 'std': 1} # Apply a "z-direction" 1D Gaussian blur to the object.
54    
55    ## NOTE: After padding vacuum, it's also suggested to turn on obj_z_recenter constraint to make sure the object remains centered along depth.
56    ##       Because the object depth location is coupled with probe defocus, so if the probe defocus is constantly changing, the object would also move along depth.
57    ##       This constraint will keep the object 1D-center-of-mass along depth to be centered, and adjust the probe defocus accordingly.
58    obj_z_recenter: {'start_iter': 1,    'step': 1, 'end_iter': null, 'thresh': 95, 'scale': 0.5, 'max_shift': 1} # Apply the z-recentering of object based on CoM to keep the object centered within the depth dimension.
59    
60    objp_postiv   : {'start_iter': 1,    'step': 1, 'end_iter': null, 'relax': 0} # Apply a positivity constraint of the object phase by clipping negative values
61
62recon_params:
63    NITER: 200 # Total number of reconstruction iterations. 1 iteration means a full pass of all selected diffraction patterns.
64    BATCH_SIZE: {'size': 32, 'grad_accumulation': 1} # Number of diffraction patterns processed simultaneously to get the gradient update.
65    SAVE_ITERS: 10 # Number of completed iterations before saving the current reconstruction results (model, probe, object) and summary figures.
66    output_dir: 'output/walkthrough/05_pad_vacuum/'
67    recon_dir_affixes: ['minimal', 'constraint', 'loss'] # Customizable affixes of reconstruction folder name with presets like 'minimal', 'default', 'all'. See docs for 19 more detailed controls.
68    prefix_time: false # type: boolean, preset strings, and time format strings. Set to true to prepend a date str like '20240903_' in front of the reconstruction folder name
69    prefix: '' # Prefix this string to the reconstruction folder name. Note that a "_" will be automatically generated.
70    postfix: '' # Postfix this string to the reconstruction folder name. Note that a "_" will be automatically generated.