# How to convert DTI tensor nhdr file from NRRD0004 to NRRD0005

**URL:** <https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016>\
**Category:** Support\
**Created:** [August 15, 2020, 9:11pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016 "2020-08-15T21:11:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 15, 2020, 9:11pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/1 "2020-08-15T21:11:35Z")

</div>

Dear all,

I wonder if there is any way to convert DTI tensor file in .nhdr format from NRRD0004 to NRRD0005?  
As in the header file .nhdr for tensor,  
NRRD0004 has a line with six components, e.g. _sizes: 6 181 216 179_, while  
NRRD0005 has a line with nine components, e.g. _sizes: 9 181 216 179_

Strangely, earlier when I saved DTI tensor into .nhdr, it wrote a .nhdr file with 6 components (NRRD0004 ), but now always writes into with 9 components (NRRD0005), though I seemed to do exactly the same steps. Any way to convert between both using Slicer? Thanks a lot for your attention.

Best regards, Xiaogai

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 15, 2020, 9:21pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/2 "2020-08-15T21:21:34Z")

</div>

Probably your version 4 file uses `3D-symmetric-matrix` while the version 5 uses `3D-matrix`. See the [definitions here](http://teem.sourceforge.net/nrrd/format.html). Either should be fine for DTI.

If you really need to convert, [the unu command](http://teem.sourceforge.net/unrrdu/) should be easy to use.

---

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 15, 2020, 9:46pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/3 "2020-08-15T21:46:22Z")

</div>

Thanks a lot! Exactly as you said, both are fine for DTI, and only differ `3D-symmetric-matrix` and `3D-matrix`.

I just checked `unu command`, seems `unu save` or ` unu convert` may work, but none seem to have option to specify the conversion. Will be really appreciated if you have insights on what command to use. Thank you very much.

---

<div class="post-metadata">

**Author:** ![Xiaogai\_Li](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/xiaogai_li/32/4401_2.png) [@Xiaogai\_Li](https://discourse.slicer.org/u/Xiaogai_Li)\
**Post date:** [August 15, 2020, 9:57pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/4 "2020-08-15T21:57:25Z")

</div>

Or if there is any way to specify in Slicer 3D to save DTI files into `3D-symmetric-matrix` (version 4) format?

I should have mentioned that the problem occurs when I have used module `Resample DTI Volume` in Slicer, then when saving to .nhdr always ended in version 5. Thanks!

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 16, 2020, 8:59pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/5 "2020-08-16T20:59:11Z")

</div>

Hmm, good question - I don’t know if there’s anyway to do that without writing a C or C++ program. All the utilities in the teem suite are pretty powerful but I don’t recall anything that handles that particular operation. Good luck!

---

<div class="post-metadata">

**Author:** ![Chris\_Rorden](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/chris_rorden/32/4073_2.png) [@Chris\_Rorden](https://discourse.slicer.org/u/Chris_Rorden)\
**Post date:** [September 15, 2020, 2:12pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/6 "2020-09-15T14:12:28Z")

</div>

Is there any reason that Slicer changed from the 6 component 3D-symmetric-matrix to the 3D-matrix? The 9 volume stores  
XX XY XZ XY YY YZ XZ YZ ZZ  
while the 6 component format removes the redundant volumes (here upper triangle):  
XX XY XZ YY YZ ZZ  
So the resulting file size and memory demands, cache penalties, etc. are all limitations of the 9 component storage. Furthermore, the compact representation would ease [interoperability](http://dti-tk.sourceforge.net/pmwiki/pmwiki.php?n=Documentation.Interoperability) with other tools.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 15, 2020, 7:32pm UTC](https://discourse.slicer.org/t/how-to-convert-dti-tensor-nhdr-file-from-nrrd0004-to-nrrd0005/13016/7 "2020-09-15T19:32:05Z")

</div>

> [@Chris\_Rorden](#):
>
> Is there any reason that Slicer changed from the 6 component 3D-symmetric-matrix to the 3D-matrix?

I don’t recall if it was a deliberate choice. Maybe @ljod knows? I agree that taking advantage of the symmetry is a good thing in general.
