File Exchange

image thumbnail

NRRD Format File Reader

version (2.67 KB) by

Read imagery and metadata from .nrrd medical imaging format files.

11 Ratings



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 (15)

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?


aek (view profile)

lufei wang


Neel (view profile)


rayman (view profile)


rayman (view profile)

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


rayman (view profile)

Sandeep singh

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.

Ilya Belevich

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


Maxime (view profile)


Updated license


Removed "author" info.

MATLAB Release
MATLAB 7.13 (R2011b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today