Learn R Programming

neurobase (version 1.32.4)

replace_outside_surface: Replace Values Outside Surface of image

Description

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

Usage

replace_outside_surface(
  img,
  value = 0,
  threshold = 0,
  replace_value = NA,
  reorient = FALSE
)

Value

Creates an array of binary values. If img is a nifti

object, then a nifti is returned

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

Examples

Run this code
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