# Extraction 3\*3 Matrix from DTI Image

**URL:** <https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149>\
**Category:** Support\
**Created:** [April 27, 2022, 2:00pm UTC](https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149 "2022-04-27T14:00:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haytham](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Haytham](https://discourse.slicer.org/u/Haytham)\
**Post date:** [April 27, 2022, 2:00pm UTC](https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149/1 "2022-04-27T14:00:41Z")

</div>

Hi all,

I have a set of patients’ dti images. How do I extract the 3x3 diffusion tensor matrices per each voxel in C++ using VTK?

thank you

---

<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:** [April 27, 2022, 2:30pm UTC](https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149/2 "2022-04-27T14:30:40Z")

</div>

You can look at the [`vtkDiffusionTensorMathematics`](https://github.com/Slicer/Slicer/blob/40087afee09fa4779e1b809423d927add1904cb7/Libs/vtkTeem/vtkDiffusionTensorMathematics.cxx) source code for examples.

---

<div class="post-metadata">

**Author:** ![Haytham](https://avatars.discourse-cdn.com/v4/letter/h/c67d28/32.png) [@Haytham](https://discourse.slicer.org/u/Haytham)\
**Post date:** [April 29, 2022, 7:51am UTC](https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149/3 "2022-04-29T07:51:20Z")

</div>

Hello,  
thank you for the responce.  
I have a vtkMRMLDiffusionTensorVolumeDisplayNode object, and i need to extract the 3\*3 tensor matrix per each voxel.

after that, i can use the vtkDiffusionTensorMathematics to calculate the eigenvalues.  
how do I extract for each voxel, the diffusion tensor matrix from a vtkMRMLDiffusionTensorVolumeDisplayNode object?

thank you

---

<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:** [April 29, 2022, 12:15pm UTC](https://discourse.slicer.org/t/extraction-3-3-matrix-from-dti-image/23149/4 "2022-04-29T12:15:59Z")

</div>

You’ll want the `vtkMRMLDiffusionTensorVolumeNode`, instance (with the image data) not the display node (which stores display parameters).

Once you have that, the `vtkImageData` has the actual array of tensor values and you can access like in the `vtkDiffusionTensorMathematics` or like this (in python, but could be converted to C++).

> <https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/util.py#L1610>
