antsImageGetSet.Rd
Get and set methods for image header information
antsGetSpacing(x) antsSetSpacing(x, spacing) antsGetOrigin(x) antsSetOrigin(x, origin) antsGetDirection(x) antsSetDirection(x, direction)
x | antsImage to access, of dimensionality |
---|---|
spacing | numeric vector of length |
origin | numeric vector of length |
direction | matrix of size |
For get
methods, vector of length d
(origin, spacing) or matrix of size d * d
(direction).
For set
methods, 0 to indicate success.
#> [1] 1 1#> [1] 0antsGetOrigin(img)#> [1] 0 0#> [1] 0testthat::expect_error(antsGetSpacing(as.array(img) ) ) testthat::expect_error(antsSetSpacing(as.array(img), c(2,2) ), "class" ) testthat::expect_error(antsSetSpacing(img, c("2",2) ), "numeric" ) testthat::expect_error(antsSetSpacing(img, c(3,3,3) ), "dimensions" ) testthat::expect_error(antsGetOrigin(as.array(img) ) ) testthat::expect_error(antsSetOrigin(as.array(img), c(0.5, 0.5) ) ) testthat::expect_error(antsSetOrigin(img, c("0.5", 0.5) ) ) testthat::expect_error(antsSetOrigin(img, c(0.5, 0.5, 0.5) ) ) img <- makeImage(c(5,5), rnorm(25)) antsGetDirection(img)#> [,1] [,2] #> [1,] 1 0 #> [2,] 0 1testthat::expect_error(antsGetDirection(as.array(img) ) ) outimg <- makeImage(c(5,5), rnorm(25)) antsGetDirection(outimg)#> [,1] [,2] #> [1,] 1 0 #> [2,] 0 1direct = antsGetDirection(outimg) antsSetDirection(outimg, direct)#> [1] 0testthat::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) ))