# Load DSI Studio (\*.trk.gz) or TrackVis (\*.trk) tracks in Slicer

**URL:** <https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356>\
**Category:** SlicerDMRI\
**Tags:** diffusion, dipy\
**Created:** [November 2, 2017, 6:27pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356 "2017-11-02T18:27:12Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [November 2, 2017, 6:27pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/1 "2017-11-02T18:27:12Z")

</div>

Does anyone have experience converting and then loading fibertrack generated by these software into 3D Slicer ?

Is there any recommended pathway to export tracts and import them into Slicer ?

We are thinking of these approaches:

- improve export to vtk (fiberbundle) in software like DSI Studio.
- add IO support for `.trk.gz`, `.trk` …

Thanks for your input

References:

- format `.trk.gz`: [http://dsi-studio.labsolver.org/](http://dsi-studio.labsolver.org/) / [Subpages - DSI Studio—A Tractography Software Tool](http://dsi-studio.labsolver.org/system/app/pages/subPages?path=/Manual)
- format `.trk`: [http://www.trackvis.org/](http://www.trackvis.org/) / [TrackVis :: Documentation](http://www.trackvis.org/docs/?subsect=fileformat)
- vtk fiberbundle is supported by SlicerDMRI thanks to [vtkMRMLFiberBundleStorageNode](https://github.com/SlicerDMRI/SlicerDMRI/blob/master/Modules/Loadable/TractographyDisplay/MRML/vtkMRMLFiberBundleStorageNode.h) and [vtkMRMLFiberBundleNode](https://github.com/SlicerDMRI/SlicerDMRI/blob/master/Modules/Loadable/TractographyDisplay/MRML/vtkMRMLFiberBundleNode.h)

Cc: @Johan_Andruejol @fbudin69500

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [November 2, 2017, 11:51pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/2 "2017-11-02T23:51:21Z")

</div>

I have code to load TrackVis-style trk files. It can create Slicer-style vtkPolyData in memory so would be pretty simple to hook it up as another i/o option. It uses C++11 features, but it’s only a few hundred lines so could be modified … unless we’re flipping switch soon! 😜

Have never used DSI Studio data though.

---

<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:** [November 4, 2017, 2:39pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/3 "2017-11-04T14:39:43Z")

</div>

@jcfr When do we plan to switch to c++11? I have trouble building Cleaver on Linux and Mac without c++11, too.

---

<div class="post-metadata">

**Author:** ![Vinny](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vinny/32/7052_2.png) [@Vinny](https://discourse.slicer.org/u/Vinny)\
**Post date:** [January 26, 2018, 1:10am UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/4 "2018-01-26T01:10:55Z")

</div>

I have been generating .trk streamlines in Dipy and would like to export them to 3d Slicer for visualization and overlay onto images. How can .trk files be imported into 3d Slicer? Thanks

---

<div class="post-metadata">

**Author:** ![jamesjcook](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesjcook/32/1177_2.png) [@jamesjcook](https://discourse.slicer.org/u/jamesjcook)\
**Post date:** [February 7, 2018, 9:13pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/5 "2018-02-07T21:13:53Z")

</div>

Building on the work of @ihnorton, @Johan_Andruejol and @jcfr solved this for us, the github for the code is here.

> **[GitHub - InteractivePublishing/TrackConverterCLI: Convert trk(.gz)? files to...](https://github.com/InteractivePublishing/TrackConverterCLI)**
>
> Convert trk(.gz)? files to vtk poly lines. Adapated to work with InteractivePublishing's copy of slicer. - GitHub - InteractivePublishing/TrackConverterCLI: Convert trk(.gz)? files to vtk poly ...

I managed to compile in windows with vs 2013.

To make it run it needs to be able to find the dll’s from your compiled copy of slicer. I grabbed all the dll files and threw them in the same directory with the exe. That is the wrong solution, but it works.

---

<div class="post-metadata">

**Author:** ![Vinny](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vinny/32/7052_2.png) [@Vinny](https://discourse.slicer.org/u/Vinny)\
**Post date:** [February 8, 2018, 11:25pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/6 "2018-02-08T23:25:46Z")

</div>

Perfect will try it out. Thanks!

---

<div class="post-metadata">

**Author:** ![samuelholly](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samuelholly](https://discourse.slicer.org/u/samuelholly)\
**Post date:** [January 25, 2019, 12:19pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/7 "2019-01-25T12:19:21Z")

</div>

Dear all,

TrackVis can save fibers as VTK polydata which can be directly imported to Slicer.

Best regards

---

<div class="post-metadata">

**Author:** ![SteveJJ](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@SteveJJ](https://discourse.slicer.org/u/SteveJJ)\
**Post date:** [November 24, 2020, 4:23pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/8 "2020-11-24T16:23:16Z")

</div>

Please can you explain how this is done? It is not clear from the menus in TracVis

Thanks!  
Steve

---

<div class="post-metadata">

**Author:** ![samuelholly](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@samuelholly](https://discourse.slicer.org/u/samuelholly)\
**Post date:** [November 25, 2020, 10:25am UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/9 "2020-11-25T10:25:17Z")

</div>

Dear Steve,

when you right-click any track group in the sidepanel, there’s a “Save as…” option. In the dialog that pops-up, you can change the format from .trk to .vtk.

You will be asked to provide an appropriate reference volume (I think to get the correct transformation).

This works for version 0.6.1. I’m not sure about previous versions (though it may work as well).

Best regards

Samuel

---

<div class="post-metadata">

**Author:** ![Eleftherios](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eleftherios/32/11643_2.png) [@Eleftherios](https://discourse.slicer.org/u/Eleftherios)\
**Post date:** [July 15, 2021, 4:18pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/10 "2021-07-15T16:18:02Z")

</div>

Dear @Vinny and all, DIPY has a command called `save_vtk` see here  
[https://dipy.org/documentation/1.3.0./reference/dipy.io/#dipy.io.streamline.save\_vtk](https://dipy.org/documentation/1.3.0./reference/dipy.io/#dipy.io.streamline.save_vtk)  
Which means that you can load the TRK file with DIPY and then save it as VTK.  
Which also means that as you are already using DIPY to do your tracking you can save the result directly to both VTK and TRK (along with TCK and DPY file formats).

I hope this information helps.  
Eleftherios

---

<div class="post-metadata">

**Author:** ![Vinny](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/vinny/32/7052_2.png) [@Vinny](https://discourse.slicer.org/u/Vinny)\
**Post date:** [July 15, 2021, 11:21pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/11 "2021-07-15T23:21:39Z")

</div>

Thanks @Eleftherios, this is very helpful!

---

<div class="post-metadata">

**Author:** ![Eleftherios](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eleftherios/32/11643_2.png) [@Eleftherios](https://discourse.slicer.org/u/Eleftherios)\
**Post date:** [July 16, 2021, 3:28pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/12 "2021-07-16T15:28:06Z")

</div>

Happy to help @Vinny. Let me know if you have any other questions. I wish I have seen this question earlier. Have in mind that I do not check this discourse channel that often. You may want to ask any other related questions on DIPY’s live chatroom (or forum) available here

> **[dipy/dipy](https://gitter.im/dipy/dipy)**
>
> Diffusion MR Imaging in Python

> **[dipy/dipy](https://github.com/dipy/dipy/discussions)**
>
> DIPY is the paragon 3D/4D+ imaging library in Python. Contains generic methods for spatial normalization, signal processing, machine learning, statistical analysis and visualization of medical imag...

Best,  
Eleftherios

---

<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:** [July 17, 2021, 6:12am UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/13 "2021-07-17T06:12:12Z")

</div>

> [@Eleftherios](#):
>
> Let me know if you have any other questions. I wish I have seen this question earlier. Have in mind that I do not check this discourse channel that often.

If you don’t have time to visit this forum regularly but would like to answer questions related to dipy then you can enable email notification for topics posted in the [SlicerDMRI category](https://discourse.slicer.org/c/community/slicerdmri/16) or tagged with [diffusion](https://discourse.slicer.org/tag/diffusion) by going to the category’s or tag’s page, clicking the “bell” icon, and choosing “watching”. I don’t think the amount of messages will be overwhelming, but if you prefer then we can even create a `dipy` tag so that you can sign up for notifications about topics specifically about dipy.

---

<div class="post-metadata">

**Author:** ![Eleftherios](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/eleftherios/32/11643_2.png) [@Eleftherios](https://discourse.slicer.org/u/Eleftherios)\
**Post date:** [July 22, 2021, 8:21pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/14 "2021-07-22T20:21:43Z")

</div>

Thank you @lassoan will do as suggested. Be happy to create a dipy tag.

---

<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:** [July 22, 2021, 8:49pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/15 "2021-07-22T20:49:35Z")

</div>

Done, see here: [https://discourse.slicer.org/tag/dipy](https://discourse.slicer.org/tag/dipy)

You could also sign up to the [diffusion tag](https://discourse.slicer.org/tag/dipy) so that you can direct people towards dipy who have not heard about it yet and would benefit from using it.

---

<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:** [July 22, 2021, 8:59pm UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/16 "2021-07-22T20:59:25Z")

</div>

Now that Slicer users can `pip_install("dipy")` it will be great to see what new things are possible.

---

<div class="post-metadata">

**Author:** ![nayanw775](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nayanw775/32/9963_2.png) [@nayanw775](https://discourse.slicer.org/u/nayanw775)\
**Post date:** [July 28, 2022, 11:05am UTC](https://discourse.slicer.org/t/load-dsi-studio-trk-gz-or-trackvis-trk-tracks-in-slicer/1356/17 "2022-07-28T11:05:13Z")

</div>

@Eleftherios I am wondering, with Dipy or slicer is it possible to convert the .tck into dicom, so that it can be used into to PACS or navigation systems?
