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

Adding possibility to simulate images in batches #94

Open
federico-carrara opened this issue Feb 5, 2025 · 2 comments
Open

Adding possibility to simulate images in batches #94

federico-carrara opened this issue Feb 5, 2025 · 2 comments

Comments

@federico-carrara
Copy link
Contributor

A useful feature to implement would be allowing users to simulate a batch of images simultaneously.

In my view, the user will have to pass a list of' Samples' to the Simulation class. Then, using the same simulation settings (e.g., parameters, optical config, detector, ..., otherwise things would become way more involved), the simulation will be performed at the same time for the entire batch.

This feature would become extremely handy in case the user would need to simulate multiple images. Indeed, the current solution is to simulate images iteratively, which is quite inefficient (although some things like the PSF are cached). At the same time, from a preliminary check, implementation appears to be rather straightforward.

@tlambert03 please let me know your take on this. I will make a draft PR with a few comments pointing to the parts of the code that will need to be changed in case we decide to proceed. Moreover, if you agree, I am happy to try to implement this!

@tlambert03
Copy link
Owner

In my view, the user will have to pass a list of' Samples' to the Simulation class.

yep, makes perfect sense. We can relatively easily do this in a backwards compatible way. I think you should

  • change the type hint on the pydantic class to list[Samples], and change the name to samples
  • Add a field validator that casts a single object to a list of objects
  • for backwards compatibility create an @property that returns just the first item in the list (and sends out a deprecation warning)

@federico-carrara
Copy link
Contributor Author

federico-carrara commented Feb 5, 2025

Do you suggest calling the new axis B (as batch) or S (as sample)? Personally, I'd say S is more appropriate. B is, I guess, more the Deep Learning way ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants