replace_outside_surface: Replace Values Outside Surface of image

Description Usage Arguments Value Examples

View source: R/replace_outside_hull.R

Description

Determines values outside the surface of an image and gives a mask back with those values set to a replacement.

Usage

1
2
3
4
5
6
7
replace_outside_surface(
  img,
  value = 0,
  threshold = 0,
  replace_value = NA,
  reorient = FALSE
)

Arguments

img

nifti object or array

value

Value to check against. If zero, then replace_outside_surface will include any dimension that has fewer than threshold zeroes. May be a vector of values, matched with match

threshold

Include dimension if fewer than threshold voxels are in the slice

replace_value

Value to replace those outside the surface.

reorient

Should image be reoriented if a filename? Passed to check_nifti

Value

Creates an array of binary values. If img is a nifti object, then a nifti is returned

Examples

1
2
3
4
5
6
7
8
9
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)))

neuroconductor/neurobase documentation built on May 19, 2021, 5:24 a.m.