Overloaded operators for antsImage objects

# S4 method for class 'antsImage,antsImage'
Arith(e1, e2)

# S4 method for class 'antsImage,antsImage'
e1 + e2

# S4 method for class 'antsImage,antsImage'
e1 - e2

# S4 method for class 'antsImage,antsImage'
e1 * e2

# S4 method for class 'antsImage,antsImage'
e1/e2

# S4 method for class 'antsImage,antsImage'
e1^e2

# S4 method for class 'antsImage,antsImage'
e1%%e2

# S4 method for class 'antsImage,antsImage'
e1%/%e2

# S4 method for class 'antsImage,numeric'
Arith(e1, e2)

# S4 method for class 'antsImage,numeric'
e1 + e2

# S4 method for class 'antsImage,numeric'
e1 - e2

# S4 method for class 'antsImage,numeric'
e1 * e2

# S4 method for class 'antsImage,numeric'
e1/e2

# S4 method for class 'antsImage,numeric'
e1^e2

# S4 method for class 'antsImage,numeric'
e1%%e2

# S4 method for class 'antsImage,numeric'
e1%/%e2

# S4 method for class 'numeric,antsImage'
e1 + e2

# S4 method for class 'numeric,antsImage'
e1 - e2

# S4 method for class 'numeric,antsImage'
e1 * e2

# S4 method for class 'numeric,antsImage'
e1/e2

# S4 method for class 'numeric,antsImage'
e1^e2

# S4 method for class 'numeric,antsImage'
e1%%e2

# S4 method for class 'numeric,antsImage'
e1%/%e2

# S4 method for class 'antsImage,missing'
Arith(e1, e2)

# S4 method for class 'numeric,antsImage'
Arith(e1, e2)

# S4 method for class 'antsImage,logical'
Arith(e1, e2)

# S4 method for class 'logical,antsImage'
Arith(e1, e2)

# S4 method for class 'antsImage,array'
Arith(e1, e2)

# S4 method for class 'array,antsImage'
Arith(e1, e2)

# S4 method for class 'list,antsImage'
Arith(e1, e2)

# S4 method for class 'antsImage,list'
Arith(e1, e2)

# S4 method for class 'antsImage,antsImage'
e1 == e2

# S4 method for class 'antsImage,list'
e1 == e2

# S4 method for class 'antsImage,array'
e1 == e2

# S4 method for class 'array,antsImage'
e1 == e2

# S4 method for class 'antsImage,ANY'
e1 == e2

# S4 method for class 'ANY,antsImage'
e1 == e2

# S4 method for class 'antsImage,antsImage'
e1 > e2

# S4 method for class 'antsImage,list'
e1 > e2

# S4 method for class 'antsImage,array'
e1 > e2

# S4 method for class 'array,antsImage'
e1 > e2

# S4 method for class 'antsImage,ANY'
e1 > e2

# S4 method for class 'ANY,antsImage'
e1 > e2

# S4 method for class 'antsImage,antsImage'
e1 < e2

# S4 method for class 'antsImage,list'
e1 < e2

# S4 method for class 'antsImage,array'
e1 < e2

# S4 method for class 'array,antsImage'
e1 < e2

# S4 method for class 'antsImage,ANY'
e1 < e2

# S4 method for class 'ANY,antsImage'
e1 < e2

# S4 method for class 'antsImage,antsImage'
e1 != e2

# S4 method for class 'antsImage,list'
e1 != e2

# S4 method for class 'antsImage,array'
e1 != e2

# S4 method for class 'array,antsImage'
e1 != e2

# S4 method for class 'antsImage,ANY'
e1 != e2

# S4 method for class 'ANY,antsImage'
e1 != e2

# S4 method for class 'antsImage,antsImage'
e1 <= e2

# S4 method for class 'antsImage,list'
e1 <= e2

# S4 method for class 'antsImage,array'
e1 <= e2

# S4 method for class 'array,antsImage'
e1 <= e2

# S4 method for class 'antsImage,ANY'
e1 <= e2

# S4 method for class 'ANY,antsImage'
e1 <= e2

# S4 method for class 'antsImage,antsImage'
e1 >= e2

# S4 method for class 'antsImage,list'
e1 >= e2

# S4 method for class 'antsImage,array'
e1 >= e2

# S4 method for class 'array,antsImage'
e1 >= e2

# S4 method for class 'antsImage,ANY'
e1 >= e2

# S4 method for class 'ANY,antsImage'
e1 >= e2

# S4 method for class 'antsImage'
is.na(x)

# S4 method for class 'antsImage'
anyNA(x, recursive = FALSE)

# S4 method for class 'antsImage'
is.nan(x)

# S4 method for class 'antsImage'
is.infinite(x)

# S4 method for class 'antsImage'
is.finite(x)

Arguments

e1

is an object of class antsImage.

e2

is an object of class antsImage.

x

is an object of class antsImage.

recursive

not used

Details

Overloading binary operators for antsImage Objects

Author

John Muschellli muschellij2@gmail.com

Examples


img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
img02 <- as.antsImage(array(64:1, c(4, 4, 4, 1)))
is.antsImage(img01 + img02)
#> [1] TRUE
is.antsImage(sqrt(2) * img01)
#> [1] TRUE
is.antsImage(img02 / pi)
#> [1] TRUE
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
et <- function(x) {
  testthat::expect_true(x)
}
x <- is.antsImage(img01 == img01)
et(x)
x <- is.antsImage(img01 == as.array(img01))
et(x)
x <- is.antsImage(img01 == 1)
et(x)
x <- is.antsImage(1 == img01)
et(x)
x <- is.antsImage(as.array(img01) == img01)
et(x)

x <- is.antsImage(img01 >= img01)
et(x)
x <- is.antsImage(img01 >= as.array(img01))
et(x)
x <- is.antsImage(img01 >= 1)
et(x)
x <- is.antsImage(1 >= img01)
et(x)
x <- is.antsImage(as.array(img01) >= img01)
et(x)

x <- is.antsImage(img01 > img01)
et(x)
x <- is.antsImage(img01 > as.array(img01))
et(x)
x <- is.antsImage(img01 > 1)
et(x)
x <- is.antsImage(1 > img01)
et(x)
x <- is.antsImage(as.array(img01) > img01)
et(x)

x <- is.antsImage(img01 < img01)
et(x)
x <- is.antsImage(img01 < as.array(img01))
et(x)
x <- is.antsImage(img01 < 1)
et(x)
x <- is.antsImage(1 < img01)
et(x)
x <- is.antsImage(as.array(img01) < img01)
et(x)


x <- is.antsImage(img01 <= img01)
et(x)
x <- is.antsImage(img01 <= as.array(img01))
et(x)
x <- is.antsImage(1 <= img01)
et(x)
x <- is.antsImage(img01 <= 1)
et(x)
x <- is.antsImage(as.array(img01) <= img01)
et(x)

x <- is.antsImage(img01 != img01)
et(x)
x <- is.antsImage(img01 != as.array(img01))
et(x)
x <- is.antsImage(1 != img01)
et(x)
x <- is.antsImage(img01 != 1)
et(x)
x <- is.antsImage(as.array(img01) != img01)
et(x)

###########################
# Multi image operations
########################
fname <- system.file("extdata",
  "multi_component_image.nii.gz",
  package = "ANTsRCore"
)
img <- antsImageRead(fname)

testthat::expect_is(img > 0, "antsImage")
testthat::expect_is(0 < img, "antsImage")
testthat::expect_is(img > c(0, 0), "antsImage")

testthat::expect_is(img >= 0, "antsImage")
testthat::expect_is(0 <= img, "antsImage")
testthat::expect_is(img >= c(0, 0), "antsImage")

testthat::expect_is(img < 0, "antsImage")
testthat::expect_is(0 > img, "antsImage")
testthat::expect_is(img < c(0, 0), "antsImage")

testthat::expect_is(img <= 0, "antsImage")
testthat::expect_is(0 >= img, "antsImage")
testthat::expect_is(img <= c(0, 0), "antsImage")

testthat::expect_is(img == 0, "antsImage")
testthat::expect_is(0 == img, "antsImage")
testthat::expect_is(img == c(0, 0), "antsImage")

testthat::expect_is(img != 0, "antsImage")
testthat::expect_is(0 != img, "antsImage")
testthat::expect_is(img != c(0, 0), "antsImage")

img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 == list())
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 > list())
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 < list())
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 != list())
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 <= list())
img01 <- as.antsImage(array(1:64, c(4, 4, 4, 1)))
testthat::expect_error(img01 >= list())