Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

copyNIfTIHeader

Copy NIfTI Header to an array


Description

Copies slots of a nifti object to an array. This is useful if you're subsetting 4D data and getting an array out

Usage

copyNIfTIHeader(
  img,
  arr,
  drop_slots = c(".Data", "dim_"),
  drop = TRUE,
  onlylast = TRUE,
  warn = TRUE,
  ...
)

Arguments

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 dropImageDimension be called before returning?

onlylast

if drop = TRUE, passed to dropImageDimension, if only the last dimensions should be dropped

warn

if drop = TRUE, passed to dropImageDimension, for warning print out

...

arguments to pass to nifti

Value

Object of class nifti the size of arr

Examples

img = nifti(img = array(rnorm(10^4), dim=rep(10, 4)), dim=rep(10, 4), datatype = 16)
sub = img[,,,1:3]
copyNIfTIHeader(img, sub)
sub = img[,,,1, drop=FALSE]
copyNIfTIHeader(img, sub) 
copyNIfTIHeader(img, sub, drop = FALSE)

neurobase

'Neuroconductor' Base Package with Helper Functions for 'nifti' Objects

v1.32.1
GPL-2
Authors
John Muschelli [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.