Describe the bug
StdShiftIntensity._stdshift (monai/transforms/intensity/array.py) always builds a full-image boolean mask, gathers every voxel through it, computes the std on that copy, and scatters back:
slices = (img != 0) if self.nonzero else ones(img.shape, dtype=bool)
if slices.any():
offset = self.factor * std(img[slices])
img[slices] = img[slices] + offset
On the default nonzero=False path (also the default for RandStdShiftIntensity), slices is all-True, so std(img[slices]) == std(img) and the scatter is just img + offset. The mask allocation, .any(), gather and scatter are extra.
Describe the bug
StdShiftIntensity._stdshift(monai/transforms/intensity/array.py) always builds a full-image boolean mask, gathers every voxel through it, computes the std on that copy, and scatters back:On the default
nonzero=Falsepath (also the default forRandStdShiftIntensity),slicesis all-True, sostd(img[slices]) == std(img)and the scatter is justimg + offset. The mask allocation,.any(), gather and scatter are extra.