How to open .TRE file?

Good news! This functionality is now available via TubeTK Python.

From Python, the commands (in long form) will look like:

import itk
from itk import TubeTK as ttk

surfaceWriterType = ttk.WriteTubesAsPolyData
surfaceWriter = surfaceWriterType.New()
surfaceWriter.SetInput(tubes)
surfaceWriter.SetFileName("tubes.vtp")
surfaceWriter.Update()

The equivalent functionality in short form are

writer = ttk.WriteTubesAsPolyData.New(Input=tubes, FileName="tubes3.vtp").Update()

pip install itk-tubetk

Should get you the version that supports this new feature, but if it doesn’t please let me know, and I will push a new version to pipy.

1 Like

I tried to update the tubetk, but there was an error: attributeerror: module ‘tubetk’ has no attribute ‘writetubesaspolydata’. Maybe this function has not been updated yet?

Ok - I will make a new wheel for pip.

Stay tuned…

We are one bug away from releasing these wheels. Sorry for the delay. With the new wheel generation scripts, the wheels have to work 100% on every platform before they can be released, and several bugs creeped in that needed to be squashed.

You can follow the last bug fix pursuit here:

Thank you for your kind help :smiley:, I will continue to pay attention to this

Hi SongAng,

It should be ready!

Let me know how it goes for you.

Stephen

1 Like

Hi, Stephen,
I noticed that the function needs to input the vtp file. How can I get it from the tre file?

SongAng

Hi,

The function call
SetFileName("Tubes.vtp")
is used to tell the class the name of the file to be created. VTP is a polydata file format that is used by VTK-based applications such as ParaView and ParaView Glance.

I’m adding a jupyter notebook to give a demo of this command. In short, the relevant code snippet is
ttk.WriteTubesAsPolyData.New(Input=tubes,FileName="Tube.vtp").Update()

The file “Tube.vtp” is the polydata defined by the hierarchy of ITKSpatialObjects in the variable “tubes”. The Tube.vtp file can then be dragged-and-dropped onto ParaView Glance in your web browser, and the results (after setting “Color By:” to “Id”) should look like

Hi,
When I use

ttk.WriteTubesAsPolyData.New(Input=tubes,FileName=“Tube.vtp”).Update()

It has the following problems:
itkImageF4 not loaded from module TubeTK because of exception:
module ‘itk.TubeTKPython’ has no attribute ‘itkImageF4’
vectoritkImageF4 not loaded from module TubeTK because of exception:
module ‘itk.TubeTKPython’ has no attribute ‘vectoritkImageF4’

Hi,

That is just a warning. I’m working to remove it. The file should still be written.

s

Hi,
Indeed, I found it in the folder, I put it in Paraview Grace and got the result! Thank you sincerely for your long-term help!

SongAng

2 Likes

Hi @Stephen_Aylward
When I use “pip install itk-tubetk” (version 0.9.0) to install TubeTK, I can’t import itk-tubetk:

No module named 'itk_tubetk'

Do you have any better suggestions? Also, when I use itk (version 5.2.1) to convert “.tre” files, I got following errors:

itkImageF4 not loaded from module TubeTK because of exception:
 module 'itk.TubeTKPython' has no attribute 'itkImageF4'
vectoritkImageF4 not loaded from module TubeTK because of exception:
 module 'itk.TubeTKPython' has no attribute 'vectoritkImageF4'

P.S. itk is installed with the pip install itk command.

Best,
Ray

Hi Ray,

As in the TubeTK examples, this import can be used:

from itk import TubeTK as ttk
1 Like

Hello, the following problem occurred when my code was running: ‘Segmentation fault (core dumped)’. What is the reason? I haven’t solved it. Thanks !

Hi,

Which line is producing the seg fault?

I’m having trouble reproducing this error. Using that same data from data.kitware.com, the following code works:

Please try running this code on your machine and reporting if it works or not. The .mha and .tre file should be in the same directory as the code / jupyter notebook. I’ve attached the jupyter notebook for your convenience.
VascularNetwork.ipynb (2.7 KB)

If it fails, we will need to check the version of ITK and TubeTK installed on your machine.

Stephen

1 Like

Thank you. The problem is solved. We changed a server and ran successfully. This error occurred on a large-scale computing platform before.

2 Likes

Outstanding!!! Thank you for following up!

Stephen

1 Like

Thank you so much

1 Like

Hi, thanks for the information. Would you please provide the ITK and TubeTK versions supports this .ipynb file? Mine are:
itk-5.3rc4.post2
itk-tubetk-1.1rc1
itk-minimalpathextraction-1.2.2

I have followed the discussion from earlier but I am stuck with the this error:

This seems like another instance of BUG: `v5.3rc04.post2` breaks backwards compatibility with external module Python packages · Issue #3528 · InsightSoftwareConsortium/ITK · GitHub.

Does updating itk-minimalpathextraction to version 1.2.3 resolve the issue?

If not, I think that updating CI to the latest ITK and making a new PyPI package would resolve this @Stephen_Aylward.