08. Resample DP#
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# Resample the loaded 4D-dataset during initialization
6
7# PSO
8
9init_params:
10 # Experimental params
11 probe_kv : 300 # [kV] Acceleration voltage
12 probe_conv_angle : 21.4 # [mrad] Semi-convergence angle for probe-forming aperture
13 probe_aberrations : {'C10': 200} # [Angstrom, degree] Aberration coefficients in Krivanel polar notations. C10 = -df, and positive C10 refers to overfocus (stronger lens).
14 meas_Npix : 256 # Detector pixel number, EMPAD is 128. Only supports square detector for simplicity
15 pos_N_scan_slow : 64 # Number of scan position along slow scan direction. Usually it's the vertical direction of acquisition GUI
16 pos_N_scan_fast : 64 # Number of scan position along fast scan direction. Usually it's the horizontal direction of acquisition GUI
17 pos_scan_step_size : 0.410 # [Angstrom] Step size between probe positions in a rectangular raster scan pattern
18 # Model complexity
19 probe_pmode_max : 4 # Maximum number of mixed probe modes
20 obj_Nlayer : 21 # Number of slices for multislice object
21 obj_slice_thickness : 10 # [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 : null # Flip meas orientation with a list of 3 binary booleans (0 or 1) as [flipud, fliplr, transpose]
26 meas_crop : [null,null,[68,188],[68,188]] # Crops the 4D dataset with [[scan_slow_start, scan_slow_end], [scan_fast_start, scan_fast_end], [ky_start, ky_end], [kx_start, kx_end]].
27 meas_pad : {'mode': 'on_the_fly', 'padding_type': 'power', 'target_Npix': 128, 'value': 0, 'threshold': 70} # Pads the diffraction pattern to side length = 'target_Npix' and correspondingly change the kMax, dx, Npix.
28
29 ## NOTE: Resampling diffraction pattern does NOT affect kMax, so the real-space px size (dx) remains the same.
30 ## Therefore, the most prominent benefit of resampling diffraction pattern is to upsample the pattern to increase Npix,
31 ## such that the probe array can have a larger room for the probe to extend its tails.
32 ## This is critically important for thick samples, large overfocus, and high convergence angles.
33 ## Because the probe intensity can spread very wide and get close to the edge of the array boundary,
34 ## which will lead to probe artifacts due to the periodic boundary constraint of FFT.
35 ## For this specific example, we first crop the diffraction pattern from 256 to 124 to remove the zero-padded region,
36 ## then pad it to 128, and then upsample it to 256.
37 ## Like other examples, PtyRAD automatically handles the sequential change of kMax (dx) and Npix, so no need to manually modify the above experimental parameters.
38 meas_resample : {'mode': 'on_the_fly', 'scale_factors': [2,2]} # Resamples the diffraction pattern along ky and kx directions.
39
40 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.
41 # Input source and params
42 meas_params : {'path': 'data/PSO/sample_data_PrScO3.mat', 'key': 'dp'} # Supports EMPAD .raw, .hdf5, .mat, and .tif
43
44constraint_params:
45 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.
46
47recon_params:
48 NITER: 200 # Total number of reconstruction iterations. 1 iteration means a full pass of all selected diffraction patterns.
49 BATCH_SIZE: {'size': 32, 'grad_accumulation': 1} # Number of diffraction patterns processed simultaneously to get the gradient update.
50 SAVE_ITERS: 10 # Number of completed iterations before saving the current reconstruction results (model, probe, object) and summary figures.
51 output_dir: 'output/walkthrough/08_resample_DP/'
52 recon_dir_affixes: ['minimal', 'constraint'] # Customizable affixes of reconstruction folder name with presets like 'minimal', 'default', 'all'. See docs for 19 more detailed controls.
53 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
54 prefix: '' # Prefix this string to the reconstruction folder name. Note that a "_" will be automatically generated.
55 postfix: 'up2' # Postfix this string to the reconstruction folder name. Note that a "_" will be automatically generated.