# Programmetically writing streamlines (fibers) with angle, anisotropy like supporting information

**URL:** https://discourse.vtk.org/t/programmetically-writing-streamlines-fibers-with-angle-anisotropy-like-supporting-information/14566
**Category:** Support
**Tags:** python
**Created:** [September 13, 2024, 4:12am UTC](https://discourse.vtk.org/t/programmetically-writing-streamlines-fibers-with-angle-anisotropy-like-supporting-information/14566 "2024-09-13T04:12:27Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Windy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/w/91b2a8/32.png) [@Windy](https://discourse.vtk.org/u/Windy)
#### Post date: [September 13, 2024, 4:12am UTC](https://discourse.vtk.org/t/programmetically-writing-streamlines-fibers-with-angle-anisotropy-like-supporting-information/14566/1 "2024-09-13T04:12:28Z")

</div>

Hi all,

I programmatically compute fiber tract in micro-CT images. I have a set of streamlines, each described as two nodes (the coordinates of each node are known), along with their angle with centerline and calculated anisotropy. I want to convert this to .vtk format for visualization and further analysis purposes.

From my digging up until now. I figured out;

1. I first need to create `vtk.PolyData()` object from the node coordinates `polydata_object.SetPoints(coordinates)`. One node is one point.
2. Then, for each line, I could do the following:

```auto
lines = vtkCellArray()
lines.InsertNextCell(2)
lines.InsertCellPoint(point_a)
lines.InsertCellPoint(point_b)
polydata_object.SetLines(lines)

```

I have a few questions:

1. First of all, is my approach correct?
2. When we use `.SetLines()` does it clear existing lines and add the new one or append to the existing lines?
3. How do I add the angle and anisotropy information of each line to the above PolyData object?

These might be dumb questions, but I am new to vtk.

Thank you in advance.
