Learn R Programming

RNifti (version 1.7.0)

extensions: NIfTI extensions

Description

The NIfTI-1 and NIfTI-2 formats have a simple extension mechanism that allows additional metadata to be stored with their headers. The format of this extension data is unspecified by the NIfTI standard, but extension codes indicate what type of information is present. These functions provide access to this extension metadata.

Usage

extensions(image)

extension(image, code, mode = c("raw", "character", "numeric", "double", "integer", "logical", "complex"), ..., simplify = TRUE)

extensions(image) <- value

extension(image, code) <- value

Value

For extensions, a list of raw vectors containing the bytes stored in each available header. For extension, a list of vector of values, converted to the required mode, for the extension code specified. If the extension code is not used in the image, the return value is NULL. The replacement forms return the modified image.

Arguments

image

An image, in any acceptable form (see asNifti).

code

Integer value, expression or string specifying which extension code is required.

mode

The required mode of the extracted data.

...

Additional arguments to readBin.

simplify

Logical value. If TRUE, the default, a single extension will be returned as a vector; otherwise a list is always returned.

value

New value for the extension(s).

Author

Jon Clayden <code@clayden.org>

Details

The plural version, extensions, extracts or replaces all extensions at once. The retrieval form returns a list of raw vectors, each with the corresponding code in an attribute, and the replacement form accepts a list of atomic vectors with code attributes, or NULL, which removes all extensions. The singular version, extension, gets all extensions with the specified code, or appends an extension with that code. Valid extension codes are stored in the ExtensionCodes vector.

NIfTI extensions are stored as a simple, unstructured byte stream, which is naturally represented in R as a vector of mode "raw". However, these functions will perform some conversion to and from other atomic types for convenience. The NIfTI standard makes no guarantees about byte order within the data stream, but the endian argument to readBin can be passed through when converting to a non-raw type.

See Also

ExtensionCodes for the valid extension codes.