IMSY-DKFZ / simpa

The Simulation and Image Processing for Photonics and Acoustics (SIMPA) toolkit.
https://simpa.readthedocs.io/en/main/
Other
74 stars 18 forks source link

Check settings prerequisites only once #84

Open TomTomRixRix opened 3 years ago

TomTomRixRix commented 3 years ago

At the moment, the check_settings_prerequisites() method is called several times within a simulation, e.g. in the kWave adapter and during reconstruction with DAS. It would be desirable if the settings were only checked once in the beginning of a simulation, so that all adapters can assume that all settings are valid.

jgroehl commented 3 years ago

The settings prerequisites are checked on the level of the simulate method already:

https://github.com/CAMI-DKFZ/simpa/blob/2ca2b81039a7252da7c618d8ba69527f2d6f240f/simpa/core/simulation.py#L41-L45

As such, the check can be omitted from any other location in the SIMPA source.

jgroehl commented 3 years ago

For use cases, where a module adapter is called individually (e.g. fr performing image reconstruction ONLY), isn't it desirable to automatically test if the volume and the device are compatible? Otherwise, it would be the responsibility of the user and might lead to errors that are hard to explain...

What do you think @TomTomRixRix

TomTomRixRix commented 3 years ago

You're right, if the adapters are used individually it makes completely sense to perform these checks in each adapter. Only in the use case of an entire simulation pipeline we should do the check once in the beginning and don't repeat it in every adapter.

jgroehl commented 3 years ago

Any idea how to implement this behaviour? :D

TomTomRixRix commented 3 years ago

Perhaps by having some sort of global variable haveChecksBeenPerformed which is set to true once the checks have been performed. Each adapter can then skip the tests accordingly or perform them, if it is the first adapter.