Mathematica Student Edition
Mathematica Home Edition
Computable Document Format (CDF)
Aerospace Engineering & Defense
Biotechnology & Medicine
Finance, Statistics & Business Analysis
Financial Engineering & Mathematics
Financial Risk Management
Software Engineering & Content Delivery
Authoring & Publishing
Social & Behavioral Sciences
Design, Arts & Entertainment
Game Design, Special Effects & Generative Art
STEM Education Initiative
Community & Technical College Education
Primary & Secondary Education
Computable Document Format (CDF)
High-Performance & Parallel Computing (HPC)
See Also: Technology Guide
Other Ways to Buy
Volume & Site Licensing
Does My Site Have a License?
Wolfram User Portal
About Wolfram Research
Stephen Wolfram's Home Page
Wolfram Functions Site
More Info >>
Mark as an Answer
Does Mathematica support Nearly Raw Raster Data NRRD file fomat?
Import and Export
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 ?
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).
@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.
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