# How to read/write an ITK TubeSpatialObject？

**URL:** https://discourse.itk.org/t/how-to-read-write-an-itk-tubespatialobject/2178
**Category:** Beginner Questions
**Created:** [August 20, 2019, 4:05pm UTC](https://discourse.itk.org/t/how-to-read-write-an-itk-tubespatialobject/2178 "2019-08-20T16:05:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Barcelona16](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@Barcelona16](https://discourse.itk.org/u/Barcelona16)
#### Post date: [August 20, 2019, 4:05pm UTC](https://discourse.itk.org/t/how-to-read-write-an-itk-tubespatialobject/2178/1 "2019-08-20T16:05:09Z")

</div>

If i want to read an object like this

```auto
import itk
PixelType = itk.UC
Dimension = 3
ReaderType = itk.TubeSpatialObject[3]
reader = ReaderType.New()
reader.GetProperty().SetName(inputImage)

```

Is there a convenient to make it?  
How can i generate the ground truth from [VascularNetwork.tre](https://data.kitware.com/#collection/591086ee8d777f16d01e0724/folder/58a372fa8d777f0721a64dfb)?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 20, 2019, 4:35pm UTC](https://discourse.itk.org/t/how-to-read-write-an-itk-tubespatialobject/2178/2 "2019-08-20T16:35:21Z")

</div>

@Stephen_Aylward can best answer this.

---

<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: [August 27, 2019, 1:59pm UTC](https://discourse.itk.org/t/how-to-read-write-an-itk-tubespatialobject/2178/3 "2019-08-27T13:59:09Z")

</div>

Excellent examples of reading a SpatialObject are given in the ITK Software Guide and in the example files. For example, see

ITK/Examples/SpatialObjects/ReadWriteSpatialObject.cxx

There is also info on the TubeSpatialObject API at

ITK/Examples/TubeSpatialObject.cxx

Hope this helps,

Stephen
