# Why my vtk does not contain time series?

**URL:** https://discourse.vtk.org/t/why-my-vtk-does-not-contain-time-series/11246
**Category:** Support
**Created:** [April 18, 2023, 7:40pm UTC](https://discourse.vtk.org/t/why-my-vtk-does-not-contain-time-series/11246 "2023-04-18T19:40:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Clifford](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/c/e56c9b/32.png) [@Clifford](https://discourse.vtk.org/u/Clifford)
#### Post date: [April 18, 2023, 7:40pm UTC](https://discourse.vtk.org/t/why-my-vtk-does-not-contain-time-series/11246/1 "2023-04-18T19:40:57Z")

</div>

I create my data through apply\_inverse(), from mne python, I want to write my data into a vtk file with a time series, however I can only get a static vtk file, don’t know where does wrong. Thanks for your help!  
Here is my code:

```auto
stc_suf = apply_inverse(evoked, inv, lambda2, inv_method)
    data=stc_suf.data
    # Assuming you have already generated your data and visualized it
    # using stc_suf.plot() and mlab.show()

    # Define the output filename
    filename = 'output_lh.vtk'
    filename2 = 'output_rh.vtk'
    polydata = vtk.vtkPolyData()
    points = vtk.vtkPoints()
    
    # Get the vertices and faces from the stc_suf object
    vertices1, faces1 = read_surface('./test/surf/lh.pial')
    vertices2, faces2 = read_surface('./test/surf/rh.pial')
    for vertex in vertices1:
        points.InsertNextPoint(vertex)
        polydata.SetPoints(points)
    triangles = vtk.vtkCellArray()
    for face in faces1:
        triangle = vtk.vtkTriangle()
        triangle.GetPointIds().SetId(0, face[0])
        triangle.GetPointIds().SetId(1, face[1])
        triangle.GetPointIds().SetId(2, face[2])
        triangles.InsertNextCell(triangle)
        polydata.SetPolys(triangles)

    scalars = vtk.vtkFloatArray()
    scalars.SetNumberOfComponents(data.shape[1])
    scalars.SetName('TimeSeriesData')
    for i in range(data.shape[1]):
        for j in range(data.shape[0]):
            scalars.InsertNextValue(data[j, i])
            polydata.GetPointData().SetScalars(scalars)

    writer = vtk.vtkPolyDataWriter()
    writer.SetFileName(filename)
    writer.SetFileTypeToASCII()
    writer.SetInputData(polydata)
    writer.Write()

```
