pynrrd update: write support

Today I pushed an updated version of pynrrd to github. This update was triggered by an e-mail from David Hammond. It was already pretty cool to hear that somebody found pynrrd useful, but on top of that David contributed back by adding support for writing nrrd files!

His contribution inspired me to have a careful look at my original pynrrd code and I realized there was room for improvement and simplification. The biggest change is the move from a class-based approach to a more functional style. Before, reading a nrrd file would look like this:

from nrrd import Nrrd
nrrdfile = Nrrd('testfile.nrrd')
print nrrdfile.data.shape
print nrrdfile.fields

Now, in the new version, this is changed to

import nrrd
data, options = nrrd.read('testfile.nrrd')
print data.shape
print options

I feel this is much simpler, and in addition this change makes reading and writing nrrd files more symmetric. All-in-all this has been a fun exercise in simplification, which hopefully can be useful to others.