Copies slots of a nifti
object to an array. This is useful if you're
subsetting 4D data and getting an array out
copyNIfTIHeader(
img,
arr,
drop_slots = c(".Data", "dim_"),
drop = TRUE,
onlylast = TRUE,
warn = TRUE,
...
)
img | object of class nifti to copy header |
---|---|
arr | array to copy header information |
drop_slots | Slots not to copy over from header |
drop | Should |
onlylast | if |
warn | if |
... | arguments to pass to |
Object of class nifti the size of arr
img = nifti(img = array(rnorm(10^4), dim=rep(10, 4)), dim=rep(10, 4), datatype = 16)
sub = img[,,,1:3]
copyNIfTIHeader(img, sub)
#> NIfTI-1 format
#> Type : nifti
#> Data Type : 16 (FLOAT32)
#> Bits per Pixel : 32
#> Slice Code : 0 (Unknown)
#> Intent Code : 0 (None)
#> Qform Code : 0 (Unknown)
#> Sform Code : 0 (Unknown)
#> Dimension : 10 x 10 x 10 x 3
#> Pixel Dimension : 1 x 1 x 1 x 1
#> Voxel Units : Unknown
#> Time Units : Unknown
sub = img[,,,1, drop=FALSE]
copyNIfTIHeader(img, sub)
#> NIfTI-1 format
#> Type : nifti
#> Data Type : 16 (FLOAT32)
#> Bits per Pixel : 32
#> Slice Code : 0 (Unknown)
#> Intent Code : 0 (None)
#> Qform Code : 0 (Unknown)
#> Sform Code : 0 (Unknown)
#> Dimension : 10 x 10 x 10
#> Pixel Dimension : 1 x 1 x 1
#> Voxel Units : Unknown
#> Time Units : Unknown
copyNIfTIHeader(img, sub, drop = FALSE)
#> NIfTI-1 format
#> Type : nifti
#> Data Type : 16 (FLOAT32)
#> Bits per Pixel : 32
#> Slice Code : 0 (Unknown)
#> Intent Code : 0 (None)
#> Qform Code : 0 (Unknown)
#> Sform Code : 0 (Unknown)
#> Dimension : 10 x 10 x 10 x 1
#> Pixel Dimension : 1 x 1 x 1 x 1
#> Voxel Units : Unknown
#> Time Units : Unknown