py4dstem / py4DSTEM

GNU General Public License v3.0
206 stars 141 forks source link

Multislice ptychography with mixed state probe? #523

Closed Kylee-iem closed 1 year ago

Kylee-iem commented 1 year ago

Hello, I have a question about the ptychography. Could you please tell me whether there is function to use the multislice ptychography with mixed state probe? I cannot find the function in the py4DSTEM tutorials. Thanks in advance.

gvarnavi commented 1 year ago

Hello @Kylee-iem,

Indeed, that functionality was not yet supported (mostly out of laziness, and since we're thinking of revamping the ptycho infrastructure soon which would affect all classes).

However, you were not the only person to ask for this functionality, so I went ahead and implemented it real quick. This is now pushed in the phase_contrast branch* and can be called as:

py4DSTEM.process.phase.MixedstateMultislicePtychographicReconstruction(
    datacube=dataset,
    num_probes=2,
    num_slices=6,
    slice_thicknesses=slice_thicknesses,
    ...
)

Hopefully the arguments you expect reconstruct to have for both multi-slice and mixed-state should all be supported, but I only did some rudimentary testing on this using the tutorials here and here, so I suspect there could be bugs. If you find any, please report them here.

Finally, note that under the current paradigm - the implementation is vectorized, meaning the propagated probes inside the forward model are stored with dimensions (num_slices, batch_size, num_probes, region_of_interest_shape[0],region_of_interest_shape[1]) which might lead to memory issues on the GPU. This should hopefully be alleviated in the upcoming restructuring, where we're hoping to switch to a streaming data model.

* You will need to set-up a dev environment to try this out before the next release using something like:

git clone https://github.com/py4dstem/py4DSTEM.git
cd py4DSTEM
git checkout phase_contrast
pip install -e .
sezelt commented 1 year ago

I tried it on some of my experimental data and it seems to behave correctly

gvarnavi commented 1 year ago

Great, thanks for testing @sezelt! Closing as PR #539 should include this in dev/next release.