NII

application/octet-stream

Safe

Magic Bytes

Offset: 344
6E 2B 31 00

The Neuroimaging Informatics Technology Initiative (NIfTI) format is a standardized file type developed by the National Institutes of Health to improve medical imaging data exchange. It is primarily utilized in neurological research and clinical settings to store multidimensional brain scan data produced by MRI and CT machines. Succeeding the older Analyze 7.5 format, NII files are generally considered safe as they store voxel data and metadata rather than executable scripts or active content.

Extension

.nii

MIME Type

application/octet-stream

Byte Offset

344

Risk Level

Safe

Validation Code

How to validate .nii files in Python

Python
def is_nii(file_path: str) -> bool:
    """
    Check if file is a valid NII by magic bytes.
    Signature offset: 344 bytes
    """
    signature = bytes([0x6E, 0x2B, 0x31, 0x00])
    with open(file_path, "rb") as f:
        f.seek(344)
        return f.read(4) == signature

How to validate .nii files in Node.js

Node.js
function isNII(buffer: Buffer): boolean {
  // Signature offset: 344 bytes
  const signature = Buffer.from([0x6E, 0x2B, 0x31, 0x00]);
  if (buffer.length < 348) return false;
  return buffer.subarray(344, 348).equals(signature);
}
Go
func IsNII(data []byte) bool {
    // Signature offset: 344 bytes
    signature := []byte{0x6E, 0x2B, 0x31, 0x00}
    if len(data) < 348 {
        return false
    }
    return bytes.Equal(data[344:348], signature)
}

API Endpoint

GET /api/v1/nii
curl https://filesignature.org/api/v1/nii

Related Formats