Skip to contents

Convenience wrapper that inspects the file metadata and dispatches to read_vol for 3D data, read_vec for 4D data, or read_hyper_vec for 5D data.

Usage

read_image(
  file_name,
  type = c("auto", "vol", "vec", "hyper"),
  index = 1,
  indices = NULL,
  mask = NULL,
  mode = c("normal", "mmap", "bigvec", "filebacked")
)

Arguments

file_name

Character vector of file paths.

type

One of "auto", "vol", "vec", or "hyper" to override dispatch.

index

Volume index to use when returning a NeuroVol or when you want to load a subset of volumes while still returning a NeuroVec.

indices

Optional vector of indices passed through to read_vec.

mask

Optional spatial mask passed through to vector/hyper-vector readers.

mode

IO mode forwarded to read_vec.

Value

A NeuroVol when the input is effectively 3D (or when type = "vol"), a NeuroVec/NeuroVecSeq for 4D input, or a NeuroHyperVec for 5D input.

Examples

vol <- read_image(system.file("extdata", "global_mask2.nii.gz", package = "neuroim2"))
vec <- read_image(system.file("extdata", "global_mask_v4.nii", package = "neuroim2"))