DOI: 10.5281/zenodo.10780748
title: Dataset and code for multi-peak bragg ptychography simulations

description: Simulation code and dataset for multi-peak bragg ptychography reconstruction. Paper titled:

Imaging extended single crystal lattice distortion fields with multi-peak Bragg ptychography

Paper accepted for publication in Optics Express (TBD). Preprint at:https://arxiv.org/abs/2312.14907

The preprint currently contains an older version of the paper and the paper figuers, from before revision. However, the algorithms and the gist of the paper remains unchanged.

The workflow used for the simulations and reconstructions was as follows:

1) Take 2D probe structure collected in an experiment at NSLS. This is stored at:

`mbptycho/experiments/matlab/datasets_0821/recon_probe_29902.mat`

2) Specify the Bragg peaks of interest and some basic simulation parameters to the matlab code in  `mbptycho/experiments/matlab/code_0821` to generate the interpolated 3D probe structure for the individual Bragg peaks. The version of the probes used in the paper is stored in 

`mbptycho/experiments/matlab/datasets_0821/probes.h5'

3) Use these simulation parameters and the probe structures for python (numpy and scipy) based forward simulations to generate the simulated diffraction data.

4) Use the simulation parameters and simulated data for Tensorflow-based reconstruction code.

 

There is a lot of redundancy in this workflow. Ideally, we would not need either the matlab or the numpy/scipy code and rely exclusively on Tensorflow code. After all, the Tensorflow code also contains the forward simulations. We were not able to curate and clean the workflow and code due to time constraints. 

Structure:



mbptycho/mbptycho: Contains the python code used for the forward model simulation and reconstructions.



mbptycho/mbptycho/code:



The python files in this base directory are for the forward model only. This part uses numpy and scipy extensively.



mbptycho/mbptycho/code/recons:



The code here uses Tensorflow 2.x for GPU-based reverse-mode automatic differentiation for the forwrad model and reconstruction. 

This code is tightly coupled with the numpy-based forward model code in mbptycho/mbptycho/code for parameters like the object and probe sizes, pixellations, ptychography scan locations, etc.

This needs to be decouped before use in actual experiments.



mbptycho/mbptycho/tests/point_inclusions_sparse_scan/weak_peaks:



This part contains the jupyter notebooks with actual simulation, reconstruction, and the resulting figures. The directory structure indicates that we are simulating a sparse ptychographic grid scanning a thin film with point inclusions, generating diffraction peaks with low photon counts.



sim.ipynb: Contains the forward mode simulation. The simulated thin film and the collected diffraction data are stored separately as lz4 files as described below.

recons_*.ipynb: Contain the reconstruction code with the notation as used in the paper preprint. The reconstruction outputs are saved variously as npz and gz files as described below.

plots.ipynb:Plotting the results for publication.







mbptycho/experiments:



Contains the matlab code used to generate the 3D probe structure, the matlab outputs. Also contains the simulation and reconstruction results obtained from the python code.

experiments/matlab:Contains a draft version of the simulation code written in matlab. Also contains the data generated from the matlab code. Note that the 3D probe structure generated from the matlab code are used in the python simulations (just to avoid rewriting and testing the probe interpolation code).



experiments/matlab/code_0821Contains the matlab codes (in *.m files) that:



take the 2D probe structure (as mentioned above) and generates interpolated 3D probe structures for the various Bragg peaks.

A draft version of the forward simulation.



experimetns/matlab/datasets_0821Contains the 2D probe structure file, the 3D probe structures (in probes.h5 for the latest version) and some temporary ".mat" files used in the matlab simulations.



mbptycho/experiments/python/point_inclusion_sparse/weak_peaks :



Contains the files lz4 files generated during the initial forward simulation with numpy/scipy.

Also contains the npz and gz files generated during the Tensorflow-based reconstructions.