Skip to content

Commit c9b8bdb

Browse files
Add deterministic support for RandSimulateLowResolutiond (#8057)
Fixes #7911, which describes how the RandSimulateLowResolutiond dictionary transform produces non-deterministic outputs, yet the typical array transform RandSimulateLowResolution produces deterministic ones. ### Description Inside of `RandSimulateLowResolutiond`, added the line `self.sim_lowres_tfm.set_random_state(seed, state)` in `set_random_state` to ensure the helper function `sim_lowres_tfm` is seeded and the transform can be performed deterministically. Note: I also sifted through the other dictionary transforms with helper functions and did not find anything that looked problematic similar to this. ### Types of changes <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Non-breaking change (fix or new feature that would not break existing functionality). - [x] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [x] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: BenjaminLi <[email protected]> Co-authored-by: YunLiu <[email protected]>
1 parent 6a0e1b0 commit c9b8bdb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

monai/transforms/spatial/dictionary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2588,6 +2588,7 @@ def set_random_state(
25882588
self, seed: int | None = None, state: np.random.RandomState | None = None
25892589
) -> RandSimulateLowResolutiond:
25902590
super().set_random_state(seed, state)
2591+
self.sim_lowres_tfm.set_random_state(seed, state)
25912592
return self
25922593

25932594
def __call__(self, data: Mapping[Hashable, NdarrayOrTensor]) -> dict[Hashable, NdarrayOrTensor]:

0 commit comments

Comments
 (0)