Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Reconstruction Runs #2

Open
wgiforos opened this issue Sep 27, 2021 · 1 comment
Open

Automatic Reconstruction Runs #2

wgiforos opened this issue Sep 27, 2021 · 1 comment
Assignees
Labels
reconstruction Reconstruction of ptychographic data

Comments

@wgiforos
Copy link
Collaborator

So, what I'm thinking is looking at being able to run the code so that you can input a certain number of different iterations to run so that the code itself can run through the iterations and save images of the data without having to be set to the new data set by human hand whenever it ends.

One example of this is you could set up a code perhaps where you have multiple strings where each string contains the parameters you want to run for one reconstruction, ie no flip images, at an angle of 11.25 and for 40 iterations of epie. Then, once this finishes, the code would save the output tables to a data file and move on to collect the next string of inputs and once again run the code according to the input given.

This way, we would be able to run multiple reconstructions at a time and greatly consolidate how much time it takes to run reconstructions on the data, as this could be run overnight, instead of just having one iteration run overnight.

It could also be that the data plots don't need to be saved as all, but rather could just be left open as they normally are, and then when we go to collect the data the next day, we have them open in the same order as they were inputed, as we have the input data page where we defined each iteration of reconstruct.py

@jacione
Copy link
Owner

jacione commented Sep 27, 2021

Ok, so it sounds like we would want to start saving the reconstructions separate from the original datafiles (rather than within the PTY file). That way the reconstruction wouldn't overwrite every time. We'll also need to save the parameters that go with each reconstruction, otherwise we'll just have a big set of useless images.

For this to work, we'll probably need to do the following:

  • Add an attribute in ReconstructionSpecs called "save_dir" that lets you save to a specific directory.
  • Add a method to ReconstructionSpecs that returns a big string of all the specs.
  • Change the "Recon.save_reconstruction()" method so that it saves in a new way.

I'm thinking that the saved reconstructions could be in a folder that looks something like this:

save_dir
    | datatitle-dd-mm-yyyy
        | R_00001
            | object_data.npy
            | probe_data.npy
            | amp_phase_separate.png
            | amp_phase_together.png
            | reconstruction_specs.txt
        | R_00002
            | object_data.npy
            | probe_data.npy
            | amp_phase_separate.png
            | amp_phase_together.png
            | reconstruction_specs.txt

and so on. That would keep the reconstructions organized by dataset.

For the save_reconstruction method, I would recommend you try to follow this psuedocode:

def save_reconstruction(self, save_dir):
    save_dir = Path(save_dir) / self.title  # alternatively, you could add this statement in ReconstructionSpecs
    # List all the subdirectories in save_dir
    # Pull out the ones that follow the original format "R_xxxxx"
    # Make a new subdir that's incremented from the highest existing subdir number
    # Save the reconstruction data in this new subdir

As for the problem of running multiple reconstructions in sequence, if you copy over everything from "reconstruction.py" into a new script (something like "multi_reconstruction.py"), you should be able to do this fairly easily just by copy/pasting the specs definition a bunch of times, putting in all the different reconstruction parameters you want for each one, then changing the execution to

if __name__ == '__main__':
    for SPECS in [SPECS1, SPECS2, SPECS3, ... , SPECSN]:
        reconstruct(SPECS)

@jacione jacione added the reconstruction Reconstruction of ptychographic data label Sep 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reconstruction Reconstruction of ptychographic data
Projects
None yet
Development

No branches or pull requests

2 participants