read.nii.voxel: Read NII Voxel

Description Usage Arguments Details Value Author(s) Examples

View source: R/read.nii.voxel.R

Description

Read values from NIfTI files at given coordinates (x,y,z,t).

Usage

1
read.nii.voxel(nii.file, coords)

Arguments

nii.file

Full directory listing to a NIfTI file. File must not be gzipped.

coords

A numeric vector conatining x,y,z,t coordinates indicating the location to read values. To read all volumes (timepoints) at an XYZ coordinate use 'Inf' for t, e.g., c(50,50,50,Inf).

Details

NIfTI files need to be unzipped before using this function or any other portions of the nifti.io package. This is necessary given the inconsistent way in which gzipped files are indexed (Some information on this is given in the documentation for the readBin function).

Values for t coordinates (coords[4]) may be Inf to retrieve all timepoints for the given x,y,z coordinates. If data is 4D and only x, y, z coordinates are given, the value at those coordinates for the first volume only is returned.

Value

A number or a numeric vector containing values for all timepoints.

Author(s)

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

Examples

1
2
3
4
5
6
7
8
9
# get filename for example NII file included in nifti.io package
nii.eg <- system.file("extdata", "egBrain.nii", package="nifti.io")

# set coordinates (this is a voxel in the head of the
# caudate in the right hemisphere in the example image)
coordinates <- c(20,35,20,1)

# read voxel value at coordinates
voxel.value <- read.nii.voxel(nii.file = nii.eg, coords = coordinates)

nifti.io documentation built on June 8, 2021, 9:06 a.m.