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

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

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).

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.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# 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)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.