Saturday, January 31, 2015

Using pynrrd to read nrrd files into Python

Another in the series of posts about file types! This time, a quick note about importing .nrrd image stacks into Python. Download and unzip pynrrd from here. In a terminal, cd into the directory, and run

python setup.py install

In Python the usage is very straightforward:

import nrrd
frames, options = nrrd.read(fileName)


3 comments:

Unknown said...

I'm getting the following error:

TypeError: coercing to Unicode: need string or buffer, module found

Can you help me? I entered:

frames, options = nrrd.read(nrrd)

Peter Weir said...

Hi Lana,

In order to read a file named 'filename.nrrd' you need to navigate to the directory the file is in, then enter:

import nrrd
frames, options = nrrd.read('filename.nrrd')

Note that in your case you gave the same variable name, nrrd, to both the module you imported and the file name you are trying to open.

Unknown said...

Hello,
The Article on Using pynrrd to read nrrd files into Python is nice.It give detail information about Phython,Thanks for Sharing for Sharing the information about it. data science consulting