Description
Describe the bug
When using RandGaussianNoised during training with more than one key the error "ValueError: shape mismatch: objects cannot be broadcast to a single shape" is returned.
To Reproduce
I have encountered the error when using RandGaussianNoised in my training pipeline for BraTS.
I have in my composition of training transforms:
RandGaussianNoised(keys=["flair", "t1", "t1ce", "t2"], mean=0., std=0.1, prob=0.15),
For this example, in
we obtain
self.mean = (0.,0,0,0)
.
This creates a mismatch between the shape of self.mean
and im_shape
in
where
im_shape=(1,128,128,128)
.
A Simple Solution
By replacing
by
self.mean = mean
the error does not appear anymore.
Expected behavior
The reason why the tests pass with the current version of the code is that the test https://github.com/Project-MONAI/MONAI/blob/master/tests/test_rand_gaussian_noised.py only contains examples with len(keys)==1
.
In addition, in
MONAI/monai/transforms/intensity/dictionary.py
Lines 131 to 133 in 8207e1e
the same sample of Gaussian noise is used for all the keys.
I would have expected that different noise samples would be used with different keys.
Is it the intended behavior for this transformation?
I can work on a pull request if you can confirm which behavior you would like to see here.
Thank you,
Lucas