set.seed(2022)
img = nifti(array(rnorm(10^3), dim = rep(10, 3)))
mask = img > 1.5
mask_vals(img, mask)
testthat::expect_equal(sum(mask_vals(img, mask)), 117.628200302518)
mask_vals(img, mask) = rep(4, sum(mask))
mask_vals(img, as(mask, "array")) = rep(4, sum(mask))
mask_vals(as(img, "array"),
as(mask, "array")) = rep(4, sum(mask))
Run the code above in your browser using DataLab