Cuts a numeric image into an integer factor, with the option of a mask.

# S3 method for nifti
cut(x, breaks, ..., mask)

# S3 method for anlz
cut(x, ..., mask)

Arguments

x

Object of class nifti

breaks

either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which x is to be cut. Passed to cut)

...

Arguments passed to cut

mask

object to subset the image. If missing, then all values of the image are used

Value

Object of class nifti with an attribute of levels

Examples

img = nifti(array(rnorm(10^3), dim = rep(10, 3)))
mask = img > 0
cut(img, mask = mask, breaks = 4)
#> NIfTI-1 format
#>   Type            : nifti
#>   Data Type       : 4 (INT16)
#>   Bits per Pixel  : 16
#>   Slice Code      : 0 (Unknown)
#>   Intent Code     : 0 (None)
#>   Qform Code      : 0 (Unknown)
#>   Sform Code      : 0 (Unknown)
#>   Dimension       : 10 x 10 x 10
#>   Pixel Dimension : 1 x 1 x 1
#>   Voxel Units     : Unknown
#>   Time Units      : Unknown