Learn R Programming

neurobase (version 1.32.4)

dropEmptyImageDimensions: Drop Empty Image Dimensions

Description

Drops dimensions of an image that has all irrelevant values

Usage

dropEmptyImageDimensions(
  img,
  value = 0,
  threshold = 0,
  other.imgs = NULL,
  keep_ind = FALSE,
  reorient = FALSE
)

drop_empty_dim( img, value = 0, threshold = 0, other.imgs = NULL, keep_ind = FALSE, reorient = FALSE )

Value

List of output image indices, and other images if other.imgs not specified or keep_ind = TRUE. Otherwise object of class nifti

Arguments

img

nifti object

value

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

threshold

Drop dimension if fewer than threshold voxels are in the slice

other.imgs

List of other nifti objects or filenames to apply the same dropping as img.

keep_ind

keep indices in output. Will return list, even if other.imgs not specified

reorient

Should image be reoriented if a filename?

See Also

getEmptyImageDimensions

Examples

Run this code
set.seed(5)
dims = rep(10, 3)
arr = array(rnorm(prod(dims)), dim = dims)
arr[,,10] = 0
nim = oro.nifti::nifti(arr)

dnim = dropEmptyImageDimensions(nim, keep_ind = TRUE)
new_nim = dnim$outimg
names(dnim)
dnim = dropEmptyImageDimensions(nim, keep_ind = TRUE, other.imgs = nim)
dims = rep(10, 4)
arr = array(rnorm(prod(dims)), dim = dims)
nim = oro.nifti::nifti(arr)

testthat::expect_error(
{dnim = dropEmptyImageDimensions(nim, keep_ind = TRUE)}
)

Run the code above in your browser using DataLab