# How to open .TRE file?

**URL:** https://discourse.itk.org/t/how-to-open-tre-file/2538
**Category:** Beginner Questions
**Created:** [December 18, 2019, 5:21am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538 "2019-12-18T05:21:37Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 23, 2020, 1:49am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/21 "2020-03-23T01:49:43Z")

</div>

Hi,

Oh actually I ran this using 5.0.1 on anaconda. So I guess the bug is the case here.

Thanks again for your fast responses.  
Ali

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [March 23, 2020, 2:07am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/22 "2020-03-23T02:07:38Z")

</div>

Hi

Yes, quite a bit has been rapidly changing in itk. The nightly repo on GitHub is actually typically a good and safe bet.

Have a good week.

S

---

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 23, 2020, 2:10am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/23 "2020-03-23T02:10:04Z")

</div>

Okay great thanks. I will follow from there.

Ali

---

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 23, 2020, 8:14pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/24 "2020-03-23T20:14:18Z")

</div>

@Stephen_Aylward  
I hope you are doing well and had a good day so far. So, after a lot of back and forth, I am using the nightly-master branch of itk. As you said, everything was resolved. However, the last step of installation I am getting a missing file error:

CMake Error at Modules/Remote/TubeTK/TubeTKLib/Filtering/cmake\_install.cmake:41 (file):  
file INSTALL cannot find  
“/home/ali/GIT/ITK/Modules/Remote/TubeTK/TubeTKLib/Filtering/itktubeCastSpatialObjectFilter.h”.  
Call Stack (most recent call first):  
Modules/Remote/TubeTK/TubeTKLib/cmake\_install.cmake:47 (include)  
Modules/Remote/TubeTK/cmake\_install.cmake:69 (include)  
cmake\_install.cmake:346 (include)  
Makefile:61: recipe for target ‘install’ failed  
make: \*\*\* [install] Error 1

Any idea how to resolve this issue? Because I checked the path and this header file is not there, obviously. 🙂  
Thanks  
Ali

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [March 23, 2020, 9:07pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/25 "2020-03-23T21:07:32Z")

</div>

You may have found a bug!

I believe that the CastObject filter was moved to ITK (it isn’t in TubeTK), but perhaps the install script was not updated. Let me check on that tonight/tomorrow. I hope you will only need to delete one line to fix the bug in your copy. I thought I had done that, but maybe not!

s

---

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 23, 2020, 9:10pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/26 "2020-03-23T21:10:10Z")

</div>

So, finally after three days of continues work I managed to pull it off. It’s working, I only had to remove like 5 lines of cmake installation to make it to finish the install. So far, I can import packages with no error. Thanks a lot for the help.

 ![vessels](https://discourse.itk.org/uploads/default/original/2X/6/6110e40e30de7a24ec3299b32ed8cfaad45e475d.jpeg)

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [March 24, 2020, 3:54pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/27 "2020-03-24T15:54:06Z")

</div>

Hi,

In the file ITK/Modules/Remote/TubeTK/TubeTKLib/CMakeLists.txt

Please remove the line that say

itktubeCastSpatialObjectFilter.h

That should do it!

Sorry about that - I almost never do an install (I keep everything in their build trees).

All is now working for me, including using arrayfire (which uses the GPU to make certain operations 40x faster).

Let me know how it goes for you!

Thanks for your patience,

Stephen

---

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 24, 2020, 8:50pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/28 "2020-03-24T20:50:24Z")

</div>

Stephen,

Thank you so much for your great help. I got it running.

Thanks much

Ali

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [March 25, 2020, 1:10am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/29 "2020-03-25T01:10:50Z")

</div>

Hi,

Yes, just don’t run the merge step. The image you want is the one produced by this step:

```auto
TubesToImageFilterType = itk.ConvertTubesToImage[ImageType]
tubesToImageFilter = TubesToImageFilterType.New()
tubesToImageFilter.SetUseRadius(True)
tubesToImageFilter.SetTemplateImage(im1)
tubesToImageFilter.SetInput(tubeG)
tubesToImageFilter.Update()

outputImage = tubesToImageFilter.GetOutput()
view(outputImage)

```

The `outputImage` is what you want.

Congrats!!!

s

---

<div class="post-metadata">

### Author: ![alib022](https://discourse.itk.org/letter_avatar_proxy/v4/letter/a/e47774/32.png) [@alib022](https://discourse.itk.org/u/alib022)
#### Post date: [March 25, 2020, 3:41am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/30 "2020-03-25T03:41:55Z")

</div>

Perfect, thank you so much. I have to admit, there wasnt any way that I could pull this off without your patience and help.

Thanks much.

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [March 25, 2020, 3:27pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/31 "2020-03-25T15:27:22Z")

</div>

So happy it is now working!

Enjoy ITK!

Stephen

---

<div class="post-metadata">

### Author: ![farhan\_009](https://discourse.itk.org/user_avatar/discourse.itk.org/farhan_009/32/1945_2.png) [@farhan\_009](https://discourse.itk.org/u/farhan_009)
#### Post date: [October 27, 2020, 6:19am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/32 "2020-10-27T06:19:00Z")

</div>

Hello @Stephen_Aylward,  
I use the following code to convert the .tre file but I don’t know how to convert it into medical image format(e.g nifti,nrrd,mha etc).Can you tell me the way? Secondly, I have installed itkwidgets and its dependencies but the “view” is not showing anything either on Linux Jupyter notebook nor on windows?  
TubesToImageFilterType = itk.ConvertTubesToImage[ImageType]  
tubesToImageFilter = TubesToImageFilterType.New()  
tubesToImageFilter.SetUseRadius(True)  
tubesToImageFilter.SetTemplateImage(im1)  
tubesToImageFilter.SetInput(tubeG)  
tubesToImageFilter.Update()

outputImage = tubesToImageFilter.GetOutput()  
view(outputImage)

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [October 27, 2020, 1:00pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/33 "2020-10-27T13:00:37Z")

</div>

Hi,

Are you certain that the space (considering origin, orientation, and spacing) occupied by im1 (the template image) overlaps with the space occupied by the vessels in the .tre file? Look at the x, y, z of a vessel centerline point and make certain it occurs within the space of the image.

Also, perhaps take a look at this notebook:  
[https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/Demo-ITKSpatialObjects.ipynb](https://github.com/InsightSoftwareConsortium/ITKTubeTK/blob/master/examples/Demo-ITKSpatialObjects.ipynb)

It shows another way to look at / render spatial objects, including tubes. It will confirm that you have tubes in your group.

Thanks  
Stephen

---

<div class="post-metadata">

### Author: ![farhan\_009](https://discourse.itk.org/user_avatar/discourse.itk.org/farhan_009/32/1945_2.png) [@farhan\_009](https://discourse.itk.org/u/farhan_009)
#### Post date: [October 27, 2020, 1:26pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/34 "2020-10-27T13:26:37Z")

</div>

Thank you for your reply sir @Stephen_Aylward.  
Actually, I have used both of the files to convert and I think they are giving the same result.

 ![Image1](https://discourse.itk.org/uploads/default/original/2X/6/6f3626f824ca3f9ebb27488431ba7fbf5227ab93.png) ![image2](https://discourse.itk.org/uploads/default/original/2X/7/7b95e7b0c9b9613acfff73402356a564f9c91b92.png) Please the attached Images.My question was how to convert that “outputimage” to .nii format to use as a label?  
And why the view of itkwidgets is not working in Jupyter notebook? Are they are linked together?

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [October 27, 2020, 1:37pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/35 "2020-10-27T13:37:28Z")

</div>

The output is not surprising - the input and output images occupy the same space. However, it doesn’t tell me if your tubes occupy the space of the image.

Are you using the data provided with TubeTK - the images and the tubes?

To save an image the command is  
itk.imwrite(im1, “filename.nii”)

---

<div class="post-metadata">

### Author: ![farhan\_009](https://discourse.itk.org/user_avatar/discourse.itk.org/farhan_009/32/1945_2.png) [@farhan\_009](https://discourse.itk.org/u/farhan_009)
#### Post date: [October 27, 2020, 2:08pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/36 "2020-10-27T14:08:32Z")

</div>

yes ,the same dataset that is provided online by ITKTube.

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [October 27, 2020, 2:14pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/37 "2020-10-27T14:14:43Z")

</div>

Have you compiled ITK head from source (not an ITK release, but the head branch of the source code) and enabled TubeTK in cmake?

Regretfully the current pip install of ITK is not compatible with the head of TubeTK.

s

---

<div class="post-metadata">

### Author: ![lisongang-PR](https://discourse.itk.org/user_avatar/discourse.itk.org/lisongang-pr/32/1858_2.png) [@lisongang-PR](https://discourse.itk.org/u/lisongang-PR)
#### Post date: [January 15, 2021, 11:26am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/39 "2021-01-15T11:26:31Z")

</div>

Hi,  
Using these code, I got the following result.It seems that the connectivity of blood vessels is not as good as Ali，Why？Did I do something wrong？  
TubesToImageFilterType = itk.ConvertTubesToImage[ImageType]  
tubesToImageFilter = TubesToImageFilterType.New()  
tubesToImageFilter.SetUseRadius(True)  
tubesToImageFilter.SetTemplateImage(im1)  
tubesToImageFilter.SetInput(tubeG)  
tubesToImageFilter.Update()

outputImage = tubesToImageFilter.GetOutput()  
view(outputImage)

 ![image](https://discourse.itk.org/uploads/default/original/2X/e/ea1f89f36383505ff0087d05b6903393c9a48c27.jpeg)

---

<div class="post-metadata">

### Author: ![Stephen\_Aylward](https://discourse.itk.org/user_avatar/discourse.itk.org/stephen_aylward/32/654_2.png) [@Stephen\_Aylward](https://discourse.itk.org/u/Stephen_Aylward)
#### Post date: [February 17, 2021, 7:14pm UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/40 "2021-02-17T19:14:15Z")

</div>

Hi,

There are two issues that are combining to cause this visualization to look “choppy”.

First, the resolution of the image and the size of the small vessels are nearly the same - as a result, when ConvertTubesToImage is applied and it must decide if a voxel is inside or outside of a vessel, the really small vessels could only partially fill adjacent voxels in such a way that a “gap” seems to appear. This is generally known as “partial voluming”, and slightly blurring and/or dilating an image can help reduce this effect.

Second, the volume rendering transfer function being applied to visualize the image appears to have a sharp step in it that is accentuating the effects of partial voluming. Try smoothing the transfer function to have a more gentle slope and/or move the sharp step to a higher value so that more of the partial voxels are made to appear as “solid” vessel voxels.

Another solution to getting improved visualizations is to convert the .tre file into a VTK surface rendering. That eliminates partial voluming and the need for volume rendering. There is a command-line application included with TubeTK called ConvertTubesToSurface that generates .vtp files from .tre files. It is only available as a command-line tool so it is a bit more challenging to compile and generate it, but I’d be happy to help (perhaps it is best just to send you the executable 🙂 ).

Hope this helps,  
Stephen

---

<div class="post-metadata">

### Author: ![lisongang-PR](https://discourse.itk.org/user_avatar/discourse.itk.org/lisongang-pr/32/1858_2.png) [@lisongang-PR](https://discourse.itk.org/u/lisongang-PR)
#### Post date: [April 23, 2021, 6:11am UTC](https://discourse.itk.org/t/how-to-open-tre-file/2538/42 "2021-04-23T06:11:10Z")

</div>

This question has puzzled me for a long time, thank you for your detailed answer!

It’s really hard for me to use command-line tool，so,could you please send me the executable？

SongAng

[Previous page](https://discourse.itk.org/t/how-to-open-tre-file/2538.md?page=1)

[Next page](https://discourse.itk.org/t/how-to-open-tre-file/2538.md?page=3)
