# Trying to create custom DTI volume

**URL:** <https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318>\
**Category:** Development\
**Tags:** diffusion, mri\
**Created:** [April 25, 2021, 11:22pm UTC](https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318 "2021-04-25T23:22:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haz\_lanz](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@haz\_lanz](https://discourse.slicer.org/u/haz_lanz)\
**Post date:** [April 25, 2021, 11:22pm UTC](https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318/1 "2021-04-25T23:22:53Z")

</div>

Hello,

I am trying to use the diffusion tractography capabilities of 3DSlicer to visualise some data I have collected from my PhD research. It is similar to diffusion weighted MRI but does not produce diffusion weighted images. My data is processed in such a way that I end up with vectors at various coordinates in 3D space (these vectors represent the directions of collagen fibre tracts).

Essentially what I would like to do is jump into the “diffusion mri analysis pipeline” so I start with a custom DTI volume in slicer. i.e. I would like to generate a custom version of slide 42/107 from: [here](https://spujol.github.io/SlicerDiffusionMRITutorial/SlicerDiffusionMRITutorial_SoniaPujol.pdf) .

My current approach has been to try and create a new volume following the process [here](https://www.slicer.org/wiki/Documentation/4.10/ScriptRepository#Create_a_new_volume) but I cannot seem to find a way to input a custom tensor field. Does anyone know if this is possible or whether there is a better way of achieving what I’m trying to do?

Thank you, please let me know if anything needs clarifying,

Harry

---

<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 26, 2021, 3:11pm UTC](https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318/2 "2021-04-26T15:11:10Z")

</div>

You need to be sure to make a `vtkMRMLDiffusionTensorVolumeNode` and manipulate the array as described [here](https://www.slicer.org/wiki/Documentation/4.10/ScriptRepository#Access_values_in_a_DTI_tensor_volume). You’ll need to determine the best method to estimate tensors from the vectors you have.

---

<div class="post-metadata">

**Author:** ![haz\_lanz](https://avatars.discourse-cdn.com/v4/letter/h/57b2e6/32.png) [@haz\_lanz](https://discourse.slicer.org/u/haz_lanz)\
**Post date:** [April 26, 2021, 4:19pm UTC](https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318/3 "2021-04-26T16:19:15Z")

</div>

Thank you, from a lot of fiddling I have managed to do it by creating a vtkFloatArray and adding it to imageData with the line `imageData.GetPointData().SetTensors(tensorarray)` and then `volumeNode.SetAndObserveImageData(imageData)`. With most of the other steps the same as in the documentation you linked.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 26, 2021, 11:26pm UTC](https://discourse.slicer.org/t/trying-to-create-custom-dti-volume/17318/4 "2021-04-26T23:26:51Z")

</div>

You can also visualize vector fields very nicely, without converting them to tensors. All you need to do is to select Description-\>Transform in the “Add data” window. You can then use the field using [Transforms display infrastructure](https://slicer.readthedocs.io/en/latest/user_guide/modules/transforms.html#display). You can also use the vector field to warp any nodes, invert the field, fit b-spline to it, etc.
