info.nii: Retrieve NIfTI Header Information

Description Usage Arguments Details Value Author(s) Examples

View source: R/info.nii.R

Description

Retrieve information from the NIfTI header of the specified file. The entire header can be retrieved as a list, or a single or subset of items can be specified as a character vector to get specific information. There are several special cases implemented including getting number of voxels, number of volumes, image spacing, and orientation.

Usage

1
info.nii(nii.file, field="hdr")

Arguments

nii.file

Full directory listing to NIfTI file.

field

A character vector of field names to be returned.

Details

Fields can take a number of different values indicating the entire header, a specific item or subset of header values or set of useful values.
Number of voxels in XYZ planes:
'dimensions', 'dims', 'size', 'sz', 'voxels', 'vxls', 'xyz'
Voxel spacing:
'space', 'spacing'
Number of Volumes:
'volumes', 'vols', 'trs'
Orientation fields:
'orientation'
Entire Header as list object:
'hdr'
Subset of specific header items:
'sizeof_hdr', 'data_type', 'db_name', 'extents', 'session_error', 'regular', 'dim_info', 'dim', 'intent_p1', 'intent_p2', 'intent_p3', 'intent_code', 'datatype', 'bitpix', 'slice_start', 'pixdim', 'vox_offset', 'scl_slope', 'scl_inter', 'slice_end', 'slice_code', 'xyzt_units', 'cal_max', 'cal_min', 'slice_duration', 'toffset', 'glmax', 'glmin', 'descrip', 'aux_file', 'qform_code', 'sform_code', 'quatern_b', 'quatern_c', 'quatern_d', 'qoffset_x', 'qoffset_y', 'qoffset_z', 'srow_x', 'srow_y', 'srow_z', 'intent_name', 'magic'

Value

A vector or named list containing the requested output

Author(s)

Timothy R. Koscik <timothy-koscik@uiowa.edu>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
# specify directory listing to NII file as a string
nii.file <- "~/file.nii"

# get the number of voxels in the 3-dimensional volume of the specified image
image.size <- info.nii(nii.file = nii.file, field = "dimensions")

# get the size in mm of the volume
image.spacing <- info.nii(nii.file = nii.file, field = "spacing")

# get the number of volumes
image.volumes <- info.nii(nii.file = nii.file, field = "volumes")

# get list containing orientation parameters
image.orientation <- info.nii(nii.file = nii.file, field = "orientation")

# get entire header from NII file
image.hdr <- info.nii(nii.file = nii.file, field = "hdr")

# get a specific element in the header
image.hdr.datatype <- info.nii(nii.file = nii.file, field = "datatype")

## End(Not run)

TKoscik/tk.nifti documentation built on June 6, 2021, 2:30 a.m.