oncoray / mirp

Medical Image Radiomics Processor
https://oncoray.github.io/mirp/
European Union Public License 1.2
51 stars 14 forks source link

Replace legacy numpy randomiser by generator-based randomisation #44

Closed alexzwanenburg closed 8 months ago

alexzwanenburg commented 9 months ago

mirp currently relies on the numpy.random module for randomisation, which uses the legacy RandomState randomiser. The drawback of the legacy implementation is that there is no default seed, i.e., some output may vary per run, even for the same input. An option would be to set a global seed using numpy.random.seed. However this may change the global state of the user environment, and for that reason should be avoided.

We should switch to the newer generator-based implementation in numpy.random.Generator, which allows for setting a seed locally and thus generating reproducible output.

The following functions and methods are affected:

For the latter three, the seed should not be fully fixed, but rather defined by the workflow configuration parameters.

alexzwanenburg commented 9 months ago

Addresses #43 .