Connect with users of Wolfram technologies to learn, solve problems and share ideas
Mark as an Answer
3 Total Likes
Follow this post
Share this post:
Import and Export
Does Mathematica support Nearly Raw Raster Data NRRD file fomat?
11 years ago
I am willing to use M's image processing APIs on some MRI scans from
which makes available information in NRRD file format. But I don't see this extension in file formats supported by Mathematica. Is it possible to convert nrrd to some format that Mathematica can work with ?
10 years ago
Also, it's possible to write custom import and export converters that work directly with Import and Export commands. If you want to go to this depth, see
10 years ago
I see your scans from Insight are 2-byte signed integer voxels encoded (within the NRRD file) with GZIP. I'm guessing you just want to get to the raster datacube, and don't care about all the interpolation and sampling management stuff that the NRRD Library provides (
One possible option, that I didn't try because I don't feel like building the "unu" command line utility (
) from source code, is to use unu to convert your NRRD files to VTK format (http://teem.sourceforge.net/nrrd/otherformat.html) which Mathematica does import (see Help on Import). But "unu" conversion support is incomplete, and I don't know how completely M supports VTK.
The other is to take an NRRD file from Insight, then use a hex editor to chop out its header, (chop right before the "1f 8b" gzip hex lead-in) then save-as .gzip. Then use 7-Zip to extract the .gzip file into a binary file. From here, I can read and display in M, as so:
SetDirectory[ <to wherever your file resides>]
grab = BinaryReadList["5074-004-01_10_t2_fit.nrrd", "Integer16", ByteOrdering -> 1];
// This ByteOrdering worked on my Windows PC. Either 1 or -1
192*256*256 // The results of these two lines should agree!
slices= Partition[Partition[grab, 256], 256];
Image[slices[], "Bit16"] // Should immediately display an image slice.
Since Mathematica itself can decode GZIP, the entire process should be able to be able to be automated within M, i.e. no need to externally use a hex editor and GZIP. If you can't take it from here, let me know, and if I'm not too busy, I'll finish a set of Mathematica commands to automate everything (that is, ignoring generality; only specifically handling these 5 files).
10 years ago
@Frank Iannarilli : I am very thankful to you for this suggestion as it worked for me. I was able to generate slices though initially I faced problem because I had to rename my extracted file as *.nrrd and than only M was able to get it.
Your offer to spend time on helping me automate was very kind.
Reply to this discussion
in reply to
Community posts can be styled and formatted using the
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Add a file to this post
Follow this discussion
Be respectful. Review our
to understand your role and responsibilities.
Wolfram|Alpha Notebook Edition
Volume & Site Licensing
Enterprise Private Cloud
Service Plans Benefits
Wolfram Language Documentation
Wolfram Language Introductory Book
Get Started with Wolfram
Fast Introduction for Programmers
Fast Introduction for Math Students
Webinars & Training
Connected Devices Project
Wolfram Data Drop
Wolfram + Raspberry Pi
. All rights reserved.
Learn how »