Calculate the mean of a list of antsImages

antsAverageImages(imageList, normalize = FALSE, weights, verbose = TRUE)

Arguments

imageList

list of antsImages or a character vector of filenames

normalize

boolean determines if image is divided by mean before averaging

weights

a vector of weights of length equal to imageList

verbose

print a progress bar

Author

Avants BB, Pustina D

Examples

f1 <- getANTsRData("r16")
f2 <- getANTsRData("r64")
r16 <- antsImageRead(f1)
r64 <- antsImageRead(f2)
mylist <- list(r16, r64)
antsAverageImages(mylist)
#> ================================================================================
#> antsImage
#>   Pixel Type          : float 
#>   Components Per Pixel: 1 
#>   Dimensions          : 256x256 
#>   Voxel Spacing       : 1x1 
#>   Origin              : 0 0 
#>   Direction           : 1 0 0 1 
#> 
bad <- resampleImage(r16, c(2, 2), useVoxels = FALSE)
antsAverageImages(mylist, normalize = TRUE)
#> ================================================================================
#> antsImage
#>   Pixel Type          : float 
#>   Components Per Pixel: 1 
#>   Dimensions          : 256x256 
#>   Voxel Spacing       : 1x1 
#>   Origin              : 0 0 
#>   Direction           : 1 0 0 1 
#> 
antsAverageImages(c(f1, f2))
#> ================================================================================
#> antsImage
#>   Pixel Type          : float 
#>   Components Per Pixel: 1 
#>   Dimensions          : 256x256 
#>   Voxel Spacing       : 1x1 
#>   Origin              : 0 0 
#>   Direction           : 1 0 0 1 
#> 
testthat::expect_error(antsAverageImages(list(f1, "")))
testthat::expect_error(antsAverageImages(list(r64, bad)))
#> ========================================
diff_size <- as.antsImage(r64[1:10, 1:10], ref = r64)
testthat::expect_error(antsAverageImages(list(r64, diff_size)))
#> ========================================