as.array: Coerce antsImage objects to array

as.arrayR Documentation

Coerce antsImage objects to array

Description

Converts antsImage, antsImage object to different data types

Usage

## S4 method for signature 'antsImage'
dim(x)

## S4 method for signature 'antsImage'
as.numeric(
  x,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S4 method for signature 'antsImage'
as.matrix(
  x,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S3 method for class 'antsImage'
as.matrix(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S4 method for signature 'antsImage'
as.array(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S3 method for class 'antsImage'
as.array(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S3 method for class 'antsImage'
as.character(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S3 method for class 'antsImage'
as.factor(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S3 method for class 'antsImage'
factor(
  x,
  ...,
  mask = logical(),
  region = new("antsRegion", index = integer(), size = integer())
)

## S4 method for signature 'antsMatrix'
as.data.frame(x)

## S3 method for class 'antsMatrix'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S4 method for signature 'antsMatrix'
as.matrix(x, ...)

## S4 method for signature 'antsMatrix'
as.list(x, ...)

Arguments

x

object of class antsImage or antsMatrix

mask

a logical vector/array or binary antsImage object

region

a antsRegion object

...

additional arguments passed to functions

row.names

NULL or a character vector giving the row names for the data frame.

optional

passsed to as.data.frame

Examples

outimg <- makeImage(c(2, 10), rnorm(20))
as.numeric(outimg)
as.numeric(outimg, mask = outimg > 1)
testthat::expect_error(as.numeric(outimg, mask = outimg))

outimg <- makeImage(c(2, 10), rnorm(20))
as.matrix(outimg)
as.matrix(outimg, mask = outimg > 1)
testthat::expect_error(as.matrix(outimg, mask = outimg))
outimg <- makeImage(c(2, 10, 2), rnorm(40))
testthat::expect_error(as.matrix(outimg))
outimg <- makeImage(c(2, 10), rnorm(20))
as.matrix(outimg)
as.matrix(outimg, mask = outimg > 1)
outimg <- makeImage(c(2, 10, 2), rnorm(40))
testthat::expect_error(as.matrix(outimg))
img <- antsImageRead(getANTsRData("r16"))
img[img > 5] <- 0
sort(unique(as.character(img)))
factor(img)
table(img, img)

stnava/ANTsR documentation built on April 16, 2024, 12:17 a.m.