How can I read NIfTI-1 files (.nii extension) in Mathematica? Are there existing tools for this?

• Expecting the answer ^^; +1 – Sektor Aug 27 '15 at 12:52
• @Sektor Sorry, no answer yet. I'm looking at Neurotica but it doesn't handle my files. I might end up doing it from scratch. Either way, I thought it would be a good idea to have a question on this. – Szabolcs Aug 27 '15 at 12:57
• Well, I was wrong, it does read my files correctly. This looks to be a large package with some very complete bits. Implementing the NifTI importer must have taken quite a bit of time. – Szabolcs Aug 27 '15 at 13:17

The Neurotica package by Noah Benson has support for importing NifTI files. It registers the "NIFTI" import format, to make importing as convenient as Import["somefile.nii", "NIFTI"].

However, by default this returns an MRImage3D object, which is specific to the Neurotica package and doesn't support arbitrary dimensional data. If the data is high dimensional, the import attempt might result in an error. The fix is to use

Import["somefile.nii", {"NIFTI", "Voxels"}]


• "Header" gives the metadata in the header as a rule list.
• "Metainformation" is the same as the above, but the output is in the {"Header" -> ...} format.
• "Data" gives {"Header" -> ..., "Voxels" -> ...}
• "Voxels" gives the raw data from the file as a multidimensional packed array.