Constructors

Properties

auxilaryFile: string = ''

Auxiliary filename (24 chars max)

calibrationMax: number = 0.0

Calibration display range

calibrationMin: number = 0.0

Calibration display range

dataIntercept: number = 0

Data scaling factor: output = input * scl_slope + scl_inter

dataSlope: number = 1.0

Data scaling factor: output = input * scl_slope + scl_inter

datatypeCode: number = 0

Data type code defining data format

DataTypeCode enum

description: string = ''

Free-form data description (80 chars max)

dimInfo: number = 0

MRI slice ordering information

dims: DimensionArray = ...

Array representing dimensions of a NIfTI volume.

Represents the dimensions of a NIfTI volume as an 8-element array where:

  • Index 0: Number of dimensions (rank) of the dataset (1-7)
  • Index 1: Size of dimension 1 (usually x dimension)
  • Index 2: Size of dimension 2 (usually y dimension)
  • Index 3: Size of dimension 3 (usually z dimension)
  • Index 4: Size of dimension 4 (usually time points)
  • Index 5-7: Sizes of optional additional dimensions
// 3D volume of size 256x256x128
const dims: DimensionArray = [3, 256, 256, 128, 1, 1, 1, 1];

// 4D volume (fMRI) with 30 time points
const timeSeries: DimensionArray = [4, 64, 64, 32, 30, 1, 1, 1];
intentCode: number = 0

Specifies the intended meaning of the data

intentName: string = ''

Name or meaning of the data (16 chars max)

intentP1: number = 0

Intent parameters - Used to store statistical parameters Meaning depends on intent_code

intentP2: number = 0
intentP3: number = 0
littleEndian: boolean = false

File encoding.

magic: string = 'ni1'

NIFTI format identifier. Invalid if anything other than "ni1" | "n+1" | "ni2" | "n+2"

numBitsPerVoxel: number = 0

Number of bits per voxel

pixDims: DimensionArray = ...

Pixel dimensions:

  • Index 0: (not used for pixdims)
  • Index 1: Pixel width in dimension 1 (usually x dimension)
  • Index 2: Pixel width in dimension 2 (usually y dimension)
  • Index 3: Pixel width in dimension 3 (usually z dimension)
  • Index 4: Time step duration (TR) for dimension 4
  • Index 5-7: Step sizes for optional additional dimensions
qFormCode: number = 0

Transform codes defining spatial orientation

qOffsetX: number = 0.0
qOffsetY: number = 0.0
qOffsetZ: number = 0.0
quaternB: number = 0.0

Quaternion parameters for spatial transform

quaternC: number = 0.0
quaternD: number = 0.0
sFormCode: number = 0

Transform codes defining spatial orientation

sliceCode: number = 0

Slice timing order code

sliceDuration: number = 0

Time for 1 slice in seconds

sliceEnd: number = 0

Last slice index

sliceStart: number = 0

First slice index

sRowX: [number, number, number, number] = ...

S-Form parameters for spatial transform

sRowY: [number, number, number, number] = ...
sRowZ: [number, number, number, number] = ...
timeOffset: number = 0

Time axis shift

voxOffset: number = 0

Byte offset into the .nii file where pixel data starts

xyztUnits: number = 0

Units of pixdim[1..4] Bits 0-2: spatial units Bits 3-5: temporal units

Accessors

  • get spatialUnits(): number
  • Gets the spatial units code from the combined units value

    Returns number

    Spatial units code extracted using SPATIAL_UNITS_MASK

  • set spatialUnits(value: number): void
  • Sets the spatial units while preserving temporal units

    Parameters

    • value: number

      New spatial units code to set

    Returns void

  • get temporalUnits(): number
  • Gets the temporal units code from the combined units value

    Returns number

    Temporal units code extracted using TEMPORAL_UNITS_MASK

  • set temporalUnits(value: number): void
  • Sets the temporal units while preserving spatial units

    Parameters

    • value: number

      New temporal units code to set

    Returns void

Methods

  • Formats header information in a simple markdown-style format

    Returns string

  • Get the data type as a human readable string

    Returns string

  • Gets human-readable name for NIFTI version

    Returns string

  • Get the QForm transform code as a human readable string

    Returns string

  • Get the SForm transform code as a human readable string

    Returns string

  • Gets a human-readable string representation of the spatial units

    Returns string

    Display name corresponding to the current spatial units code

  • Gets a human-readable string representation of the temporal units

    Returns string

    Display name corresponding to the current temporal units code

  • Serializes the NIFTI-1 header data into a binary format. Creates a new typed array and copies all header fields according to the NIFTI-1 specification, handling endianness conversion.

    Returns Uint8Array<ArrayBufferLike>

    Uint8Array containing the complete NIFTI-1 header (348 bytes)

  • Serializes the NIFTI-2 header data into a binary format. Creates a new typed array and copies all header fields according to the NIFTI-2 specification, handling endianness conversion.

    Returns ArrayBuffer

    Uint8Array containing the complete NIFTI-1 header (540 bytes)

  • Parses a NIFTI header from a DataView based on header version information.

    Parameters

    • view: DataView<ArrayBufferLike>

      DataView containing the NIFTI header data

    • peekInfo: NiftiHeaderPeekInfo

      Header version and endianness information from peekVersion

    Returns NiftiHeader

    Parsed NiftiHeader object

  • Parses a NIFTI-1 format header from a DataView.

    Parameters

    • view: DataView<ArrayBufferLike>

      DataView containing the NIFTI header data

    • OptionallittleEndian: boolean

      Whether to read values as little-endian (from peekNiftiHeader)

    Returns NiftiHeader

    A NiftiHeader object containing the parsed header fields

    https://nifti.nimh.nih.gov/nifti-1/ for header specification

  • Parses a NIFTI-2 format header from a DataView.

    Parameters

    • view: DataView<ArrayBufferLike>

      DataView containing the NIFTI header data

    • OptionallittleEndian: boolean

      Whether to read values as little-endian (from peekVersion)

    Returns NiftiHeader

    A NiftiHeader object containing the parsed header fields

    https://nifti.nimh.nih.gov/nifti-2/ for header specification

  • Peek at first 4 bytes of header to determine nifti version and endianness. Returns undefined if not a nifti header.

    Parameters

    • view: DataView<ArrayBufferLike>

    Returns undefined | NiftiHeaderPeekInfo