Learn R Programming

nat (version 1.8.24)

unmask: Make im3d image array containing values at locations defined by a mask

Description

Make im3d image array containing values at locations defined by a mask

Usage

unmask(
  x,
  mask,
  default = NA,
  attributes. = attributes(mask),
  copyAttributes = TRUE
)

Value

A new im3d object with attributes/dimensions defined by

mask and values from x. If copyAttributes is

FALSE, then it will have mode of x and length of mask

but no other attributes.

Arguments

x

the data to place on a regular grid

mask

An im3d regular image array where non-zero voxels are the selected element.

default

Value for regions outside the mask (default: NA)

attributes.

Attributes to set on new object. Defaults to attributes of mask

copyAttributes

Whether to copy over attributes (including dim) from the mask to the returned object. default: TRUE

Details

The values in x will be placed into a grid defined by the dimensions of the mask in the order defined by the standard R linear subscripting of arrays (see e.g. arrayInd).

See Also

Other im3d: as.im3d(), boundingbox(), im3d-coords, im3d-io, im3d(), imexpand.grid(), imslice(), is.im3d(), mask(), origin(), projection(), threshold(), voxdims()

Examples

Run this code
if (FALSE) {
# read in a mask
LHMask=read.im3d(system.file('tests/testthat/testdata/nrrd/LHMask.nrrd', package='nat'))
# pick out all the non zero values
inmask=LHMask[LHMask!=0]
# fill the non-zero elements of the mask with a vector that iterates over the
# values 0:9
stripes=unmask(seq(inmask)%%10, LHMask)
# make an image from one slice of that result array
image(imslice(stripes,11), asp=TRUE)
}

Run the code above in your browser using DataLab