Randomize the values within a mask
randomize_mask(img, mask)
img | Object of class nifti with values to be randomized |
---|---|
mask | Binary mask indicating which values should be randomized. |
Object of class nifti
set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
nim = oro.nifti::nifti(arr)
mask = abs(nim) > 1
randomize_mask(nim, mask)
#> NIfTI-1 format
#> Type : nifti
#> Data Type : 2 (UINT8)
#> Bits per Pixel : 8
#> Slice Code : 0 (Unknown)
#> Intent Code : 0 (None)
#> Qform Code : 0 (Unknown)
#> Sform Code : 0 (Unknown)
#> Dimension : 10 x 10 x 10
#> Pixel Dimension : 1 x 1 x 1
#> Voxel Units : Unknown
#> Time Units : Unknown