[Insight-developers] Nrrd format changes

Gordon Kindlmann gk at bwh.harvard.edu
Sat Jan 14 18:25:07 EST 2006


hello all,

okay, sorry for the long email, but I wanted to be as precise as  
possible about all this.

The only changes in the NRRD format in that past, and the only ones I  
will allow in the future, are additions of new fields to the header,  
accompanied by incrementing the magic, which in turn causes old  
readers to fail on new files.  This effect is completely intended  
because old readers should not be allowed to merrily read in files  
for which they lack the means of interpreting and representing the  
information in the file.

Because the only changes are additions to the set of possible fields,  
NRRD files are always and absolutely backwards compatible.  A reader  
that can read NRRD0005 files can read NRRD0004 files, and NRRD0003  
files, and so on.  I completely agree with Bill's statement that  
backwards compatibility is a pre-requisite, especially when it comes  
to things like file formats, which can live on read-only media.

The change from NRRD0004 to NRRD0005 was the addition of a  
"measurement frame" field, which is a necessary part of fully  
representing information like vectors and tensors, wherein  
coefficients are measured with respect to some set of basis vectors.   
The measurement frame describes the mapping from the vector/tensor  
coordinate frame, to the image orientation coordinate frame (such as  
DICOM's LPS).  The measurement frame is documented here:
http://teem.sourceforge.net/nrrd/format.html#measurementframe

So, as far as reading an array of values from a NRRD file into ITK,  
there is no problem whatsoever.  Specifically, the NrrdIO in ITK 2.6  
can read the NRRDs previously readable in ITK 2.4.

But, what you do with the facilities provided by the NRRD format is  
where things get more complicated.

Ever since NRRD0002, there has been the ability to store key/value  
pairs in NRRD files, which is essentially a simple version of ITK's  
MetaData dictionary (in NRRD both the keys and the values are simply  
strings).  It is with these key/value pairs that certain application- 
specification information about diffusion-weighted MRI can be stored  
in NRRD files.

A convention was developed by me and others on how to use key/value  
pairs to store DWI-specific information (and on read, ITK puts NRRD  
key/value pairs into the MetaData dictionary).  As of last week's NA- 
MIC All Hands Meeting in Salt Lake, the updated information is  
documented here:
http://www.na-mic.org/Wiki/index.php/NAMIC_Wiki:DTI:Nrrd_format
and I'm continuing to flesh out that page as time permits.

An old version of this information resided here:
http://teem.sourceforge.net/nrrd/namic-format.html
but that page should never have been created outside the Wiki-verse,  
and so it long outlived its relevance.  My bad.

This key/value pair convention is not really a file format- it was  
just a provisional convention.  Indeed, the first pass at that  
convention was broken, because it failed to encode the scalar b- 
value.  I believe the right thing to do is fix the convention in such  
a way that breaks old readers, which is what I did.

Anyway: the point is that the software change in response to the  
change in the key/value pair convention is *not* at the level of the  
NRRD reader.  It is at the level of whatever pairs and process the  
optional meta information that accompanies images (such as the  
MetaData dictionary).

Gordon

On Jan 10, 2006, at 1:19 PM, Karthik Krishnan wrote:

> Yes, it was there in 1 release - 2.4 and changed into release 2.6.
> (Maybe I am wrong.) . Do you need me to patch any releases ? Or add  
> some
> information into the Wiki to save somebody possible pain ?
>
> Aside from the file format changes and related pain, I think its a  
> good
> thing cause the previous way of iterating through volumes could have
> been rather slow.
>
> Nrrd's rather convenient to represent DWI volumes. Its got tags to
> represent DWI gradients as key value tags, store multiple gradients  
> and
> the B0 in one file. It can also store masked Diffusion Tensor volumes
> and has some functionality to account for cases where the tensor
> measurement frame may be different.
>
> Of course Gordon knows better.
>
> Thanks
> karthik
>
>
> On Tue, 2006-01-10 at 14:36 -0500, Lorensen, William E (GE, Research)
> wrote:
>> Was the old header format in an ITK release? If so, is there a way  
>> to support the old and new versions? We must be considerate of our  
>> user base...
>>
>> Bill
>>
>> -----Original Message-----
>> From: insight-developers-bounces+lorensen=crd.ge.com at itk.org
>> [mailto:insight-developers-bounces+lorensen=crd.ge.com at itk.org]On  
>> Behalf
>> Of Karthik Krishnan
>> Sent: Tuesday, January 10, 2006 1:22 PM
>> To: Gordon Kindlmann
>> Cc: Insight-developers (E-mail)
>> Subject: [Insight-developers] Nrrd format changes
>>
>>
>> Hi Gordon,
>>
>> I have some old DWI headers for Nrrd. There were some nrrd format
>> changes, probably for more efficient iteration in terms of reading  
>> each
>> gradient image etc.. Do you have a quick and dirty program that does
>> this re-ordering ? I presume you've had the need to do this  
>> yourself. If
>> you don't that's ok, its an easy thing thing to do.
>>
>> Could you please tell me what the new header is supposed to look  
>> like ?
>> Here is the old header.
>>
>> ----------------------
>> NRRD0004
>> content: dwi
>> type: short
>> dimension: 4
>> space: right-anterior-superior
>> sizes: 256 256 50 31
>> thicknesses:  NaN  NaN 4  NaN
>> space directions: (0.9375,0,0) (0,0.9375,0) (0,0,2.5) none
>> centerings: cell cell cell none
>> kinds: space space space list
>> endian: little
>> encoding: raw
>> space units: "mm" "mm" "mm"
>> space origin: (0, 0, 0)
>> data file: xt_dwi.img
>> modality:=DW
>> DW_gradient_001:=-1.000000 	 0.000000 	 0.000000
>> DW_gradient_002:=-0.166000 	 0.986000 	 0.000000
>> DW_gradient_003:=0.110000 	 0.664000 	 0.740000
>> DW_gradient_004:=-0.901000 	 -0.419000 	 -0.110000
>> DW_gradient_005:=0.169000 	 -0.601000 	 0.781000
>> DW_gradient_006:=0.815000 	 -0.386000 	 0.433000
>> DW_gradient_007:=-0.656000 	 0.366000 	 0.660000
>> DW_gradient_008:=-0.582000 	 0.800000 	 0.143000
>> DW_gradient_009:=-0.900000 	 0.259000 	 0.350000
>> DW_gradient_010:=-0.693000 	 -0.698000 	 0.178000
>> DW_gradient_011:=-0.357000 	 -0.924000 	 -0.140000
>> DW_gradient_012:=-0.543000 	 -0.488000 	 -0.683000
>> DW_gradient_013:=0.525000 	 -0.396000 	 0.753000
>> DW_gradient_014:=0.639000 	 0.689000 	 0.341000
>> DW_gradient_015:=0.330000 	 -0.013000 	 -0.944000
>> DW_gradient_016:=0.524000 	 -0.783000 	 0.335000
>> DW_gradient_017:=-0.609000 	 -0.065000 	 -0.791000
>> DW_gradient_018:=-0.220000 	 -0.233000 	 -0.947000
>> DW_gradient_019:=0.004000 	 -0.910000 	 -0.415000
>> DW_gradient_020:=0.511000 	 0.627000 	 -0.589000
>> DW_gradient_021:=-0.414000 	 0.737000 	 0.535000
>> DW_gradient_022:=0.679000 	 0.139000 	 -0.721000
>> DW_gradient_023:=-0.884000 	 -0.296000 	 0.362000
>> DW_gradient_024:=-0.262000 	 0.432000 	 0.863000
>> DW_gradient_025:=-0.088000 	 0.185000 	 -0.979000
>> DW_gradient_026:=-0.294000 	 -0.907000 	 0.302000
>> DW_gradient_027:=-0.887000 	 -0.089000 	 -0.453000
>> DW_gradient_028:=-0.257000 	 -0.443000 	 0.859000
>> DW_gradient_029:=-0.086000 	 0.867000 	 -0.491000
>> DW_gradient_030:=-0.863000 	 0.504000 	 -0.025000
>> -----------------------------------
>>
>> I presume the image dwi.img should be re-ordered so that
>> sizes: 31 256 256 50
>> instead of
>> sizes: 256 256 50 31
>>
>> so that the gradients vary the fastest.
>>
>> Is that the only change ?
>>
>> Thanks
>> karthik
>>
>>
>>
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>



More information about the Insight-developers mailing list