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

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

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).

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.

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.

Author(s)

Jon Clayden <code@clayden.org>

See Also

ExtensionCodes for the valid extension codes.


RNifti

Fast R and C++ Access to NIfTI Images

v1.3.0
GPL-2
Authors
Jon Clayden [cre, aut] (<https://orcid.org/0000-0002-6608-0619>), Bob Cox [aut], Mark Jenkinson [aut], Matt Hall [ctb], Rick Reynolds [ctb], Kate Fissell [ctb], Jean-loup Gailly [cph], Mark Adler [cph]
Initial release
2020-12-04

We don't support your browser anymore

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