as.array: Coerce antsImage objects to array

Description Usage Arguments Examples

Description

Converts antsImage, antsImage object to different data types

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## S4 method for signature 'antsImage'
dim(x)

## S4 method for signature 'antsImage'
is.na(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()))

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
outimg<-makeImage( c(2,10) , 1)
is.na(outimg)
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) 

muschellij2/atropos documentation built on May 4, 2019, 3:17 p.m.