# Replace UKF modality node with external data

**URL:** <https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288>\
**Category:** Support\
**Tags:** diffusion\
**Created:** [October 4, 2018, 9:43pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288 "2018-10-04T21:43:57Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrjeffs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mrjeffs/32/1185_2.png) [@mrjeffs](https://discourse.slicer.org/u/mrjeffs)\
**Post date:** [October 4, 2018, 9:43pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/1 "2018-10-04T21:43:57Z")

</div>

is there a pythonic way to replace one or more of the scalar values in UKF fiberbundle, eg FA1 or trace1 for example, with external data or better yet a volume node or a multivolume node for a movie preserving spacial registration between vtk and vol?

jeff

---

<div class="post-metadata">

**Author:** ![zhangfanmark](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/zhangfanmark/32/4451_2.png) [@zhangfanmark](https://discourse.slicer.org/u/zhangfanmark)\
**Post date:** [October 5, 2018, 6:22pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/2 "2018-10-05T18:22:24Z")

</div>

Hi Jeff,

You can do this by creating your own extension using Extension Wizard.  
We had a tutorial in the last month at MICCAI for teaching how to build a new extension. You can find the materials online at: [https://projects.iq.harvard.edu/slicerdmri2018](https://projects.iq.harvard.edu/slicerdmri2018)  
The third hands-on tutorial talks about creating extensions. For your problem, the third part “Module: tractography processing” is the most related.

Regards,  
Fan

---

<div class="post-metadata">

**Author:** ![mrjeffs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mrjeffs/32/1185_2.png) [@mrjeffs](https://discourse.slicer.org/u/mrjeffs)\
**Post date:** [October 8, 2018, 9:36pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/3 "2018-10-08T21:36:09Z")

</div>

thanks Fan, i was afraid you’d say build an extension. would love to but not possible in my time frame. jeff

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [October 8, 2018, 10:18pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/4 "2018-10-08T22:18:37Z")

</div>

Hi this is a python module that contains example code. No need to build anything. Using the extension wizard module, you just click some buttons and your new module appears. This takes maybe two minutes. Then in the new module there are buttons to open the code in a text editor and also to reload the code, so it’s easy to play with changing the functionality to do what you want.

---

<div class="post-metadata">

**Author:** ![mrjeffs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mrjeffs/32/1185_2.png) [@mrjeffs](https://discourse.slicer.org/u/mrjeffs)\
**Post date:** [October 18, 2018, 9:33pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/5 "2018-10-18T21:33:54Z")

</div>

hi lauren, ok i’ll bite a little, cause i have a little more time:  
1st question is we have a UKF vtk file and an RAS+ volume in the same space. outside slicer it seems the x  
coordinate on the vtk is revesed or swapped. is that true?  
how would you recommend getting a one to one matching coordinate between the vtk in mm and RAS+  
volume?  
when we do it outside slicer the x values get wrong offsets.  
jeff

---

<div class="post-metadata">

**Author:** ![ljod](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ljod/32/652_2.png) [@ljod](https://discourse.slicer.org/u/ljod)\
**Post date:** [October 18, 2018, 10:13pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/6 "2018-10-18T22:13:31Z")

</div>

You need to use the ijktoRAS transform in Slicer to convert between image and world space (fiber tract) coordinates. There are multiple modules that do this so you can look at the code. There is one module that makes a mask image from fiber tracts, and another that selects fibers based on an image ROI. I’m on the phone now so I don’t have the exact module names but they should be easy to find on the diffusion menu. Please reply if this is not clear and we can take a more specific look tomorrow.

---

<div class="post-metadata">

**Author:** ![mrjeffs](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mrjeffs/32/1185_2.png) [@mrjeffs](https://discourse.slicer.org/u/mrjeffs)\
**Post date:** [October 18, 2018, 10:29pm UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/7 "2018-10-18T22:29:54Z")

</div>

no worries, i will investigate. thanks jeff

---

<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:** [October 19, 2018, 4:44am UTC](https://discourse.slicer.org/t/replace-ukf-modality-node-with-external-data/4288/8 "2018-10-19T04:44:21Z")

</div>

Internally, Slicer stores data in RAS coordinate system (due to historical reasons). However, Slicer writes most data types in LPS coordinate system for maximum compatibility, as LPS is used by DICOM and by most medical image computing software nowadays.

Slicer still writes model nodes in RAS coordinate system instead of LPS, but you can detect this (if you find `SPACE=RAS` in file comment) and compensate for it by applying ijkToRas transform (`diag(-1.0, -1.0, 1.0, 1.0)` transformation matrix) to the point coordinates. Within a year, we will change Slicer so that model files are saved in LPS coordinate system by default (you’ll find `SPACE=LPS` in the header so you will know that no RAS-\>LPS transformation is necessary).
