set.seed(5)
dims = rep(10, 3)
arr = array(0, dim = dims)
arr[ 3:5, 4:6, c(2, 6:8, 5)] = 1
nim = oro.nifti::nifti(arr)
out = replace_outside_surface(nim, replace_value = 0)
out_arr = replace_outside_surface(arr, replace_value = 0)
testthat::expect_equal(out_arr, array(out, dim = dim(out)))
Run the code above in your browser using DataLab