Classes

FILE

Methods

(static) load_untouch0_nii_hdr(machine, data) → {Object}

Loads the header of a NIfTI file.

This function initializes a FILE object to read the binary data of a NIfTI header. It then extracts the header information and returns it. This function does not read anything regarding the transformation.

Parameters:
NameTypeDescription
machine'ieee-le' | 'ieee-be'

Byte order used by the machine ('ieee-le' for little-endian, 'ieee-be' for big-endian).

dataArrayBuffer

The binary data of the NIfTI file.

See
Returns:

The parsed NIfTI header object.

Type: 
Object

(static) load_untouch_nii(filename, data, img_idxopt, dim5_idxopt, dim6_idxopt, dim7_idxopt, old_RGBopt, slice_idxopt) → {Object}

Load a NIfTI or ANALYZE dataset without applying affine transformations or voxel intensity scaling. This function preserves the original NIfTI header and data untouched.

Parameters:
NameTypeAttributesDefaultDescription
filenamestring

The NIfTI or ANALYZE file name (with extension).

dataArrayBuffer

The raw content of the file.

img_idxArray.<number><optional>
[]

A numerical array of image volume indices. Only the specified volumes will be loaded. Default is to load all available volumes.

dim5_idxArray.<number><optional>
[]

A numerical array of 5th dimension indices. Default is to load all available slices.

dim6_idxArray.<number><optional>
[]

A numerical array of 6th dimension indices. Default is to load all available slices.

dim7_idxArray.<number><optional>
[]

A numerical array of 7th dimension indices. Default is to load all available slices.

old_RGB0 | 1<optional>
0

A flag to handle old RGB format. Set to 1 if the image uses the old RGB format (Analyze 6.0), otherwise set to 0 (default).

slice_idxArray.<number><optional>
[]

A numerical array of image slice indices. Default is to load all available slices.

Returns:

nii - The NIfTI object containing the header and image data.

Type: 
Object

(static) load_untouch_nii_hdr(machine, data) → {Object}

Loads the header of a NIfTI file.

This function initializes a FILE object to read the binary data of a NIfTI header. It then extracts the header information and returns it. If the magic field in the header is not 'n+1' or 'ni1', qform_code and sform_code are set to 0.

Parameters:
NameTypeDescription
machine'ieee-le' | 'ieee-be'

Byte order used by the machine ('ieee-le' for little-endian, 'ieee-be' for big-endian).

dataArrayBuffer

The binary data of the NIfTI file.

See
Returns:

The parsed NIfTI header object.

Type: 
Object

(static) nifti_anatomical_convention(nii) → {Object}

Automatically flips NIFTI image data to have the right side on the right. Only works on 3D black-and-white NIfTI images. It does not work on colored images, images with imaginary numbers, or 4D images.

Parameters:
NameTypeDescription
niiObject

NIFTI file data loaded using load_nifti.js or load_untouch_nifti.js.

Properties
NameTypeDescription
hdrObject

Struct containing NIFTI header fields.

imgArray

3D matrix representing the NIFTI image data.

Returns:

The modified NIFTI object with flipped header and data.

Type: 
Object
Example
const flippedNii = open_nii_anatomical_convention(nii);