# Convert .tck to .vtk streamlines

**URL:** <https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870>\
**Category:** Support\
**Created:** [November 17, 2023, 5:05am UTC](https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870 "2023-11-17T05:05:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yi\_yang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yi_yang/32/68330_2.png) [@yi\_yang](https://discourse.slicer.org/u/yi_yang)\
**Post date:** [November 17, 2023, 5:05am UTC](https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870/1 "2023-11-17T05:05:38Z")

</div>

Hi,  
I am trying to convert some tractography data from .tck to .vtk format. But I can’t get the correct results that match the image loaded in slicer. I’m not very familiar to vtk files and  
slicer so I’m seeking for help. Here’s the efforts I’ve tried:

1. `tckconvert -scanner2image`  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/0/00d2cce925cec36b5a5fdcf148eb0c1b5d00b322.png) Mrtrix provides a command to realize it. TCK files are in world coordinates and `2image` means changing it to image coordinates(in mm). Then load vtk as` models` with explicitly set `coordinate system` as RAS. But the problems are:

- Anterior and Posterior of the image volume seems wrong as you can see in Fig.1.
- Tracts(yellow) are above the back right of the image volume.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/c/a/ca682f0a809c96e1d6d4971218d07b99b95bfbf7.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/4/54b939f3abfec7949de1dc53267e2b597c3af6c2.png)

1. `tckconvert -scanner2voxel`, where `2voxel` means changing it to voxel coordinates. Also load vtk as` models` with explicitly set `coordinate system` as RAS. Now :

- Tracts(blue) are smaller than it should be.
- different location from tracts(yellow).  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/e/fede079220163139669419387fd23a69c5788308.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/8/0/809fd78599bf32e9c9a3be18bafd1a86ad4d9760.png)

1. python vtk package:  
[reference here](https://mail.python.org/pipermail/neuroimaging/2019-July/002006.html) In reference, a TRK file was loaded and converted,here I replaced with a TCK file.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/c/2c7239c07db1f30391da0087ef49f7b12911378a.png)  
Now:

- Tracts(green) is in the back of the volume

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/a/9a8116e7612445826ffabd853c561aaebfa2e73c.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/0/d0a198714cf72dae44fc8765e4a9ec75bf77ca54.png)

1. python vtk package:I tried to move original coordination in voxel coordinates randomly ( maybe change RAS to LAS, and move tracts backward a little? `10` is a number I test to match, really painful…) As the same, load it as RAS system.  
Now:

- Tracts(red) seems flipped over in A-P direction  

- If I set image as centered when loading image volume, suddenly the tracts(red) can match the volume. However, I still don’t understand the rationale.  

It took me a long time try to figure it out, but I failed… My goal is to convert my tractography to vtk format, then I can use WhiteMatterAnalysis for parcellation. And I want to know:

1. Which coordinate system 3D slicer uses to load and display a nifiti image?
2. Which coordinate system VTK file could receive ?
3. Which coordinate system should I choose when sending a VTK file as a `model`? And what about as `Fiberbundles`?

Anyone’ help will be very much appreciated!

Operating system: Ubuntu  
Slicer version: 5.0.3

---

<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:** [November 17, 2023, 2:00pm UTC](https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870/2 "2023-11-17T14:00:23Z")

</div>

We can’t really comment on what other software does with coordinates. Slicer uses RAS for FiberBundles and stores them in the patient space defined by the DICOM headers of the source DWI scans. If centering the volume on load was required, then whatever software created the tracts threw away the original patient space. We really try to avoid doing that because it removes the ability to correlate with other scans, like structural of functional scans acquired in the same study.

---

<div class="post-metadata">

**Author:** ![yi\_yang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/yi_yang/32/68330_2.png) [@yi\_yang](https://discourse.slicer.org/u/yi_yang)\
**Post date:** [November 18, 2023, 2:28pm UTC](https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870/3 "2023-11-18T14:28:45Z")

</div>

Thanks for your reply! I finally deal with it by extracting b0 volume from the origin 4D volume (I forgot to check if 3D slicer can load 4D image 😂). Actually I accidently found my T1w image was symmetric with DWI in the AP direction, and I’m sure headers are the same. According to advice, I load 3D b0 DWI and it matched well with my vtk file achieved here:

> 3.python vtk package:  
> [reference here](https://mail.python.org/pipermail/neuroimaging/2019-July/002006.html) In reference, a TRK file was loaded and converted,here I replaced with a TCK file.

---

<div class="post-metadata">

**Author:** ![sebastien\_dam](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@sebastien\_dam](https://discourse.slicer.org/u/sebastien_dam)\
**Post date:** [February 2, 2024, 10:32am UTC](https://discourse.slicer.org/t/convert-tck-to-vtk-streamlines/32870/4 "2024-02-02T10:32:11Z")

</div>

Hi!

I’m also trying to convert my streamlines from .tck to .vtk. I extracted the b0 volume and tried to follow the code you gave in reference. However, I cannot visualize any streamlines from the .vtk once converted (using [medInria](https://med.inria.fr/)). Here is the snippet from which I call the function (which I did not touch):

```auto
fname="path/to/.tck"
reference="path/to/b0.nii.gz"
streams = load_tck(fname, reference)
streamlines = Streamlines(streams.streamlines)
saveStreamlinesVTK("sl.vtk")

```

Is it how you did too ? If not, would you mind sharing how you managed to obtain your .vtk streamlines ?

Thank you,

Sébastien
