File Exchange

image thumbnail

NRRD Format File Reader

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

44 Downloads

Updated 01 Sep 2016

View Version History

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.

Cite As

Jeff Mather (2020). NRRD Format File Reader (https://www.mathworks.com/matlabcentral/fileexchange/34653-nrrd-format-file-reader), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (20)

sorly

Manuel Rausch

When reading a file exported through Slicer I get following error message:
"Error using nrrdread (line 76)
Missing required metadata fields."

Christopher Mezias

I get the error: Unable to resolve the name Ref20131120pt14pl2.nrrd.
This is even though I copied and pasted the name and I've put the file into the same matlab path as the function. Do you know how to resolve this? Thanks!

Stephen Lamb

Steven Lewis

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,'[')) = '';
end
if (contains(field, ']'))
field (strfind(field,']')) = '';
end

Is this part of the *.nrrd format?

aek

lufei wang

Neel

rayman

rayman

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

rayman

Kalyan Sundar

sandeep singh

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

Ibraheem Al-Dhamari

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

Ibraheem Al-Dhamari

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

Ilya Belevich

Nima Tajbakhsh

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'}."

fclose(fidTmp);
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

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!