RandFlip Spatial Axis and Probabilities both as Sequences #5356
Replies: 2 comments 2 replies
-
Hi @AustinTapp, the
Hope it can help you, thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi @KumoLiu, Thanks for your quick reply. I understand Instead, I suggest users could additionally provide their probability as a sequence. The Without this, users must specify multiple Best regards, |
Beta Was this translation helpful? Give feedback.
-
For RandFlip, spatial_axis can be set individually (i.e. [0], [1], [2], for x, y and z respectively) or spatial_axis can be set as a sequence[int] (i.e. [0, 1, 2], for x, y and z respectively). However, probabilities can only be set as a single float.
It would be helpful to allow probability arguments to also be passed in the same manner as spatial_axis: Optional[Union[Sequence[int], int]] = None. This would permit users to define a sequence, where the probability float matches the corresponding spatial_axis in a sequence. The typical behavior, which uses a single int for all random flip probabilities, should be maintained.
For example:
RandFlipd(keys=["keys"], spatial_axis=[0, 1, 2], prob=[0.1, 1, 0.5])
Would flip an image along the x-axis 10%, along the y-axis 100%, and along the z-axis 50% of the time. Note that this definition would be for independent flipping probability.
Currently, users must specify multiple RandFlip transforms for differing axes if they would like to initialize each flip independently. An example of this occurs in https://github.com/Project-MONAI/tutorials/blob/main/self_supervised_pretraining/ssl_finetuning_train.py#L87
Thanks for your consideration and support.
Beta Was this translation helpful? Give feedback.
All reactions