Get and set methods for image header information

antsGetSpacing(x)

antsSetSpacing(x, spacing)

antsGetOrigin(x)

antsSetOrigin(x, origin)

antsGetDirection(x)

antsSetDirection(x, direction)

Arguments

x

antsImage to access, of dimensionality d.

spacing

numeric vector of length d.

origin

numeric vector of length d.

direction

matrix of size d * d.

Value

For get methods, vector of length d (origin, spacing) or matrix of size d * d (direction). For set methods, 0 to indicate success.

Examples

img <- makeImage(c(5, 5), rnorm(25))
antsGetSpacing(img)
#> [1] 1 1
antsSetSpacing(img, c(2.0, 2.0))
#> [1] 0
antsGetOrigin(img)
#> [1] 0 0
antsSetOrigin(img, c(0.5, 0.5))
#> [1] 0
img <- makeImage(c(5, 5), rnorm(25))
antsGetDirection(img)
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
testthat::expect_error(antsGetDirection(as.array(img)))
outimg <- makeImage(c(5, 5), rnorm(25))
antsGetDirection(outimg)
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
direct <- antsGetDirection(outimg)
antsSetDirection(outimg, direct)
#> [1] 0
testthat::expect_error(antsSetDirection(as.array(outimg), direct))
testthat::expect_error(antsSetDirection(outimg, as.numeric(direct)))
testthat::expect_error(antsSetDirection(outimg, diag(length(dim(outimg)) + 1)))