Read file info from image header

antsImageHeaderInfo(filename)

Arguments

filename

name of image file to scan for info

Value

outputs a list containing:

pixelclass:

Type of pixel (scalar, vector, etc).

pixeltype:

Type of pixel values (int, float, etc).

nDimensions:

Number of image dimensions.

nComponents:

Number of pixel dimensions.

dimensions:

Size of image dimensions.

spacing:

Pixel resolution.

origin:

Spatial origin of image

pixelclass:

Spatial directions of image axes.

Author

Duda JT

Examples

antsImageHeaderInfo(getANTsRData("r16"))
#> $pixelclass
#> [1] "scalar"
#> 
#> $pixeltype
#> [1] "unsigned char"
#> 
#> $nDimensions
#> [1] 2
#> 
#> $nComponents
#> [1] 1
#> 
#> $dimensions
#> [1] 256 256
#> 
#> $spacing
#> [1] 1 1
#> 
#> $origin
#> [1] 0 0
#> 
#> $direction
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 

img <- antsImageRead(getANTsRData("r16"))
antsImageHeaderInfo(img)
#> $pixelclass
#> [1] "scalar"
#> 
#> $pixeltype
#> [1] "float"
#> 
#> $nDimensions
#> [1] 2
#> 
#> $nComponents
#> [1] 1
#> 
#> $dimensions
#> [1] 256 256
#> 
#> $spacing
#> [1] 1 1
#> 
#> $origin
#> [1] 0 0
#> 
#> $direction
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
antsImageHeaderInfo(getANTsRData("r16"))
#> $pixelclass
#> [1] "scalar"
#> 
#> $pixeltype
#> [1] "unsigned char"
#> 
#> $nDimensions
#> [1] 2
#> 
#> $nComponents
#> [1] 1
#> 
#> $dimensions
#> [1] 256 256
#> 
#> $spacing
#> [1] 1 1
#> 
#> $origin
#> [1] 0 0
#> 
#> $direction
#>      [,1] [,2]
#> [1,]    1    0
#> [2,]    0    1
#> 
testthat::expect_error(antsImageHeaderInfo(""))