What is a NIfTI (.nii) file?
If you have taken part in a brain study, or work with FSL, SPM or FreeSurfer, you have met .nii files. Here is what they are and how to look inside one without installing a toolbox.
One file, one volume
NIfTI (Neuroimaging Informatics Technology Initiative) is a format for MRI data in research. Where a hospital scanner writes DICOM — one file per slice, full of patient details — NIfTI keeps a whole 3D volume in a single file, with only what analysis needs: the size of the grid, the size of each voxel and how the grid sits in space.
A file ends in .nii, or .nii.gz when it is compressed. Some files hold a series of volumes over time (fMRI) or across directions (diffusion imaging) — a 4D file.
NIfTI-1 and NIfTI-2
NIfTI-1 is the common version. NIfTI-2 has the same fields with larger numbers, for very big images. Both start with a fixed header, so a program can tell them apart from the first bytes.
Looking inside one
Drop the file on OsonKit. It reads the header and the first volume in your browser and shows three planes — axial, coronal and sagittal — oriented the way radiologists look at them: the patient’s right on the left of the screen.
- Switch planes with the Plane button; each opens on its middle slice.
- Scroll through slices, drag to change contrast, zoom with Ctrl + wheel.
- The Volume tags show the grid size, voxel size, data type and orientation.
Large files are fine: only the first volume is read, even from a compressed file of several gigabytes. In a 4D file you see that first volume.
Why it matters where you open it
Research data comes with consent forms and data agreements that rarely allow uploading to a random website. A viewer that runs in the browser lets you check a file — the right subject, the right orientation, not corrupted — without the data leaving your machine.
.hdr/.img pairs, stepping through the volumes of a 4D file, and side markers on the image.