File Exchange

image thumbnail

NRRD Format File Reader

version (2.67 KB) by Jeff Mather
Read imagery and metadata from .nrrd medical imaging format files.


Updated 01 Sep 2016

View License

Read volumetric data from the NRRD (.nrrd) medical imagery file format. This function returns the image volume and all of the metadata stored in the file.

Comments and Ratings (17)

I am having a difficult time unzipping this file with MATLAB or 7-zip.

Kannan U V

I had this problem when attributes were embedded in the dim[0], dim[1], dim[2] field name value fields and the script didn't like it. The nrrd format was created using a standard ITK writer (in c3d toolbox).
So I added few lines
if (contains(field, '['))
field (strfind(field,'[')) = '';
if (contains(field, ']'))
field (strfind(field,']')) = '';

Is this part of the *.nrrd format?


lufei wang




clicked by accident, do not know how to delete it, sorry!


how to use this please tell me should i unzip and add folder where i have installed my matlab

Voxels values are not correct. Voxels values in Slicer3D and MITK are the same but in matlab are different.

very useful,
it would be nice if the numeric meta data extracted as numbers instead of characters.

Good job! One limitation I encountered is that some temporary files that are created during the code execution are not deleted at the end. It can be a serious problem in the case of medical images where each temporary file is about 200MB. To fix this, I commented out the following line of the code

cleaner = onCleanup(@() fclose(fidTmp));

and added the followings at the end of "case {'gzip', 'gz'}."

system(['del ' tmpFile])
system(['del ' tmpBase])

Roi mehrez

you might have a problam in the fopen. fileID in the function readData point the nhdr and the data file



Updated license

Removed "author" info.

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux