Learn R Programming

neuroim2 (version 0.8.5)

NiftiExtension: Create a NIfTI Extension

Description

Constructor function for creating a NiftiExtension-class object with proper padding to ensure the size is a multiple of 16 bytes.

Usage

NiftiExtension(ecode, data)

Value

A NiftiExtension-class object.

Arguments

ecode

Integer extension code. See NiftiExtensionCodes for known codes. Common values: 4 (AFNI), 6 (comment), 32 (CIFTI).

data

The extension data. Can be:

  • A character string (will be converted to raw with null terminator)

  • A raw vector (used as-is)

Details

The function automatically handles padding to ensure the total extension size (esize) is a multiple of 16 bytes, as required by the NIfTI specification. The esize includes the 8-byte header (esize + ecode fields).

See Also

NiftiExtension-class, NiftiExtensionCodes

Examples

Run this code
# Create a comment extension
ext <- NiftiExtension(ecode = 6L, data = "This is a comment")
ext@ecode
ext@esize

# Create an AFNI extension with XML data
afni_xml <- ''
afni_ext <- NiftiExtension(ecode = 4L, data = afni_xml)

Run the code above in your browser using DataLab