NRRD vs NIFTI: which one to choose?

This is a question for users of those two formats: if you had to set up a workflow where you need to store your medical images imported from DICOM in a single file, which would you choose between NRRD and NIFTI (or another?) and why?

Are there clear advantages known for each of those formats versus the other? Has anyone done any benchmarks to compare size, IO speed?

The only knowledge I have is that NIFTI is an upgrade from ANALYZE, and NIFTI itself has two versions where the image orientation can be stored in multiple ways, which aren’t always straightforward: https://brainder.org/2012/09/23/the-nifti-file-format/

Thank you

While DICOM is very complicated, both NRRD and NIfTI are very simple. From my perspective, they fill a very similar niche and are of similar complexity. I would choose the one that is used most in your domain.

NIfTI is very explicit, with a fixed 348-byte binary header. This makes it very simple to read. However, it is a bit harder to write, because it demands the order of image data dimensions (e.g. a Red, Green, Blue image MUST be saved RGBRGBRGB…), the first three dimensions must be spatial the fourth temporal and dimensions 5,6,7 are up to the user.

NRRD is text based, so it is human readable. It is easy to write, as you can easily describe whatever order you want to your dimensions. The trade off is that it is harder to create a reader, as you need to juggle the image dimensions. What is elegant about NRRD is that the flexibility of the header allows you to create a tiny header that describes a complicated image in a different format, for example you could write a NRRD-format nhdr file that describes most uncompressed DICOM images allowing easy support for DICOM.

With respect to speed, both are very fast to parse, and the small cost of the header is swamped for larger images. Without a doubt, NIfTI being all binary is faster, but in real world cases the amount is negligible. Further, since the NIfTI format is so constrained, many users add a BIDS JSON text sidecar to store extra information, and reading this incurs the same penalty as the text header in NRRD.

In my experience, Slicer supports both thoroughly, so you might want to look at other tools in your toolchain to decide.

2 Likes

Nifti format contains a lot of neuroimaging-specific details and it is quite rigid (fixed, binary header; inflexible dimensions). This makes nifti a good file format for neuroimaging but not well suited as a general image file format.

Thank you @Chris_Rorden and @lassoan.

I’d add another nice thing about nrrd is the unu command, which can be very convenient for manipulating datasets. I don’t know if there’s anything similar for nifti. I’d generally use python to do most of what unu does, but for certain circumstances it’s a good tool.